signal-desktop/ts/components/Spinner.stories.tsx

47 lines
1.2 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2020-08-21 22:04:19 +00:00
import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { select, text } from '@storybook/addon-knobs';
2020-09-12 00:46:52 +00:00
import { Props, Spinner, SpinnerDirections, SpinnerSvgSizes } from './Spinner';
2020-08-21 22:04:19 +00:00
const story = storiesOf('Components/Spinner', module);
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
size: text('size', overrideProps.size || ''),
svgSize: select(
'svgSize',
SpinnerSvgSizes.reduce((m, s) => ({ ...m, [s]: s }), {}),
overrideProps.svgSize || 'normal'
),
direction: select(
'direction',
SpinnerDirections.reduce((d, s) => ({ ...d, [s]: s }), {}),
overrideProps.direction
),
});
story.add('Normal', () => {
const props = createProps();
return <Spinner {...props} />;
});
story.add('SVG Sizes', () => {
const props = createProps();
return SpinnerSvgSizes.map(svgSize => (
<Spinner key={svgSize} {...props} svgSize={svgSize} />
));
});
story.add('Directions', () => {
const props = createProps();
return SpinnerDirections.map(direction => (
<Spinner key={direction} {...props} direction={direction} />
));
});