Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[List][joy-ui] Add gap and missing active styles #39146

Merged
merged 9 commits into from
Sep 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function ExampleChoiceChipCheckbox() {
'--List-gap': '8px',
'--ListItem-radius': '20px',
'--ListItem-minHeight': '32px',
'--ListItem-gap': '4px',
}}
>
{['Elevator', 'Washer/Dryer', 'Fireplace', 'Dogs ok', 'Cats ok'].map(
Expand All @@ -30,7 +31,7 @@ export default function ExampleChoiceChipCheckbox() {
<Done
fontSize="md"
color="primary"
sx={{ ml: -0.5, mr: 0.5, zIndex: 2, pointerEvents: 'none' }}
sx={{ ml: -0.5, zIndex: 2, pointerEvents: 'none' }}
/>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function ExampleChoiceChipCheckbox() {
'--List-gap': '8px',
'--ListItem-radius': '20px',
'--ListItem-minHeight': '32px',
'--ListItem-gap': '4px',
}}
>
{['Elevator', 'Washer/Dryer', 'Fireplace', 'Dogs ok', 'Cats ok'].map(
Expand All @@ -30,7 +31,7 @@ export default function ExampleChoiceChipCheckbox() {
<Done
fontSize="md"
color="primary"
sx={{ ml: -0.5, mr: 0.5, zIndex: 2, pointerEvents: 'none' }}
sx={{ ml: -0.5, zIndex: 2, pointerEvents: 'none' }}
/>
)}
<Checkbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,12 @@ export default function ExampleFilterMemberCheckbox() {
<div role="group" aria-labelledby="member">
<List
sx={{
'--ListItem-gap': '0.75rem',
[`& .${checkboxClasses.root}`]: {
mr: 'auto',
flexGrow: 1,
alignItems: 'center',
flexDirection: 'row-reverse',
gap: 1.5,
},
'& li': {
gap: 1.25,
},
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export default function ExampleFilterMemberCheckbox() {
variant="outlined"
sx={{
p: 2,

borderRadius: 'sm',
width: 360,
maxWidth: '100%',
Expand All @@ -41,15 +40,12 @@ export default function ExampleFilterMemberCheckbox() {
<div role="group" aria-labelledby="member">
<List
sx={{
'--ListItem-gap': '0.75rem',
[`& .${checkboxClasses.root}`]: {
mr: 'auto',
flexGrow: 1,
alignItems: 'center',
flexDirection: 'row-reverse',
gap: 1.5,
},
'& li': {
gap: 1.25,
},
}}
>
Expand Down
4 changes: 2 additions & 2 deletions docs/data/joy/components/list/ExampleCollapsibleList.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function ExampleCollapsibleList() {
>
Tutorial
</Typography>
<Typography component="span" level="body-xs" sx={{ ml: 1 }}>
<Typography component="span" level="body-xs">
9
</Typography>
</ListItem>
Expand Down Expand Up @@ -140,7 +140,7 @@ export default function ExampleCollapsibleList() {
>
How-to Guides
</Typography>
<Typography component="span" level="body-xs" sx={{ ml: 1 }}>
<Typography component="span" level="body-xs">
39
</Typography>
</ListItem>
Expand Down
4 changes: 2 additions & 2 deletions docs/data/joy/components/list/ExampleCollapsibleList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function ExampleCollapsibleList() {
>
Tutorial
</Typography>
<Typography component="span" level="body-xs" sx={{ ml: 1 }}>
<Typography component="span" level="body-xs">
9
</Typography>
</ListItem>
Expand Down Expand Up @@ -142,7 +142,7 @@ export default function ExampleCollapsibleList() {
>
How-to Guides
</Typography>
<Typography component="span" level="body-xs" sx={{ ml: 1 }}>
<Typography component="span" level="body-xs">
39
</Typography>
</ListItem>
Expand Down
14 changes: 12 additions & 2 deletions docs/data/joy/components/list/ExampleIOSList.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ export default function ExampleIOSList() {
</Sheet>
</ListItemDecorator>
<ListItemContent>Wi-Fi</ListItemContent>
<Typography textColor="text.tertiary">Mars</Typography>
<Typography
textColor="text.tertiary"
sx={{ mr: 'calc(-1 * var(--ListItem-gap))' }}
>
Mars
</Typography>
<KeyboardArrowRight fontSize="xl3" />
</ListItemButton>
</ListItem>
Expand All @@ -175,7 +180,12 @@ export default function ExampleIOSList() {
</Sheet>
</ListItemDecorator>
<ListItemContent>Bluetooth</ListItemContent>
<Typography textColor="text.tertiary">On</Typography>
<Typography
textColor="text.tertiary"
sx={{ mr: 'calc(-1 * var(--ListItem-gap))' }}
>
On
</Typography>
<KeyboardArrowRight fontSize="xl3" />
</ListItemButton>
</ListItem>
Expand Down
14 changes: 12 additions & 2 deletions docs/data/joy/components/list/ExampleIOSList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,12 @@ export default function ExampleIOSList() {
</Sheet>
</ListItemDecorator>
<ListItemContent>Wi-Fi</ListItemContent>
<Typography textColor="text.tertiary">Mars</Typography>
<Typography
textColor="text.tertiary"
sx={{ mr: 'calc(-1 * var(--ListItem-gap))' }}
>
Mars
</Typography>
<KeyboardArrowRight fontSize="xl3" />
</ListItemButton>
</ListItem>
Expand All @@ -175,7 +180,12 @@ export default function ExampleIOSList() {
</Sheet>
</ListItemDecorator>
<ListItemContent>Bluetooth</ListItemContent>
<Typography textColor="text.tertiary">On</Typography>
<Typography
textColor="text.tertiary"
sx={{ mr: 'calc(-1 * var(--ListItem-gap))' }}
>
On
</Typography>
<KeyboardArrowRight fontSize="xl3" />
</ListItemButton>
</ListItem>
Expand Down
1 change: 1 addition & 0 deletions docs/data/joy/components/list/ExampleNavigationMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ export default function ExampleNavigationMenu() {
'--List-radius': '8px',
'--List-padding': '4px',
'--List-gap': '8px',
'--ListItem-gap': '0px',
}}
>
<ListItem role="none">
Expand Down
1 change: 1 addition & 0 deletions docs/data/joy/components/list/ExampleNavigationMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ export default function ExampleNavigationMenu() {
'--List-radius': '8px',
'--List-padding': '4px',
'--List-gap': '8px',
'--ListItem-gap': '0px',
}}
>
<ListItem role="none">
Expand Down
2 changes: 0 additions & 2 deletions docs/data/joy/components/tabs/TabsPageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export default function TabsPageExample() {
size="sm"
variant="soft"
color={index === 0 ? 'primary' : 'neutral'}
sx={{ ml: 1 }}
>
14
</Chip>
Expand All @@ -64,7 +63,6 @@ export default function TabsPageExample() {
size="sm"
variant="soft"
color={index === 1 ? 'primary' : 'neutral'}
sx={{ ml: 1 }}
>
24
</Chip>
Expand Down
2 changes: 0 additions & 2 deletions docs/data/joy/components/tabs/TabsPageExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export default function TabsPageExample() {
size="sm"
variant="soft"
color={index === 0 ? 'primary' : 'neutral'}
sx={{ ml: 1 }}
>
14
</Chip>
Expand All @@ -64,7 +63,6 @@ export default function TabsPageExample() {
size="sm"
variant="soft"
color={index === 1 ? 'primary' : 'neutral'}
sx={{ ml: 1 }}
>
24
</Chip>
Expand Down
2 changes: 2 additions & 0 deletions docs/data/joy/components/tabs/TabsUsage.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import TabList from '@mui/joy/TabList';
import Tab from '@mui/joy/Tab';
import TabPanel from '@mui/joy/TabPanel';
import JoyUsageDemo from 'docs/src/modules/components/JoyUsageDemo';
import Apps from '@mui/icons-material/Apps';

export default function TabsUsage() {
const [index, setIndex] = React.useState(0);
Expand Down Expand Up @@ -108,6 +109,7 @@ export default function TabsUsage() {
disableIndicator={disableIndicator}
{...(index === 0 && { color, variant })}
>
<Apps />
Tab A
</Tab>
<Tab
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function ColorInversionFooter() {
size="sm"
orientation="horizontal"
wrap
sx={{ flexGrow: 0, '--ListItem-radius': '8px' }}
sx={{ flexGrow: 0, '--ListItem-radius': '8px', '--ListItem-gap': '0px' }}
>
<ListItem nested sx={{ width: { xs: '50%', md: 140 } }}>
<ListSubheader>Sitemap</ListSubheader>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default function ColorInversionFooter() {
size="sm"
orientation="horizontal"
wrap
sx={{ flexGrow: 0, '--ListItem-radius': '8px' }}
sx={{ flexGrow: 0, '--ListItem-radius': '8px', '--ListItem-gap': '0px' }}
>
<ListItem nested sx={{ width: { xs: '50%', md: 140 } }}>
<ListSubheader>Sitemap</ListSubheader>
Expand Down
3 changes: 3 additions & 0 deletions packages/mui-joy/src/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const StyledList = styled('ul')<{ ownerState: ListOwnerState }>(({ theme,
'--ListItem-minHeight': '2rem',
'--ListItem-paddingY': '3px',
'--ListItem-paddingX': '0.5rem',
'--ListItem-gap': '0.5rem',
'--ListItemDecorator-size': ownerState.orientation === 'horizontal' ? '1.5rem' : '2rem',
'--Icon-fontSize': theme.vars.fontSize.lg,
};
Expand All @@ -57,6 +58,7 @@ export const StyledList = styled('ul')<{ ownerState: ListOwnerState }>(({ theme,
'--ListItem-minHeight': '2.25rem',
'--ListItem-paddingY': '0.25rem',
'--ListItem-paddingX': '0.75rem',
'--ListItem-gap': '0.625rem',
'--ListItemDecorator-size': ownerState.orientation === 'horizontal' ? '1.75rem' : '2.5rem',
'--Icon-fontSize': theme.vars.fontSize.xl,
};
Expand All @@ -67,6 +69,7 @@ export const StyledList = styled('ul')<{ ownerState: ListOwnerState }>(({ theme,
'--ListItem-minHeight': '2.75rem',
'--ListItem-paddingY': '0.375rem',
'--ListItem-paddingX': '1rem',
'--ListItem-gap': '0.75rem',
'--ListItemDecorator-size': ownerState.orientation === 'horizontal' ? '2.25rem' : '3rem',
'--Icon-fontSize': theme.vars.fontSize.xl2,
};
Expand Down
4 changes: 3 additions & 1 deletion packages/mui-joy/src/ListItem/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const StyledListItem = styled('li')<{ ownerState: ListItemOwnerState }>(
'--ListItemButton-marginInline': `calc(-1 * var(--ListItem-paddingLeft)) calc(-1 * var(--ListItem-paddingRight))`,
'--ListItemButton-marginBlock': 'calc(-1 * var(--ListItem-paddingY))',
alignItems: 'center',
gap: 'var(--ListItem-gap)',
marginInline: 'var(--ListItem-marginInline)',
} as const),
ownerState.nested &&
Expand Down Expand Up @@ -74,7 +75,8 @@ export const StyledListItem = styled('li')<{ ownerState: ListItemOwnerState }>(
}),
boxSizing: 'border-box',
borderRadius: 'var(--ListItem-radius)',
display: 'flex',
display: 'var(--_ListItem-display)',
'&:not([hidden])': { '--_ListItem-display': 'flex' },
Comment on lines +78 to +79
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To work with native HTML hidden attribute.

flex: 'none', // prevent children from shrinking when the List's height is limited.
position: 'relative',
paddingBlockStart: ownerState.nested ? 0 : 'var(--ListItem-paddingY)',
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-joy/src/ListItemButton/ListItemButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const StyledListItemButton = styled('div')<{ ownerState: ListItemButtonOw
flexDirection: 'row',
alignItems: 'center',
alignSelf: 'stretch', // always stretch itself to fill the parent (List|ListItem)
gap: 'var(--ListItem-gap)',
...(ownerState.orientation === 'vertical' && {
flexDirection: 'column',
justifyContent: 'center',
Expand Down Expand Up @@ -90,6 +91,7 @@ export const StyledListItemButton = styled('div')<{ ownerState: ListItemButtonOw
zIndex: 1, // to be above of the next element. For example, the first Tab item should be above the second so that the outline is above the second Tab.
},
...theme.variants[ownerState.variant!]?.[ownerState.color!],
'&:active': theme.variants[`${ownerState.variant!}Active`]?.[ownerState.color!],
[`.${listItemClasses.root} > &`]: {
'--unstable_ListItem-flex': '1 0 0%', // grow to fill the available space of ListItem
},
Expand Down
2 changes: 2 additions & 0 deletions packages/mui-joy/src/ListItemDecorator/ListItemDecorator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ const ListItemDecoratorRoot = styled('span', {
...(ownerState.parentOrientation === 'horizontal'
? {
minInlineSize: 'var(--ListItemDecorator-size)',
marginInlineEnd: 'calc(-1 * var(--ListItem-gap))',
}
: {
minBlockSize: 'var(--ListItemDecorator-size)',
justifyContent: 'center',
marginBlockEnd: 'calc(-1 * var(--ListItem-gap))',
}),
}));
/**
Expand Down
1 change: 1 addition & 0 deletions packages/mui-joy/src/TabList/TabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ const TabListRoot = styled(StyledList, {
'--List-gap': '0px',
'--ListDivider-gap': '0px',
'--ListItem-paddingX': 'var(--Tabs-spacing)',
'--ListItem-gap': '0.375rem',
// the `var(--unknown,)` is a workaround because emotion does not support space toggle.
'--unstable_TabList-hasUnderline': ownerState.disableUnderline ? 'var(--unknown,)' : 'initial',
...scopedVariables,
Expand Down