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

[material-ui][AvatarGroup] Convert to support CSS extraction #41485

Merged
merged 7 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 5 additions & 5 deletions apps/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

49 changes: 26 additions & 23 deletions packages/mui-material/src/AvatarGroup/AvatarGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,11 @@ import { isFragment } from 'react-is';
import clsx from 'clsx';
import chainPropTypes from '@mui/utils/chainPropTypes';
import composeClasses from '@mui/utils/composeClasses';
import styled from '../styles/styled';
import useThemeProps from '../styles/useThemeProps';
import { styled, createUseThemeProps } from '../zero-styled';
import Avatar, { avatarClasses } from '../Avatar';
import avatarGroupClasses, { getAvatarGroupUtilityClass } from './avatarGroupClasses';

const SPACINGS = {
small: -16,
medium: null,
};
const useThemeProps = createUseThemeProps('MuiAlert');

const useUtilityClasses = (ownerState) => {
const { classes } = ownerState;
Expand All @@ -33,25 +29,32 @@ const AvatarGroupRoot = styled('div', {
[`& .${avatarGroupClasses.avatar}`]: styles.avatar,
...styles.root,
}),
})(({ theme, ownerState }) => {
const marginValue =
ownerState.spacing && SPACINGS[ownerState.spacing] !== undefined
? SPACINGS[ownerState.spacing]
: -ownerState.spacing;

return {
[`& .${avatarClasses.root}`]: {
border: `2px solid ${(theme.vars || theme).palette.background.default}`,
boxSizing: 'content-box',
marginLeft: marginValue ?? -8,
'&:last-child': {
marginLeft: 0,
})(({ theme }) => ({
display: 'flex',
flexDirection: 'row-reverse',
[`& .${avatarClasses.root}`]: {
border: `2px solid ${(theme.vars || theme).palette.background.default}`,
boxSizing: 'content-box',
zanivan marked this conversation as resolved.
Show resolved Hide resolved
},
variants: [
zanivan marked this conversation as resolved.
Show resolved Hide resolved
{
zanivan marked this conversation as resolved.
Show resolved Hide resolved
props: { spacing: 'small' },
style: {
[`& .${avatarClasses.root}:not(:last-of-type)`]: {
marginLeft: -16,
},
},
},
display: 'flex',
flexDirection: 'row-reverse',
};
});
{
props: { spacing: 'medium' },
style: {
[`& .${avatarClasses.root}:not(:last-of-type)`]: {
marginLeft: -8,
},
},
},
],
}));

const AvatarGroup = React.forwardRef(function AvatarGroup(inProps, ref) {
const props = useThemeProps({
Expand Down
Loading