signal-desktop/ts/components/Spinner.stories.tsx
2022-11-17 16:45:19 -08:00

60 lines
1.3 KiB
TypeScript

// Copyright 2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { select, text } from '@storybook/addon-knobs';
import type { Props } from './Spinner';
import { Spinner, SpinnerDirections, SpinnerSvgSizes } from './Spinner';
export default {
title: 'Components/Spinner',
};
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
),
});
export function Normal(): JSX.Element {
const props = createProps();
return <Spinner {...props} />;
}
export function SvgSizes(): JSX.Element {
const props = createProps();
return (
<>
{SpinnerSvgSizes.map(svgSize => (
<Spinner key={svgSize} {...props} svgSize={svgSize} />
))}
</>
);
}
SvgSizes.story = {
name: 'SVG Sizes',
};
export function Directions(): JSX.Element {
const props = createProps();
return (
<>
{SpinnerDirections.map(direction => (
<Spinner key={direction} {...props} direction={direction} />
))}
</>
);
}