switch.stories.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // @ts-nocheck
  2. import * as mod from "./switch"
  3. import { create } from "../storybook/scaffold"
  4. const docs = `### Overview
  5. Toggle control for binary settings.
  6. Use in settings panels or forms.
  7. ### API
  8. - Uses Kobalte Switch props (\`checked\`, \`defaultChecked\`, \`onChange\`).
  9. - Optional: \`hideLabel\`, \`description\`.
  10. - Children render as the label.
  11. ### Variants and states
  12. - Checked/unchecked, disabled states.
  13. ### Behavior
  14. - Controlled or uncontrolled usage via Kobalte props.
  15. ### Accessibility
  16. - TODO: confirm aria attributes from Kobalte.
  17. ### Theming/tokens
  18. - Uses \`data-component="switch"\` and slot attributes.
  19. `
  20. const story = create({
  21. title: "UI/Switch",
  22. mod,
  23. args: { defaultChecked: true, children: "Enable notifications" },
  24. })
  25. export default {
  26. title: "UI/Switch",
  27. id: "components-switch",
  28. component: story.meta.component,
  29. tags: ["autodocs"],
  30. parameters: {
  31. docs: {
  32. description: {
  33. component: docs,
  34. },
  35. },
  36. },
  37. }
  38. export const Basic = story.Basic
  39. export const States = {
  40. render: () => (
  41. <div style={{ display: "grid", gap: "12px" }}>
  42. <mod.Switch defaultChecked>Enabled</mod.Switch>
  43. <mod.Switch>Disabled</mod.Switch>
  44. <mod.Switch disabled>Disabled switch</mod.Switch>
  45. <mod.Switch description="Optional description">With description</mod.Switch>
  46. </div>
  47. ),
  48. }
  49. export const HiddenLabel = {
  50. args: {
  51. children: "Hidden label",
  52. hideLabel: true,
  53. defaultChecked: true,
  54. },
  55. }