mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +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 }) => { | ||||||
|     margin: 'auto', |     const width = avatarWidth ? avatarWidth(theme) : theme.spacing(3.5); | ||||||
|     backgroundColor: theme.palette.secondary.light, | 
 | ||||||
|     color: theme.palette.text.primary, |     return { | ||||||
|     fontSize: theme.fontSizes.smallerBody, |         width, | ||||||
|     fontWeight: theme.fontWeight.bold, |         height: width, | ||||||
| })); |         margin: 'auto', | ||||||
|  |         backgroundColor: theme.palette.secondary.light, | ||||||
|  |         color: theme.palette.text.primary, | ||||||
|  |         fontSize: theme.fontSizes.smallerBody, | ||||||
|  |         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