mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Use Component Story Format for stories (#8108)
The recommended way of writing stories changed in Storybook v5.2 to the Component Story Format (CSF). Instead of using `storiesOf` and running everything upon module import, the new story format is a declarative description of each component that uses ES6 import semantics.
This commit is contained in:
parent
cb995d66da
commit
7a9f53c99d
@ -1,12 +1,14 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { storiesOf } from '@storybook/react'
|
|
||||||
import { action } from '@storybook/addon-actions'
|
import { action } from '@storybook/addon-actions'
|
||||||
import ButtonGroup from '.'
|
import ButtonGroup from '.'
|
||||||
import Button from '../button'
|
import Button from '../button'
|
||||||
import { text, boolean } from '@storybook/addon-knobs/react'
|
import { text, boolean } from '@storybook/addon-knobs/react'
|
||||||
|
|
||||||
storiesOf('ButtonGroup', module)
|
export default {
|
||||||
.add('with Buttons', () => (
|
title: 'ButtonGroup',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const withButtons = () => (
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
style={{ width: '300px' }}
|
style={{ width: '300px' }}
|
||||||
disabled={boolean('Disabled', false)}
|
disabled={boolean('Disabled', false)}
|
||||||
@ -28,8 +30,9 @@ storiesOf('ButtonGroup', module)
|
|||||||
{text('Button3', 'Fast')}
|
{text('Button3', 'Fast')}
|
||||||
</Button>
|
</Button>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
))
|
)
|
||||||
.add('with a disabled Button', () => (
|
|
||||||
|
export const withDisabledButton = () => (
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
style={{ width: '300px' }}
|
style={{ width: '300px' }}
|
||||||
disabled={boolean('Disabled', false)}
|
disabled={boolean('Disabled', false)}
|
||||||
@ -46,4 +49,4 @@ storiesOf('ButtonGroup', module)
|
|||||||
{text('Button2', 'Disabled')}
|
{text('Button2', 'Disabled')}
|
||||||
</Button>
|
</Button>
|
||||||
</ButtonGroup>
|
</ButtonGroup>
|
||||||
))
|
)
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { storiesOf } from '@storybook/react'
|
|
||||||
import { action } from '@storybook/addon-actions'
|
import { action } from '@storybook/addon-actions'
|
||||||
import Button from '.'
|
import Button from '.'
|
||||||
import { text, boolean } from '@storybook/addon-knobs/react'
|
import { text, boolean } from '@storybook/addon-knobs/react'
|
||||||
|
|
||||||
// ', 'secondary', 'default', 'warning', 'danger', 'danger-primary', 'link'], 'primary')}
|
export default {
|
||||||
storiesOf('Button', module)
|
title: 'Button',
|
||||||
.add('Button - Primary', () => (
|
}
|
||||||
|
|
||||||
|
export const primaryType = () => (
|
||||||
<Button
|
<Button
|
||||||
onClick={action('clicked')}
|
onClick={action('clicked')}
|
||||||
type="primary"
|
type="primary"
|
||||||
@ -14,8 +15,9 @@ storiesOf('Button', module)
|
|||||||
>
|
>
|
||||||
{text('text', 'Click me')}
|
{text('text', 'Click me')}
|
||||||
</Button>
|
</Button>
|
||||||
))
|
)
|
||||||
.add('Button - Secondary', () => (
|
|
||||||
|
export const secondaryType = () => (
|
||||||
<Button
|
<Button
|
||||||
onClick={action('clicked')}
|
onClick={action('clicked')}
|
||||||
type="secondary"
|
type="secondary"
|
||||||
@ -23,8 +25,9 @@ storiesOf('Button', module)
|
|||||||
>
|
>
|
||||||
{text('text', 'Click me')}
|
{text('text', 'Click me')}
|
||||||
</Button>
|
</Button>
|
||||||
))
|
)
|
||||||
.add('Button - Default', () => (
|
|
||||||
|
export const defaultType = () => (
|
||||||
<Button
|
<Button
|
||||||
onClick={action('clicked')}
|
onClick={action('clicked')}
|
||||||
type="default"
|
type="default"
|
||||||
@ -32,8 +35,9 @@ storiesOf('Button', module)
|
|||||||
>
|
>
|
||||||
{text('text', 'Click me')}
|
{text('text', 'Click me')}
|
||||||
</Button>
|
</Button>
|
||||||
))
|
)
|
||||||
.add('Button - Warning', () => (
|
|
||||||
|
export const warningType = () => (
|
||||||
<Button
|
<Button
|
||||||
onClick={action('clicked')}
|
onClick={action('clicked')}
|
||||||
type="warning"
|
type="warning"
|
||||||
@ -41,8 +45,9 @@ storiesOf('Button', module)
|
|||||||
>
|
>
|
||||||
{text('text', 'Click me')}
|
{text('text', 'Click me')}
|
||||||
</Button>
|
</Button>
|
||||||
))
|
)
|
||||||
.add('Button - Danger', () => (
|
|
||||||
|
export const dangerType = () => (
|
||||||
<Button
|
<Button
|
||||||
onClick={action('clicked')}
|
onClick={action('clicked')}
|
||||||
type="danger"
|
type="danger"
|
||||||
@ -50,8 +55,9 @@ storiesOf('Button', module)
|
|||||||
>
|
>
|
||||||
{text('text', 'Click me')}
|
{text('text', 'Click me')}
|
||||||
</Button>
|
</Button>
|
||||||
))
|
)
|
||||||
.add('Button - Danger Primary', () => (
|
|
||||||
|
export const dangerPrimaryType = () => (
|
||||||
<Button
|
<Button
|
||||||
onClick={action('clicked')}
|
onClick={action('clicked')}
|
||||||
type="danger-primary"
|
type="danger-primary"
|
||||||
@ -59,8 +65,9 @@ storiesOf('Button', module)
|
|||||||
>
|
>
|
||||||
{text('text', 'Click me')}
|
{text('text', 'Click me')}
|
||||||
</Button>
|
</Button>
|
||||||
))
|
)
|
||||||
.add('Button - Link', () => (
|
|
||||||
|
export const linkType = () => (
|
||||||
<Button
|
<Button
|
||||||
onClick={action('clicked')}
|
onClick={action('clicked')}
|
||||||
type="link"
|
type="link"
|
||||||
@ -68,4 +75,4 @@ storiesOf('Button', module)
|
|||||||
>
|
>
|
||||||
{text('text', 'Click me')}
|
{text('text', 'Click me')}
|
||||||
</Button>
|
</Button>
|
||||||
))
|
)
|
||||||
|
@ -1,53 +1,61 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { storiesOf } from '@storybook/react'
|
|
||||||
import TextField from '.'
|
import TextField from '.'
|
||||||
|
|
||||||
storiesOf('TextField', module)
|
export default {
|
||||||
.add('text', () => (
|
title: 'TextField',
|
||||||
|
}
|
||||||
|
|
||||||
|
export const text = () => (
|
||||||
<TextField
|
<TextField
|
||||||
label="Text"
|
label="Text"
|
||||||
type="text"
|
type="text"
|
||||||
/>
|
/>
|
||||||
))
|
)
|
||||||
.add('password', () => (
|
|
||||||
|
export const password = () => (
|
||||||
<TextField
|
<TextField
|
||||||
label="Password"
|
label="Password"
|
||||||
type="password"
|
type="password"
|
||||||
/>
|
/>
|
||||||
))
|
)
|
||||||
.add('error', () => (
|
|
||||||
|
export const error = () => (
|
||||||
<TextField
|
<TextField
|
||||||
type="text"
|
type="text"
|
||||||
label="Name"
|
label="Name"
|
||||||
error="Invalid value"
|
error="Invalid value"
|
||||||
/>
|
/>
|
||||||
))
|
)
|
||||||
.add('Mascara text', () => (
|
|
||||||
|
export const mascaraText = () => (
|
||||||
<TextField
|
<TextField
|
||||||
label="Text"
|
label="Text"
|
||||||
type="text"
|
type="text"
|
||||||
largeLabel
|
largeLabel
|
||||||
/>
|
/>
|
||||||
))
|
)
|
||||||
.add('Material text', () => (
|
|
||||||
|
export const materialText = () => (
|
||||||
<TextField
|
<TextField
|
||||||
label="Text"
|
label="Text"
|
||||||
type="text"
|
type="text"
|
||||||
theme="material"
|
theme="material"
|
||||||
/>
|
/>
|
||||||
))
|
)
|
||||||
.add('Material password', () => (
|
|
||||||
|
export const materialPassword = () => (
|
||||||
<TextField
|
<TextField
|
||||||
label="Password"
|
label="Password"
|
||||||
type="password"
|
type="password"
|
||||||
theme="material"
|
theme="material"
|
||||||
/>
|
/>
|
||||||
))
|
)
|
||||||
.add('Material error', () => (
|
|
||||||
|
export const materialError = () => (
|
||||||
<TextField
|
<TextField
|
||||||
type="text"
|
type="text"
|
||||||
label="Name"
|
label="Name"
|
||||||
error="Invalid value"
|
error="Invalid value"
|
||||||
theme="material"
|
theme="material"
|
||||||
/>
|
/>
|
||||||
))
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user