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

50 lines
1.1 KiB
TypeScript
Raw Normal View History

2021-06-01 20:45:43 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useState } from 'react';
import { action } from '@storybook/addon-actions';
import { Select } from './Select';
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Select',
};
2021-06-01 20:45:43 +00:00
2022-06-07 00:48:02 +00:00
export const Normal = (): JSX.Element => {
2021-06-01 20:45:43 +00:00
const [value, setValue] = useState(0);
const onChange = action('onChange');
return (
<Select
options={[
{ value: 1, text: '1' },
{ value: 2, text: '2' },
{ value: 3, text: '3' },
]}
value={value}
onChange={newValue => {
onChange(newValue);
setValue(parseInt(newValue, 10));
}}
/>
);
2022-06-07 00:48:02 +00:00
};
2021-08-05 12:35:33 +00:00
2022-06-07 00:48:02 +00:00
export const WithDisabledOptions = (): JSX.Element => (
2021-08-05 12:35:33 +00:00
<Select
options={[
{ value: 'a', text: 'Apples' },
{ value: 'b', text: 'Bananas', disabled: true },
{ value: 'c', text: 'Cabbage' },
{ value: 'd', text: 'Durian', disabled: true },
]}
onChange={action('onChange')}
value="c"
/>
2022-06-07 00:48:02 +00:00
);
WithDisabledOptions.story = {
name: 'With disabled options',
};