Skip to content

Commit

Permalink
docs(avatar): add avatar stories
Browse files Browse the repository at this point in the history
  • Loading branch information
estevanmaito committed Nov 8, 2020
1 parent adb7bb8 commit 22e0de8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
5 changes: 5 additions & 0 deletions @types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ declare module '*.svg' {
export default content
}

declare module '*.jpg' {
const content: any
export default content
}

declare type ListenerMap = {
[k: string]: any
}
4 changes: 2 additions & 2 deletions src/Avatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useContext } from 'react'
import classNames from 'classnames'
import { ThemeContext } from './context/ThemeContext'

interface Props extends React.HTMLAttributes<HTMLDivElement> {
export interface AvatarProps extends React.HTMLAttributes<HTMLDivElement> {
/**
* The size of the avatar
*/
Expand All @@ -17,7 +17,7 @@ interface Props extends React.HTMLAttributes<HTMLDivElement> {
src: string
}

const Avatar = React.forwardRef<HTMLDivElement, Props>(function Avatar(props, ref) {
const Avatar = React.forwardRef<HTMLDivElement, AvatarProps>(function Avatar(props, ref) {
const { size = 'regular', src, alt, className, ...other } = props
const {
theme: { avatar },
Expand Down
34 changes: 34 additions & 0 deletions src/stories/Avatar.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'

import { Story, Meta } from '@storybook/react/types-6-0'

import Avatar, { AvatarProps } from '../Avatar'

import avatarImage from './static/avatar-1.jpg'

export default {
title: 'Avatar',
component: Avatar,
} as Meta

const Template: Story<AvatarProps> = (args) => <Avatar {...args} />

export const Large = Template.bind({})
Large.args = {
size: 'large',
src: avatarImage,
alt: 'Profile image',
}

export const Regular = Template.bind({})
Regular.args = {
src: avatarImage,
alt: 'Profile image',
}

export const Small = Template.bind({})
Small.args = {
size: 'small',
src: avatarImage,
alt: 'Profile image',
}
Binary file added src/stories/static/avatar-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 22e0de8

Please sign in to comment.