Design system.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

59 行
1.1 KiB

  1. import * as React from 'react';
  2. import type { Meta } from '@storybook/react';
  3. import { Slider as Component, SliderProps as Props, AVAILABLE_SLIDER_ORIENTATIONS } from '.';
  4. const meta: Meta<typeof Component> = {
  5. component: Component,
  6. argTypes: {
  7. orient: {
  8. control: {
  9. type: 'select',
  10. },
  11. options: AVAILABLE_SLIDER_ORIENTATIONS,
  12. },
  13. max: {
  14. control: { type: 'number' },
  15. },
  16. min: {
  17. control: { type: 'number' },
  18. },
  19. length: {
  20. control: { type: 'number' },
  21. },
  22. children: {
  23. control: { type: 'text' },
  24. },
  25. onChange: {
  26. table: {
  27. disable: true,
  28. },
  29. action: 'changed',
  30. },
  31. },
  32. args: {
  33. ...(Component.defaultProps ?? {}),
  34. max: 100,
  35. min: 0,
  36. },
  37. };
  38. export const Slider = ({children, ...args}: Omit<Props, 'ref'>) => (
  39. <Component
  40. {...args}
  41. >
  42. {(children ? children.toString() : '').split('\n').filter(s => s.length > 0).map((s, i) => {
  43. const [label, value = label] = s.split(':').map(s => s.trim()) as string[];
  44. return (
  45. <option
  46. key={`${s}:${i}`}
  47. value={value}
  48. >
  49. {label}
  50. </option>
  51. );
  52. })}
  53. </Component>
  54. );
  55. export default meta;