mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-10 23:45:44 +01:00
use reflow to migrate from flow to typescript
This commit is contained in:
74
scm-ui/ui-components/src/buttons/index.stories.tsx
Normal file
74
scm-ui/ui-components/src/buttons/index.stories.tsx
Normal file
@@ -0,0 +1,74 @@
|
||||
import React, { ReactNode } from 'react';
|
||||
import Button from './Button';
|
||||
import { storiesOf } from '@storybook/react';
|
||||
import styled from 'styled-components';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import AddButton from './AddButton';
|
||||
import CreateButton from './CreateButton';
|
||||
import DeleteButton from './DeleteButton';
|
||||
import DownloadButton from './DownloadButton';
|
||||
import EditButton from './EditButton';
|
||||
import SubmitButton from './SubmitButton';
|
||||
|
||||
const colors = [
|
||||
'primary',
|
||||
'link',
|
||||
'info',
|
||||
'success',
|
||||
'warning',
|
||||
'danger',
|
||||
'white',
|
||||
'light',
|
||||
'dark',
|
||||
'black',
|
||||
'text',
|
||||
];
|
||||
|
||||
const Spacing = styled.div`
|
||||
padding: 1em;
|
||||
`;
|
||||
|
||||
const RoutingDecorator = story => (
|
||||
<MemoryRouter initialEntries={['/']}>{story()}</MemoryRouter>
|
||||
);
|
||||
|
||||
const SpacingDecorator = story => <Spacing>{story()}</Spacing>;
|
||||
|
||||
storiesOf('Buttons|Button', module)
|
||||
.addDecorator(RoutingDecorator)
|
||||
.add('Colors', () => (
|
||||
<div>
|
||||
{colors.map(color => (
|
||||
<Spacing key={color}>
|
||||
<Button color={color} label={color} />
|
||||
</Spacing>
|
||||
))}
|
||||
</div>
|
||||
))
|
||||
.add('Loading', () => (
|
||||
<Spacing>
|
||||
<Button color={'primary'} loading={true}>
|
||||
Loading Button
|
||||
</Button>
|
||||
</Spacing>
|
||||
));
|
||||
|
||||
const buttonStory = (name: string, storyFn: () => ReactNode) => {
|
||||
return storiesOf('Buttons|' + name, module)
|
||||
.addDecorator(RoutingDecorator)
|
||||
.addDecorator(SpacingDecorator)
|
||||
.add('Default', storyFn);
|
||||
};
|
||||
|
||||
buttonStory('AddButton', () => <AddButton color={'primary'}>Add</AddButton>);
|
||||
buttonStory('CreateButton', () => <CreateButton>Create</CreateButton>);
|
||||
buttonStory('DeleteButton', () => <DeleteButton>Delete</DeleteButton>);
|
||||
buttonStory('DownloadButton', () => (
|
||||
<DownloadButton
|
||||
displayName="Download"
|
||||
disabled={false}
|
||||
url=""
|
||||
></DownloadButton>
|
||||
));
|
||||
buttonStory('EditButton', () => <EditButton>Edit</EditButton>);
|
||||
buttonStory('SubmitButton', () => <SubmitButton>Submit</SubmitButton>);
|
||||
Reference in New Issue
Block a user