mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +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',
|
shouldForwardProp: (prop) => prop !== 'hasValue',
|
||||||
})<{ hasValue: boolean }>(({ theme, hasValue }) => ({
|
})<{ hasValue: boolean }>(({ theme, hasValue }) => ({
|
||||||
color: hasValue ? 'inherit' : theme.palette.primary.main,
|
color: hasValue ? 'inherit' : theme.palette.primary.main,
|
||||||
|
width: 'max-content',
|
||||||
'.MuiChip-icon': {
|
'.MuiChip-icon': {
|
||||||
transform: 'translateX(50%)',
|
transform: 'translateX(50%)',
|
||||||
fill: theme.palette.primary.main,
|
fill: theme.palette.primary.main,
|
||||||
|
@ -36,11 +36,8 @@ const Container = styled('article')(({ theme }) => ({
|
|||||||
backgroundColor: theme.palette.background.paper,
|
backgroundColor: theme.palette.background.paper,
|
||||||
borderRadius: theme.shape.borderRadiusLarge,
|
borderRadius: theme.shape.borderRadiusLarge,
|
||||||
border: `1px solid ${theme.palette.divider}`,
|
border: `1px solid ${theme.palette.divider}`,
|
||||||
containerType: 'inline-size',
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const onNarrowContainer = '@container (max-width: 700px)';
|
|
||||||
|
|
||||||
const TopRow = styled('div')(({ theme }) => ({
|
const TopRow = styled('div')(({ theme }) => ({
|
||||||
'--gap': theme.spacing(1),
|
'--gap': theme.spacing(1),
|
||||||
padding: 'var(--padding)',
|
padding: 'var(--padding)',
|
||||||
@ -53,27 +50,21 @@ const TopRow = styled('div')(({ theme }) => ({
|
|||||||
|
|
||||||
const ConstraintOptions = styled('div')(({ theme }) => ({
|
const ConstraintOptions = styled('div')(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexFlow: 'row nowrap',
|
flexFlow: 'row wrap',
|
||||||
gap: 'var(--gap)',
|
gap: 'var(--gap)',
|
||||||
alignSelf: 'flex-start',
|
alignSelf: 'flex-start',
|
||||||
[onNarrowContainer]: {
|
|
||||||
flexFlow: 'row wrap',
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const OperatorOptions = styled(ConstraintOptions)(({ theme }) => ({
|
const OperatorOptions = styled(ConstraintOptions)(({ theme }) => ({
|
||||||
flexFlow: 'row nowrap',
|
flexFlow: 'row wrap',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const ConstraintDetails = styled('div')(({ theme }) => ({
|
const ConstraintDetails = styled('div')(({ theme }) => ({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
gap: 'var(--gap)',
|
gap: 'var(--gap)',
|
||||||
flexFlow: 'row nowrap',
|
flexFlow: 'row wrap',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
height: 'min-content',
|
height: 'min-content',
|
||||||
[onNarrowContainer]: {
|
|
||||||
flexDirection: 'column',
|
|
||||||
},
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const InputContainer = styled('div')(({ theme }) => ({
|
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 { Chip, type ChipProps, styled, type Theme } from '@mui/material';
|
||||||
import { type FC, forwardRef, type PropsWithChildren, useRef } from 'react';
|
import { type FC, forwardRef, type PropsWithChildren, useRef } from 'react';
|
||||||
|
|
||||||
const ValueListWrapper = styled('div')(({ theme }) => ({
|
const ValueListWrapper = styled('div')({
|
||||||
display: 'flex',
|
display: 'contents',
|
||||||
flexFlow: 'row wrap',
|
});
|
||||||
gap: theme.spacing(1),
|
|
||||||
}));
|
|
||||||
|
|
||||||
const StyledList = styled('ul')({
|
const StyledList = styled('ul')({
|
||||||
listStyle: 'none',
|
listStyle: 'none',
|
||||||
padding: 0,
|
|
||||||
display: 'contents',
|
display: 'contents',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user