multipleCheckbox.stories.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {useState} from 'react';
  2. import {action} from '@storybook/addon-actions';
  3. import MultipleCheckbox from 'sentry/components/forms/controls/multipleCheckbox';
  4. export default {
  5. title: 'Components/Forms/Controls/Multiple Checkbox',
  6. component: MultipleCheckbox,
  7. args: {
  8. disabled: false,
  9. name: 'multiple-checkbox-example',
  10. },
  11. };
  12. export const _MultipleCheckbox = ({...args}) => {
  13. const [value, setValue] = useState(['bar']);
  14. return (
  15. <MultipleCheckbox
  16. value={value}
  17. onChange={(newValue, e) => {
  18. setValue(newValue);
  19. action('MultipleCheckbox change')(newValue, e);
  20. }}
  21. {...args}
  22. >
  23. <MultipleCheckbox.Item value="foo">Foo</MultipleCheckbox.Item>
  24. <MultipleCheckbox.Item value="bar">Bar</MultipleCheckbox.Item>
  25. <MultipleCheckbox.Item value="baz">Baz</MultipleCheckbox.Item>
  26. <MultipleCheckbox.Item value="quux">Quux</MultipleCheckbox.Item>
  27. </MultipleCheckbox>
  28. );
  29. };
  30. _MultipleCheckbox.storyName = 'Multiple Checkbox';
  31. _MultipleCheckbox.parameters = {
  32. docs: {
  33. description: {
  34. story: 'Multiple Checkbox Control (controlled only atm)',
  35. },
  36. },
  37. };