Design system.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 lines
914 B

  1. import * as React from 'react';
  2. import type { Meta } from '@storybook/react';
  3. import { ToggleSwitch as Component, ToggleSwitchProps as Props } from '.';
  4. const LENGTH = 3 as const;
  5. const meta: Meta<typeof Component> = {
  6. component: Component,
  7. argTypes: {
  8. checkedLabel: {
  9. control: {
  10. type: 'text',
  11. },
  12. },
  13. subtext: {
  14. control: {
  15. type: 'text',
  16. },
  17. },
  18. uncheckedLabel: {
  19. control: {
  20. type: 'text',
  21. },
  22. },
  23. onChange: {
  24. table: {
  25. disable: true,
  26. },
  27. action: 'changed',
  28. },
  29. },
  30. args: {
  31. ...(Component.defaultProps ?? {}),
  32. checkedLabel: Component.displayName,
  33. },
  34. };
  35. export const ToggleSwitch = (args: Omit<Props, 'ref'>) => (
  36. <>
  37. {Array.from({ length: LENGTH }).map((_, i) => (
  38. <Component
  39. {...args}
  40. key={i}
  41. name={Component.displayName}
  42. value={i + 1}
  43. checkedLabel={`${Component.displayName} ${i + 1}`}
  44. />
  45. ))}
  46. </>
  47. );
  48. export default meta;