forked from voiceflow/react-chat
-
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.
feat: add component documentation (DX-447) (voiceflow#49)
- Loading branch information
1 parent
74c939b
commit 1774e8c
Showing
59 changed files
with
689 additions
and
117 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
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
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
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
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
14 changes: 12 additions & 2 deletions
14
packages/react-chat/src/components/Avatar/Avatar.story.tsx
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 |
---|---|---|
@@ -1,22 +1,32 @@ | ||
import { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
||
import { VF_ICON } from '@/fixtures'; | ||
|
||
import Avatar from '.'; | ||
|
||
export default { | ||
title: 'Core/Avatar', | ||
component: Avatar, | ||
argTypes: { | ||
size: { | ||
options: ['small', 'large'], | ||
control: { type: 'radio' }, | ||
defaultValue: 'small', | ||
}, | ||
}, | ||
args: { | ||
avatar: VF_ICON, | ||
}, | ||
} as ComponentMeta<typeof Avatar>; | ||
|
||
const Template: ComponentStory<typeof Avatar> = (args) => <Avatar {...args} />; | ||
|
||
export const Small = Template.bind({}); | ||
Small.args = { | ||
size: 'small', | ||
image: 'https://source.unsplash.com/random/26x26', | ||
}; | ||
|
||
export const Large = Template.bind({}); | ||
Large.args = { | ||
size: 'large', | ||
image: 'https://source.unsplash.com/random/72x72', | ||
}; |
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 |
---|---|---|
@@ -1,13 +1,30 @@ | ||
import { VariantProp } from '@/types'; | ||
|
||
import { AvatarContainer } from './styled'; | ||
|
||
export interface AvatarProps extends React.ComponentProps<typeof AvatarContainer> { | ||
/** | ||
* An image URL which will be rendered as the background. | ||
*/ | ||
avatar: string; | ||
|
||
/** | ||
* Pre-defined size variants. | ||
* | ||
* @default 'small' | ||
*/ | ||
size?: VariantProp<typeof AvatarContainer, 'size'>; | ||
} | ||
|
||
const Avatar: React.FC<AvatarProps> = ({ avatar, ...props }) => ( | ||
<AvatarContainer {...props} css={{ backgroundImage: `url(${avatar})`, ...props.css }} /> | ||
); | ||
|
||
/** | ||
* Displays an image in a circular frame. | ||
* | ||
* @see {@link https://voiceflow.github.io/react-chat/?path=/story/core-avatar--small} | ||
*/ | ||
export default Object.assign(Avatar, { | ||
Container: AvatarContainer, | ||
}); |
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
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
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
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
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
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
Oops, something went wrong.