-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
53b0c67
commit b80b629
Showing
3 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { StoryObj, Meta } from '@storybook/react'; | ||
import { Avatar, AvatarProps } from '@ignite-ui/react'; | ||
|
||
export default { | ||
title: 'Data display/Avatar', | ||
component: Avatar, | ||
} as Meta<AvatarProps>; | ||
|
||
export const Primary: StoryObj<AvatarProps> = { | ||
args: { | ||
src: 'https://github.com/brenocastelo.png', | ||
alt: 'Breno Castelo Branco', | ||
}, | ||
}; | ||
|
||
export const WithFallback: StoryObj<AvatarProps> = { | ||
args: { | ||
src: undefined, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { User } from 'phosphor-react'; | ||
import { ComponentProps } from 'react'; | ||
import { AvatarContainer, AvatarFallback, AvatarImage } from './styles'; | ||
|
||
export function Avatar(props: AvatarProps) { | ||
return ( | ||
<AvatarContainer> | ||
<AvatarImage {...props} /> | ||
|
||
<AvatarFallback delayMs={600}> | ||
<User /> | ||
</AvatarFallback> | ||
</AvatarContainer> | ||
); | ||
} | ||
|
||
export interface AvatarProps extends ComponentProps<typeof AvatarImage> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as Avatar from '@radix-ui/react-avatar'; | ||
|
||
import { styled } from '../../styles'; | ||
|
||
export const AvatarContainer = styled(Avatar.Root, { | ||
borderRadius: '$full', | ||
display: 'inline-block', | ||
height: '$12', | ||
width: '$12', | ||
overflow: 'hidden', | ||
}); | ||
|
||
export const AvatarImage = styled(Avatar.Image, { | ||
width: '100%', | ||
heigh: '100%', | ||
objectFit: 'cover', | ||
borderRadius: 'inherit', | ||
}); | ||
|
||
export const AvatarFallback = styled(Avatar.Fallback, { | ||
width: '100%', | ||
height: '100%', | ||
display: 'flex', | ||
justifyContent: 'center', | ||
alignItems: 'center', | ||
backgroundColor: '$gray800', | ||
color: '$gray600', | ||
|
||
svg: { | ||
height: '$6', | ||
width: '$6', | ||
}, | ||
}); |