button.stories.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. // @ts-nocheck
  2. import { Button } from "./button"
  3. const docs = `### Overview
  4. Primary action button with size, variant, and optional icon support.
  5. Use \`IconButton\` for icon-only actions.
  6. ### API
  7. - \`variant\`: "primary" | "secondary" | "ghost".
  8. - \`size\`: "small" | "normal" | "large".
  9. - \`icon\`: Icon name for a leading icon.
  10. - Inherits Kobalte Button props and native button attributes.
  11. ### Variants and states
  12. - Variants: primary, secondary, ghost.
  13. - States: disabled.
  14. ### Behavior
  15. - Renders an Icon when \`icon\` is set.
  16. ### Accessibility
  17. - Provide clear label text; use \`aria-label\` for icon-only buttons.
  18. ### Theming/tokens
  19. - Uses \`data-component="button"\` with size/variant data attributes.
  20. `
  21. export default {
  22. title: "UI/Button",
  23. id: "components-button",
  24. component: Button,
  25. tags: ["autodocs"],
  26. parameters: {
  27. docs: {
  28. description: {
  29. component: docs,
  30. },
  31. },
  32. },
  33. args: {
  34. children: "Button",
  35. variant: "secondary",
  36. size: "normal",
  37. },
  38. argTypes: {
  39. variant: {
  40. control: "select",
  41. options: ["primary", "secondary", "ghost"],
  42. },
  43. size: {
  44. control: "select",
  45. options: ["small", "normal", "large"],
  46. },
  47. icon: {
  48. control: "select",
  49. options: ["none", "check", "plus", "arrow-right"],
  50. mapping: {
  51. none: undefined,
  52. },
  53. },
  54. },
  55. }
  56. export const Primary = {
  57. args: {
  58. variant: "primary",
  59. },
  60. }
  61. export const Secondary = {}
  62. export const Ghost = {
  63. args: {
  64. variant: "ghost",
  65. },
  66. }
  67. export const WithIcon = {
  68. args: {
  69. children: "Continue",
  70. icon: "arrow-right",
  71. },
  72. }
  73. export const Disabled = {
  74. args: {
  75. variant: "primary",
  76. disabled: true,
  77. },
  78. }
  79. export const Sizes = {
  80. render: () => (
  81. <div style={{ display: "flex", gap: "12px", "align-items": "center" }}>
  82. <Button size="small" variant="secondary">
  83. Small
  84. </Button>
  85. <Button size="normal" variant="secondary">
  86. Normal
  87. </Button>
  88. <Button size="large" variant="secondary">
  89. Large
  90. </Button>
  91. </div>
  92. ),
  93. }