-
Notifications
You must be signed in to change notification settings - Fork 615
Refactor Avatar to use Box #2019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
204af41
07cc791
0d8aee4
e41e849
4fdc495
f1fcc62
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import Avatar from '../Avatar' | ||
import {Meta} from '@storybook/react' | ||
import React from 'react' | ||
import {ThemeProvider} from '..' | ||
import BaseStyles from '../BaseStyles' | ||
|
||
const meta: Meta = { | ||
title: 'Building blocks/Avatar/fixtures', | ||
component: Avatar, | ||
decorators: [ | ||
(Story: React.ComponentType): JSX.Element => ( | ||
<ThemeProvider> | ||
<BaseStyles> | ||
<Story /> | ||
</BaseStyles> | ||
</ThemeProvider> | ||
) | ||
] | ||
} | ||
export default meta | ||
|
||
export function SimpleAvatar(): JSX.Element { | ||
return <Avatar alt="Primer logo" src="https://avatars.githubusercontent.com/primer" /> | ||
} | ||
|
||
export function CustomSize(): JSX.Element { | ||
return <Avatar size={48} alt="Primer logo" src="https://avatars.githubusercontent.com/primer" /> | ||
} | ||
|
||
export function SquareAvatar(): JSX.Element { | ||
return <Avatar square alt="Primer logo" src="https://avatars.githubusercontent.com/primer" /> | ||
} | ||
Comment on lines
+26
to
+32
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These could just be Storybook controls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True! I'm creating extra stories so that they can be part of our visual regression testing suite :) Should I also add a story with all the controls? (.langermank calls it the playground story in primer-css) |
||
|
||
export function DefaultAltText(): JSX.Element { | ||
return <Avatar src="https://avatars.githubusercontent.com/primer" /> | ||
} | ||
|
||
export function AcceptsRef(): JSX.Element { | ||
const ref = React.useRef<HTMLImageElement>(null) | ||
|
||
return <Avatar ref={ref} src="https://avatars.githubusercontent.com/primer" data-test-id="avatar" /> | ||
} | ||
|
||
export function AcceptsSxProp(): JSX.Element { | ||
return ( | ||
<> | ||
<Avatar sx={{marginRight: 4}} src="https://avatars.githubusercontent.com/primer" /> | ||
<span>text pushed to right because avatar has margin</span> | ||
</> | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use
ComponentPropsWithoutRef
here