Fix identicon component for new Storybook format (#12888)
* identicon * Upating identicon story and withBorder prop to work dynamically Co-authored-by: georgewrmarshall <george.marshall@consensys.net>feature/default_network_editable
parent
51fa7734fd
commit
61935835a0
@ -0,0 +1,37 @@ |
||||
import { Story, Canvas, ArgsTable } from '@storybook/addon-docs'; |
||||
|
||||
import Identicon from './identicon.component'; |
||||
|
||||
# Identicon |
||||
|
||||
An identifier component that can be supplied an image or randomly generates one based on the account address. |
||||
|
||||
<Canvas> |
||||
<Story id="ui-components-ui-identicon-identicon-stories-js--default-story" /> |
||||
</Canvas> |
||||
|
||||
## Component API |
||||
|
||||
<ArgsTable of={Identicon} /> |
||||
|
||||
## Usage |
||||
|
||||
### With Image |
||||
|
||||
Use with custom image |
||||
|
||||
<Canvas> |
||||
<Story id="ui-components-ui-identicon-identicon-stories-js--with-image" /> |
||||
</Canvas> |
||||
|
||||
### With Blockie |
||||
|
||||
<Canvas> |
||||
<Story id="ui-components-ui-identicon-identicon-stories-js--with-blockie" /> |
||||
</Canvas> |
||||
|
||||
### With Border |
||||
|
||||
<Canvas> |
||||
<Story id="ui-components-ui-identicon-identicon-stories-js--with-border" /> |
||||
</Canvas> |
@ -1,49 +1,62 @@ |
||||
import React from 'react'; |
||||
import { text, boolean, number } from '@storybook/addon-knobs'; |
||||
import README from './README.mdx'; |
||||
import Identicon from './identicon.component'; |
||||
|
||||
export default { |
||||
title: 'Components/UI/Identicon', |
||||
id: __filename, |
||||
component: Identicon, |
||||
parameters: { |
||||
docs: { |
||||
page: README, |
||||
}, |
||||
}, |
||||
argTypes: { |
||||
addBorder: { control: 'boolean' }, |
||||
address: { control: 'text' }, |
||||
className: { control: 'text' }, |
||||
diameter: { control: 'number' }, |
||||
image: { control: 'text' }, |
||||
useBlockie: { control: 'boolean' }, |
||||
alt: { control: 'text' }, |
||||
imageBorder: { control: 'boolean' }, |
||||
useTokenDetection: { control: 'boolean' }, |
||||
tokenList: { control: 'object' }, |
||||
}, |
||||
}; |
||||
|
||||
const diameterOptions = { |
||||
range: true, |
||||
min: 10, |
||||
max: 200, |
||||
step: 1, |
||||
}; |
||||
export const DefaultStory = () => ( |
||||
<Identicon |
||||
addBorder={boolean('Add Border', Identicon.defaultProps.addBorder)} |
||||
address={text('Address', '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1')} |
||||
diameter={number( |
||||
'Diameter', |
||||
Identicon.defaultProps.diameter, |
||||
diameterOptions, |
||||
)} |
||||
useBlockie={boolean('Use Blockie', Identicon.defaultProps.useBlockie)} |
||||
/> |
||||
); |
||||
export const DefaultStory = (args) => <Identicon {...args} />; |
||||
|
||||
DefaultStory.storyName = 'Default'; |
||||
DefaultStory.args = { |
||||
addBorder: false, |
||||
address: '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1', |
||||
diameter: 32, |
||||
useBlockie: false, |
||||
}; |
||||
|
||||
export const Image = () => <Identicon image="./images/eth_logo.svg" />; |
||||
|
||||
export const Blockie = () => ( |
||||
<Identicon |
||||
address={text('Address', '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1')} |
||||
useBlockie={boolean('Use Blockie', true)} |
||||
/> |
||||
); |
||||
export const WithImage = (args) => <Identicon {...args} />; |
||||
WithImage.args = { |
||||
addBorder: false, |
||||
diameter: 32, |
||||
useBlockie: false, |
||||
image: './images/eth_logo.svg', |
||||
alt: 'Ethereum', |
||||
imageBorder: true, |
||||
}; |
||||
|
||||
// The border size is hard-coded in CSS, and was designed with this size identicon in mind
|
||||
const withBorderDiameter = 32; |
||||
export const WithBlockie = (args) => <Identicon {...args} />; |
||||
WithBlockie.args = { |
||||
addBorder: false, |
||||
address: '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1', |
||||
diameter: 32, |
||||
useBlockie: true, |
||||
}; |
||||
|
||||
export const WithBorder = () => ( |
||||
<Identicon |
||||
addBorder={boolean('Add Border', true)} |
||||
address={text('Address', '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1')} |
||||
diameter={number('Diameter', withBorderDiameter, diameterOptions)} |
||||
/> |
||||
); |
||||
export const WithBorder = (args) => <Identicon {...args} />; |
||||
WithBorder.args = { |
||||
addBorder: true, |
||||
address: '0x5CfE73b6021E818B776b421B1c4Db2474086a7e1', |
||||
diameter: 32, |
||||
useBlockie: false, |
||||
}; |
||||
|
Loading…
Reference in new issue