StyleGuide.jsx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { h } from 'preact';
  2. import ArrowDropdown from '../icons/ArrowDropdown';
  3. import ArrowDropup from '../icons/ArrowDropup';
  4. import Button from '../components/Button';
  5. import Heading from '../components/Heading';
  6. import Select from '../components/Select';
  7. import Switch from '../components/Switch';
  8. import TextField from '../components/TextField';
  9. import { useCallback, useState } from 'preact/hooks';
  10. export default function StyleGuide() {
  11. const [switches, setSwitches] = useState({ 0: false, 1: true, 2: false, 3: false });
  12. const handleSwitch = useCallback(
  13. (id, checked) => {
  14. setSwitches({ ...switches, [id]: checked });
  15. },
  16. [switches]
  17. );
  18. return (
  19. <div>
  20. <Heading size="md">Button</Heading>
  21. <div className="flex space-x-4 mb-4">
  22. <Button>Default</Button>
  23. <Button color="red">Danger</Button>
  24. <Button color="green">Save</Button>
  25. <Button color="gray">Gray</Button>
  26. <Button disabled>Disabled</Button>
  27. </div>
  28. <div className="flex space-x-4 mb-4">
  29. <Button type="text">Default</Button>
  30. <Button color="red" type="text">
  31. Danger
  32. </Button>
  33. <Button color="green" type="text">
  34. Save
  35. </Button>
  36. <Button color="gray" type="text">
  37. Gray
  38. </Button>
  39. <Button disabled type="text">
  40. Disabled
  41. </Button>
  42. </div>
  43. <div className="flex space-x-4 mb-4">
  44. <Button type="outlined">Default</Button>
  45. <Button color="red" type="outlined">
  46. Danger
  47. </Button>
  48. <Button color="green" type="outlined">
  49. Save
  50. </Button>
  51. <Button color="gray" type="outlined">
  52. Gray
  53. </Button>
  54. <Button disabled type="outlined">
  55. Disabled
  56. </Button>
  57. </div>
  58. <Heading size="md">Switch</Heading>
  59. <div className="flex-col space-y-4 max-w-4xl">
  60. <Switch label="Disabled, off" labelPosition="after" />
  61. <Switch label="Disabled, on" labelPosition="after" checked />
  62. <Switch
  63. label="Enabled, (off initial)"
  64. labelPosition="after"
  65. checked={switches[0]}
  66. id={0}
  67. onChange={handleSwitch}
  68. />
  69. <Switch
  70. label="Enabled, (on initial)"
  71. labelPosition="after"
  72. checked={switches[1]}
  73. id={1}
  74. onChange={handleSwitch}
  75. />
  76. <Switch checked={switches[2]} id={2} label="Label before" onChange={handleSwitch} />
  77. <Switch checked={switches[3]} id={3} label="Label after" labelPosition="after" onChange={handleSwitch} />
  78. </div>
  79. <Heading size="md">Select</Heading>
  80. <div className="flex space-x-4 mb-4 max-w-4xl">
  81. <Select label="Basic select box" options={['All', 'None', 'Other']} selected="None" />
  82. </div>
  83. <Heading size="md">TextField</Heading>
  84. <div className="flex-col space-y-4 max-w-4xl">
  85. <TextField label="Default text field" />
  86. <TextField label="Pre-filled" value="This is my pre-filled value" />
  87. <TextField label="With help" helpText="This is some help text" />
  88. <TextField label="Leading icon" leadingIcon={ArrowDropdown} />
  89. <TextField label="Trailing icon" trailingIcon={ArrowDropup} />
  90. </div>
  91. </div>
  92. );
  93. }