mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-23 01:16:27 +02:00
Fix/constraint value wrapping (#9873)
Changes how constraint values are treated and wrapped. Previously, they would have their own column and fill it up:  Then we changed it to always being on the next line below certain widths:  But that would also cause it to break even if there was no need for it. This iteration instead uses display `contents` on the value lists to let them be handled by the flex flow of the containing element. This allows them to only wrap when necessary. <img width="995" alt="image" src="https://github.com/user-attachments/assets/d61f6f49-b1ef-49ec-91a4-df868cedc678" /> Of course, if they don't need to wrap, they don't: <img width="1030" alt="image" src="https://github.com/user-attachments/assets/84c27997-7cb2-4e1b-8977-d43a46f7de6e" /> This loom video shows how it folds in the most complex scenario, with all elements being visible and within bounds down to about 300px: https://www.loom.com/share/4f29cdb105d54edeb70edd54dfaca9f9
This commit is contained in:
parent
3c6d797234
commit
0e1ab236c9
@ -8,6 +8,7 @@ const StyledChip = styled(ValueChip, {
|
||||
shouldForwardProp: (prop) => prop !== 'hasValue',
|
||||
})<{ hasValue: boolean }>(({ theme, hasValue }) => ({
|
||||
color: hasValue ? 'inherit' : theme.palette.primary.main,
|
||||
width: 'max-content',
|
||||
'.MuiChip-icon': {
|
||||
transform: 'translateX(50%)',
|
||||
fill: theme.palette.primary.main,
|
||||
|
@ -36,11 +36,8 @@ const Container = styled('article')(({ theme }) => ({
|
||||
backgroundColor: theme.palette.background.paper,
|
||||
borderRadius: theme.shape.borderRadiusLarge,
|
||||
border: `1px solid ${theme.palette.divider}`,
|
||||
containerType: 'inline-size',
|
||||
}));
|
||||
|
||||
const onNarrowContainer = '@container (max-width: 700px)';
|
||||
|
||||
const TopRow = styled('div')(({ theme }) => ({
|
||||
'--gap': theme.spacing(1),
|
||||
padding: 'var(--padding)',
|
||||
@ -53,27 +50,21 @@ const TopRow = styled('div')(({ theme }) => ({
|
||||
|
||||
const ConstraintOptions = styled('div')(({ theme }) => ({
|
||||
display: 'flex',
|
||||
flexFlow: 'row nowrap',
|
||||
flexFlow: 'row wrap',
|
||||
gap: 'var(--gap)',
|
||||
alignSelf: 'flex-start',
|
||||
[onNarrowContainer]: {
|
||||
flexFlow: 'row wrap',
|
||||
},
|
||||
}));
|
||||
|
||||
const OperatorOptions = styled(ConstraintOptions)(({ theme }) => ({
|
||||
flexFlow: 'row nowrap',
|
||||
flexFlow: 'row wrap',
|
||||
}));
|
||||
|
||||
const ConstraintDetails = styled('div')(({ theme }) => ({
|
||||
display: 'flex',
|
||||
gap: 'var(--gap)',
|
||||
flexFlow: 'row nowrap',
|
||||
flexFlow: 'row wrap',
|
||||
width: '100%',
|
||||
height: 'min-content',
|
||||
[onNarrowContainer]: {
|
||||
flexDirection: 'column',
|
||||
},
|
||||
}));
|
||||
|
||||
const InputContainer = styled('div')(({ theme }) => ({
|
||||
|
@ -2,15 +2,12 @@ import Clear from '@mui/icons-material/Clear';
|
||||
import { Chip, type ChipProps, styled, type Theme } from '@mui/material';
|
||||
import { type FC, forwardRef, type PropsWithChildren, useRef } from 'react';
|
||||
|
||||
const ValueListWrapper = styled('div')(({ theme }) => ({
|
||||
display: 'flex',
|
||||
flexFlow: 'row wrap',
|
||||
gap: theme.spacing(1),
|
||||
}));
|
||||
const ValueListWrapper = styled('div')({
|
||||
display: 'contents',
|
||||
});
|
||||
|
||||
const StyledList = styled('ul')({
|
||||
listStyle: 'none',
|
||||
padding: 0,
|
||||
display: 'contents',
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user