select.stories.tsx 734 B

1234567891011121314151617181920212223242526272829303132333435
  1. import { Select } from '../js/shared/components/select'
  2. const items = [1, 2, 3, 4].map(index => ({
  3. key: index,
  4. value: `Demo item ${index}`,
  5. group: index >= 3 ? 'Large numbers' : undefined,
  6. }))
  7. export const Base = () => {
  8. return (
  9. <Select
  10. items={items}
  11. itemToString={x => String(x?.value)}
  12. itemToKey={x => String(x.key)}
  13. defaultText="Choose an item"
  14. />
  15. )
  16. }
  17. export const WithSubtitles = () => {
  18. return (
  19. <Select
  20. items={items}
  21. itemToString={x => String(x?.value)}
  22. itemToKey={x => String(x.key)}
  23. itemToSubtitle={x => x?.group ?? ''}
  24. defaultText="Choose an item"
  25. />
  26. )
  27. }
  28. export default {
  29. title: 'Shared / Components / Select',
  30. component: Select,
  31. }