Design system.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

70 řádky
1.3 KiB

  1. import * as React from 'react';
  2. import type {Meta} from '@storybook/react';
  3. import {TextControl} from '@tesseract-design/web-base';
  4. import {MenuSelect as Component, MenuSelectProps as Props} from '.';
  5. const meta: Meta<typeof Component> = {
  6. component: Component,
  7. argTypes: {
  8. label: {
  9. control: { type: 'text' },
  10. },
  11. hint: {
  12. control: { type: 'text' },
  13. },
  14. variant: {
  15. control: {
  16. type: 'select',
  17. },
  18. options: TextControl.AVAILABLE_VARIANTS,
  19. },
  20. size: {
  21. control: {
  22. type: 'select',
  23. },
  24. options: TextControl.AVAILABLE_SIZES,
  25. },
  26. indicator: {
  27. control: { type: 'text' },
  28. },
  29. children: {
  30. control: { type: 'text' },
  31. },
  32. onChange: {
  33. table: {
  34. disable: true,
  35. },
  36. action: 'changed',
  37. },
  38. },
  39. args: {
  40. ...(Component.defaultProps ?? {}),
  41. label: Component.displayName,
  42. children: `Chocolate
  43. Vanilla
  44. Mango
  45. Strawberry
  46. `,
  47. },
  48. };
  49. export const MenuSelect = ({ children = '', ...args }: Omit<Props, 'ref'>) => (
  50. <Component
  51. {...args}
  52. >
  53. {(children ? children.toString() : '').split('\n').filter(s => s.length > 0).map((s, i) => {
  54. const [label, value = label] = s.split(':').map(s => s.trim()) as string[];
  55. return (
  56. <option
  57. key={`${s}:${i}`}
  58. value={value}
  59. >
  60. {label}
  61. </option>
  62. );
  63. })}
  64. </Component>
  65. );
  66. export default meta;