mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
chore: make the User Avatar size configurable (#7332)
This change makes the width of the user avatar configurable via a new "avatarWidth" property. It also sets the width to be `theme.spacing(3)` (currently 24px) for the feature flag table. It looks like this now:  It used to look like this: 
This commit is contained in:
parent
08713c918c
commit
df3ca10a6d
@ -9,15 +9,21 @@ import type { IUser } from 'interfaces/user';
|
|||||||
import type { FC } from 'react';
|
import type { FC } from 'react';
|
||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||||
|
|
||||||
const StyledAvatar = styled(Avatar)(({ theme }) => ({
|
const StyledAvatar = styled(Avatar, {
|
||||||
width: theme.spacing(3.5),
|
shouldForwardProp: (prop) => prop !== 'avatarWidth',
|
||||||
height: theme.spacing(3.5),
|
})<{ avatarWidth?: (theme: Theme) => string }>(({ theme, avatarWidth }) => {
|
||||||
|
const width = avatarWidth ? avatarWidth(theme) : theme.spacing(3.5);
|
||||||
|
|
||||||
|
return {
|
||||||
|
width,
|
||||||
|
height: width,
|
||||||
margin: 'auto',
|
margin: 'auto',
|
||||||
backgroundColor: theme.palette.secondary.light,
|
backgroundColor: theme.palette.secondary.light,
|
||||||
color: theme.palette.text.primary,
|
color: theme.palette.text.primary,
|
||||||
fontSize: theme.fontSizes.smallerBody,
|
fontSize: theme.fontSizes.smallerBody,
|
||||||
fontWeight: theme.fontWeight.bold,
|
fontWeight: theme.fontWeight.bold,
|
||||||
}));
|
};
|
||||||
|
});
|
||||||
|
|
||||||
interface IUserAvatarProps extends AvatarProps {
|
interface IUserAvatarProps extends AvatarProps {
|
||||||
user?: Partial<
|
user?: Partial<
|
||||||
@ -29,6 +35,7 @@ interface IUserAvatarProps extends AvatarProps {
|
|||||||
onMouseLeave?: () => void;
|
onMouseLeave?: () => void;
|
||||||
className?: string;
|
className?: string;
|
||||||
sx?: SxProps<Theme>;
|
sx?: SxProps<Theme>;
|
||||||
|
avatarWidth?: (theme: Theme) => string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UserAvatar: FC<IUserAvatarProps> = ({
|
export const UserAvatar: FC<IUserAvatarProps> = ({
|
||||||
|
@ -182,6 +182,7 @@ export const ProjectFeatureToggles = ({
|
|||||||
name: original.createdBy.name,
|
name: original.createdBy.name,
|
||||||
imageUrl: original.createdBy.imageUrl,
|
imageUrl: original.createdBy.imageUrl,
|
||||||
}}
|
}}
|
||||||
|
avatarWidth={(theme) => theme.spacing(3)}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user