@commercetools/nimbus 0.0.1 → 0.0.3-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (302) hide show
  1. package/dist/index.d.ts +1412 -0
  2. package/dist/index.js +22451 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/index.umd.cjs +27 -0
  5. package/dist/index.umd.cjs.map +1 -0
  6. package/package.json +74 -40
  7. package/.storybook/apca-check/index.ts +0 -150
  8. package/.storybook/main.ts +0 -64
  9. package/.storybook/preview.tsx +0 -92
  10. package/.storybook/vitest.setup.ts +0 -13
  11. package/docs/architecture-decisions/adr-0001-consumer-component-apis.md +0 -177
  12. package/docs/architecture-decisions/adr-0002-compound-component-extraction.md +0 -82
  13. package/src/components/accordion/accordion-context.tsx +0 -17
  14. package/src/components/accordion/accordion.mdx +0 -172
  15. package/src/components/accordion/accordion.recipe.tsx +0 -98
  16. package/src/components/accordion/accordion.slots.tsx +0 -39
  17. package/src/components/accordion/accordion.stories.tsx +0 -188
  18. package/src/components/accordion/accordion.tsx +0 -16
  19. package/src/components/accordion/accordion.types.tsx +0 -54
  20. package/src/components/accordion/components/accordion-content.tsx +0 -28
  21. package/src/components/accordion/components/accordion-group.tsx +0 -27
  22. package/src/components/accordion/components/accordion-header.tsx +0 -63
  23. package/src/components/accordion/components/accordion-item.tsx +0 -87
  24. package/src/components/accordion/index.ts +0 -2
  25. package/src/components/alert/alert.mdx +0 -92
  26. package/src/components/alert/alert.recipe.tsx +0 -65
  27. package/src/components/alert/alert.slots.tsx +0 -46
  28. package/src/components/alert/alert.stories.tsx +0 -308
  29. package/src/components/alert/alert.tsx +0 -18
  30. package/src/components/alert/alert.types.tsx +0 -70
  31. package/src/components/alert/components/alert.actions.tsx +0 -27
  32. package/src/components/alert/components/alert.description.tsx +0 -27
  33. package/src/components/alert/components/alert.dismiss-button.tsx +0 -41
  34. package/src/components/alert/components/alert.root.tsx +0 -92
  35. package/src/components/alert/components/alert.title.tsx +0 -29
  36. package/src/components/alert/index.ts +0 -2
  37. package/src/components/avatar/avatar.mdx +0 -80
  38. package/src/components/avatar/avatar.recipe.tsx +0 -36
  39. package/src/components/avatar/avatar.slots.tsx +0 -16
  40. package/src/components/avatar/avatar.stories.tsx +0 -136
  41. package/src/components/avatar/avatar.tsx +0 -34
  42. package/src/components/avatar/avatar.types.ts +0 -33
  43. package/src/components/avatar/index.ts +0 -2
  44. package/src/components/badge/badge.mdx +0 -91
  45. package/src/components/badge/badge.recipe.tsx +0 -72
  46. package/src/components/badge/badge.slots.tsx +0 -8
  47. package/src/components/badge/badge.stories.tsx +0 -124
  48. package/src/components/badge/badge.tsx +0 -35
  49. package/src/components/badge/badge.types.tsx +0 -40
  50. package/src/components/badge/index.ts +0 -2
  51. package/src/components/bleed/bleed.tsx +0 -1
  52. package/src/components/bleed/index.ts +0 -1
  53. package/src/components/box/box.mdx +0 -115
  54. package/src/components/box/box.stories.tsx +0 -71
  55. package/src/components/box/box.tsx +0 -11
  56. package/src/components/box/index.ts +0 -1
  57. package/src/components/button/button.mdx +0 -169
  58. package/src/components/button/button.recipe.ts +0 -185
  59. package/src/components/button/button.slots.tsx +0 -45
  60. package/src/components/button/button.stories.tsx +0 -369
  61. package/src/components/button/button.tsx +0 -37
  62. package/src/components/button/button.types.ts +0 -14
  63. package/src/components/button/index.ts +0 -2
  64. package/src/components/card/card.mdx +0 -92
  65. package/src/components/card/card.recipe.tsx +0 -71
  66. package/src/components/card/card.slots.tsx +0 -50
  67. package/src/components/card/card.stories.tsx +0 -175
  68. package/src/components/card/card.tsx +0 -9
  69. package/src/components/card/card.types.ts +0 -22
  70. package/src/components/card/components/card.content.tsx +0 -29
  71. package/src/components/card/components/card.header.tsx +0 -28
  72. package/src/components/card/components/card.root.tsx +0 -62
  73. package/src/components/card/index.ts +0 -2
  74. package/src/components/checkbox/checkbox.mdx +0 -78
  75. package/src/components/checkbox/checkbox.recipe.tsx +0 -116
  76. package/src/components/checkbox/checkbox.slots.tsx +0 -33
  77. package/src/components/checkbox/checkbox.stories.tsx +0 -200
  78. package/src/components/checkbox/checkbox.tsx +0 -77
  79. package/src/components/checkbox/checkbox.types.tsx +0 -22
  80. package/src/components/checkbox/index.ts +0 -2
  81. package/src/components/code/code.mdx +0 -17
  82. package/src/components/code/code.recipe.ts +0 -63
  83. package/src/components/code/code.tsx +0 -1
  84. package/src/components/code/index.ts +0 -1
  85. package/src/components/dialog/dialog.mdx +0 -20
  86. package/src/components/dialog/dialog.recipe.ts +0 -254
  87. package/src/components/dialog/dialog.tsx +0 -61
  88. package/src/components/dialog/index.ts +0 -1
  89. package/src/components/em/em.mdx +0 -17
  90. package/src/components/em/em.tsx +0 -1
  91. package/src/components/em/index.ts +0 -1
  92. package/src/components/flex/flex.mdx +0 -41
  93. package/src/components/flex/flex.tsx +0 -1
  94. package/src/components/flex/index.ts +0 -1
  95. package/src/components/grid/grid.mdx +0 -156
  96. package/src/components/grid/grid.stories.tsx +0 -151
  97. package/src/components/grid/grid.tsx +0 -29
  98. package/src/components/grid/index.ts +0 -1
  99. package/src/components/heading/heading.mdx +0 -23
  100. package/src/components/heading/heading.recipe.ts +0 -49
  101. package/src/components/heading/heading.tsx +0 -1
  102. package/src/components/heading/index.ts +0 -1
  103. package/src/components/highlight/highlight.mdx +0 -18
  104. package/src/components/highlight/highlight.tsx +0 -1
  105. package/src/components/highlight/index.ts +0 -1
  106. package/src/components/icon-button/icon-button.mdx +0 -98
  107. package/src/components/icon-button/icon-button.stories.tsx +0 -188
  108. package/src/components/icon-button/icon-button.tsx +0 -21
  109. package/src/components/icon-button/icon-button.types.tsx +0 -10
  110. package/src/components/icon-button/index.ts +0 -2
  111. package/src/components/index.ts +0 -33
  112. package/src/components/input/index.ts +0 -1
  113. package/src/components/input/input.mdx +0 -20
  114. package/src/components/input/input.recipe.ts +0 -95
  115. package/src/components/input/input.tsx +0 -1
  116. package/src/components/input-group/index.ts +0 -1
  117. package/src/components/input-group/input-group.mdx +0 -20
  118. package/src/components/input-group/input-group.tsx +0 -44
  119. package/src/components/kbd/index.ts +0 -1
  120. package/src/components/kbd/kbd.mdx +0 -18
  121. package/src/components/kbd/kbd.recipe.ts +0 -57
  122. package/src/components/kbd/kbd.tsx +0 -1
  123. package/src/components/link/index.ts +0 -2
  124. package/src/components/link/link.mdx +0 -77
  125. package/src/components/link/link.recipe.ts +0 -52
  126. package/src/components/link/link.slots.tsx +0 -29
  127. package/src/components/link/link.stories.tsx +0 -204
  128. package/src/components/link/link.tsx +0 -38
  129. package/src/components/link/link.types.tsx +0 -26
  130. package/src/components/list/index.ts +0 -1
  131. package/src/components/list/list.mdx +0 -18
  132. package/src/components/list/list.recipe.ts +0 -68
  133. package/src/components/list/list.tsx +0 -9
  134. package/src/components/loading-spinner/index.ts +0 -2
  135. package/src/components/loading-spinner/loading-spinner.mdx +0 -92
  136. package/src/components/loading-spinner/loading-spinner.recipe.tsx +0 -70
  137. package/src/components/loading-spinner/loading-spinner.slots.tsx +0 -38
  138. package/src/components/loading-spinner/loading-spinner.stories.tsx +0 -97
  139. package/src/components/loading-spinner/loading-spinner.tsx +0 -50
  140. package/src/components/loading-spinner/loading-spinner.types.tsx +0 -21
  141. package/src/components/nimbus-provider/color-mode.tsx +0 -32
  142. package/src/components/nimbus-provider/index.ts +0 -2
  143. package/src/components/nimbus-provider/nimbus-provider.mdx +0 -21
  144. package/src/components/nimbus-provider/nimbus-provider.tsx +0 -51
  145. package/src/components/select/components/select.clear-button.tsx +0 -31
  146. package/src/components/select/components/select.option-group.tsx +0 -48
  147. package/src/components/select/components/select.option.tsx +0 -21
  148. package/src/components/select/components/select.options.tsx +0 -23
  149. package/src/components/select/components/select.root.tsx +0 -81
  150. package/src/components/select/index.ts +0 -2
  151. package/src/components/select/select.mdx +0 -170
  152. package/src/components/select/select.recipe.tsx +0 -216
  153. package/src/components/select/select.slots.tsx +0 -58
  154. package/src/components/select/select.stories.tsx +0 -841
  155. package/src/components/select/select.tsx +0 -18
  156. package/src/components/select/select.types.tsx +0 -37
  157. package/src/components/simple-grid/index.ts +0 -1
  158. package/src/components/simple-grid/simple-grid.mdx +0 -133
  159. package/src/components/simple-grid/simple-grid.stories.tsx +0 -143
  160. package/src/components/simple-grid/simple-grid.tsx +0 -31
  161. package/src/components/stack/index.ts +0 -1
  162. package/src/components/stack/stack.mdx +0 -88
  163. package/src/components/stack/stack.stories.tsx +0 -82
  164. package/src/components/stack/stack.tsx +0 -15
  165. package/src/components/table/index.ts +0 -1
  166. package/src/components/table/table.mdx +0 -23
  167. package/src/components/table/table.recipe.ts +0 -170
  168. package/src/components/table/table.tsx +0 -43
  169. package/src/components/text/index.ts +0 -1
  170. package/src/components/text/text.mdx +0 -244
  171. package/src/components/text/text.tsx +0 -23
  172. package/src/components/text-input/index.ts +0 -2
  173. package/src/components/text-input/text-input.mdx +0 -118
  174. package/src/components/text-input/text-input.recipe.tsx +0 -68
  175. package/src/components/text-input/text-input.slots.tsx +0 -24
  176. package/src/components/text-input/text-input.stories.tsx +0 -282
  177. package/src/components/text-input/text-input.tsx +0 -39
  178. package/src/components/text-input/text-input.types.ts +0 -7
  179. package/src/components/toggle-button-group/components/toggle-button-group.button.tsx +0 -14
  180. package/src/components/toggle-button-group/components/toggle-button-group.root.tsx +0 -15
  181. package/src/components/toggle-button-group/index.ts +0 -2
  182. package/src/components/toggle-button-group/toggle-button-group.mdx +0 -94
  183. package/src/components/toggle-button-group/toggle-button-group.recipe.tsx +0 -64
  184. package/src/components/toggle-button-group/toggle-button-group.slots.tsx +0 -26
  185. package/src/components/toggle-button-group/toggle-button-group.stories.tsx +0 -311
  186. package/src/components/toggle-button-group/toggle-button-group.tsx +0 -12
  187. package/src/components/toggle-button-group/toggle-button-group.types.tsx +0 -62
  188. package/src/components/tooltip/index.ts +0 -4
  189. package/src/components/tooltip/make-element-focusable.stories.tsx +0 -56
  190. package/src/components/tooltip/make-element-focusable.tsx +0 -57
  191. package/src/components/tooltip/tooltip-trigger.stories.tsx +0 -157
  192. package/src/components/tooltip/tooltip-trigger.tsx +0 -15
  193. package/src/components/tooltip/tooltip.mdx +0 -48
  194. package/src/components/tooltip/tooltip.recipe.ts +0 -26
  195. package/src/components/tooltip/tooltip.slots.ts +0 -35
  196. package/src/components/tooltip/tooltip.stories.tsx +0 -139
  197. package/src/components/tooltip/tooltip.tsx +0 -31
  198. package/src/components/tooltip/tooltip.types.ts +0 -44
  199. package/src/components/visually-hidden/index.ts +0 -1
  200. package/src/components/visually-hidden/visually-hidden.mdx +0 -61
  201. package/src/components/visually-hidden/visually-hidden.stories.tsx +0 -124
  202. package/src/components/visually-hidden/visually-hidden.tsx +0 -18
  203. package/src/docs/accessibility.mdx +0 -21
  204. package/src/docs/background.mdx +0 -154
  205. package/src/docs/border.mdx +0 -226
  206. package/src/docs/changelog.mdx +0 -17
  207. package/src/docs/components-layout.mdx +0 -22
  208. package/src/docs/components.mdx +0 -17
  209. package/src/docs/data-display.mdx +0 -23
  210. package/src/docs/display.mdx +0 -55
  211. package/src/docs/effects.mdx +0 -73
  212. package/src/docs/feedback.mdx +0 -22
  213. package/src/docs/filters.mdx +0 -268
  214. package/src/docs/flex-and-grid.mdx +0 -445
  215. package/src/docs/forms.mdx +0 -22
  216. package/src/docs/generated/index.mdx +0 -16
  217. package/src/docs/getting-started.mdx +0 -17
  218. package/src/docs/home.mdx +0 -56
  219. package/src/docs/hooks.mdx +0 -16
  220. package/src/docs/inputs.mdx +0 -21
  221. package/src/docs/installation.mdx +0 -60
  222. package/src/docs/interactivity.mdx +0 -278
  223. package/src/docs/known-issues.mdx +0 -19
  224. package/src/docs/layout.mdx +0 -301
  225. package/src/docs/list.mdx +0 -82
  226. package/src/docs/markdown.mdx +0 -234
  227. package/src/docs/media.mdx +0 -22
  228. package/src/docs/naivgation.mdx +0 -22
  229. package/src/docs/playground.mdx +0 -16
  230. package/src/docs/rfcs-component-structure-rfcs.mdx +0 -17
  231. package/src/docs/rfcs-component-structure.mdx +0 -74
  232. package/src/docs/rfcs-hook-structure.mdx +0 -59
  233. package/src/docs/sizing.mdx +0 -210
  234. package/src/docs/spacing.mdx +0 -193
  235. package/src/docs/style-props-typography.mdx +0 -373
  236. package/src/docs/style-props.mdx +0 -15
  237. package/src/docs/svg.mdx +0 -58
  238. package/src/docs/tables.mdx +0 -95
  239. package/src/docs/toc.mdx +0 -39
  240. package/src/docs/tokens/animations.mdx +0 -68
  241. package/src/docs/tokens/aspect-ratios.mdx +0 -21
  242. package/src/docs/tokens/blurs.mdx +0 -20
  243. package/src/docs/tokens/borders.mdx +0 -25
  244. package/src/docs/tokens/breakpoints.mdx +0 -35
  245. package/src/docs/tokens/colors.mdx +0 -86
  246. package/src/docs/tokens/cursors.mdx +0 -21
  247. package/src/docs/tokens/radii.mdx +0 -23
  248. package/src/docs/tokens/shadows.mdx +0 -21
  249. package/src/docs/tokens/sizes.mdx +0 -54
  250. package/src/docs/tokens/spacing.mdx +0 -35
  251. package/src/docs/tokens/typography.mdx +0 -61
  252. package/src/docs/tokens/z-indices.mdx +0 -23
  253. package/src/docs/tokens-other.mdx +0 -17
  254. package/src/docs/tokens.mdx +0 -16
  255. package/src/docs/transforms.mdx +0 -150
  256. package/src/docs/transitions.mdx +0 -164
  257. package/src/docs/typography.mdx +0 -17
  258. package/src/docs/utilities.mdx +0 -17
  259. package/src/hooks/index.ts +0 -2
  260. package/src/hooks/use-copy-to-clipboard/use-copy-to-clipboard.mdx +0 -54
  261. package/src/hooks/use-copy-to-clipboard/use-copy-to-clipboard.ts +0 -1
  262. package/src/hooks/use-hotkeys/use-hotkeys.mdx +0 -48
  263. package/src/hooks/use-hotkeys/use-hotkeys.stories.tsx +0 -69
  264. package/src/hooks/use-hotkeys/use-hotkeys.ts +0 -1
  265. package/src/index.ts +0 -3
  266. package/src/test/utils.tsx +0 -20
  267. package/src/theme/animation-styles.ts +0 -52
  268. package/src/theme/breakpoints.ts +0 -32
  269. package/src/theme/global-css.ts +0 -53
  270. package/src/theme/index.ts +0 -35
  271. package/src/theme/keyframes.ts +0 -192
  272. package/src/theme/layer-styles.ts +0 -12
  273. package/src/theme/recipes/index.ts +0 -21
  274. package/src/theme/semantic-tokens/colors.ts +0 -55
  275. package/src/theme/semantic-tokens/index.ts +0 -9
  276. package/src/theme/semantic-tokens/radii.ts +0 -3
  277. package/src/theme/semantic-tokens/shadows.ts +0 -4
  278. package/src/theme/slot-recipes/index.ts +0 -15
  279. package/src/theme/text-styles.ts +0 -8
  280. package/src/theme/tokens/animations.ts +0 -4
  281. package/src/theme/tokens/aspect-ratios.ts +0 -5
  282. package/src/theme/tokens/blurs.ts +0 -5
  283. package/src/theme/tokens/borders.ts +0 -4
  284. package/src/theme/tokens/colors.ts +0 -8
  285. package/src/theme/tokens/cursor.ts +0 -4
  286. package/src/theme/tokens/durations.ts +0 -4
  287. package/src/theme/tokens/easings.ts +0 -4
  288. package/src/theme/tokens/font-sizes.ts +0 -4
  289. package/src/theme/tokens/font-weights.ts +0 -4
  290. package/src/theme/tokens/fonts.ts +0 -4
  291. package/src/theme/tokens/index.ts +0 -57
  292. package/src/theme/tokens/letter-spacings.ts +0 -24
  293. package/src/theme/tokens/line-heights.ts +0 -4
  294. package/src/theme/tokens/radii.ts +0 -4
  295. package/src/theme/tokens/sizes.ts +0 -120
  296. package/src/theme/tokens/spacing.ts +0 -4
  297. package/src/theme/tokens/z-index.ts +0 -4
  298. package/src/utils/extractStyleProps.ts +0 -26
  299. package/src/utils/fixedForwardRef.ts +0 -17
  300. package/tsconfig.json +0 -38
  301. package/vite.config.ts +0 -54
  302. package/vitest.config.ts +0 -50
@@ -1,369 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { Button } from "./button";
3
- import { Box, Stack } from "@/components";
4
- import type { ButtonProps } from "./button.types";
5
- import { userEvent, within, expect, fn } from "@storybook/test";
6
- import { ArrowRight as DemoIcon } from "@commercetools/nimbus-icons";
7
- import { createRef, useState } from "react";
8
-
9
- const meta: Meta<typeof Button> = {
10
- title: "components/Button",
11
- component: Button,
12
- };
13
-
14
- export default meta;
15
-
16
- type Story = StoryObj<typeof Button>;
17
-
18
- const sizes: ButtonProps["size"][] = [
19
- //"2xl",
20
- //"xl",
21
- //"lg",
22
- "md",
23
- //"sm",
24
- "xs",
25
- "2xs",
26
- ];
27
-
28
- const variants: ButtonProps["variant"][] = [
29
- "solid",
30
- "subtle",
31
- "outline",
32
- "ghost",
33
- "link",
34
- ];
35
-
36
- const tones: ButtonProps["tone"][] = [
37
- "primary",
38
- "neutral",
39
- "critical",
40
- ] as const;
41
-
42
- export const Base: Story = {
43
- args: {
44
- children: "Button",
45
- onPress: fn(),
46
-
47
- ["data-testid"]: "test",
48
- ["aria-label"]: "test-button",
49
- },
50
- play: async ({ canvasElement, args, step }) => {
51
- const canvas = within(canvasElement);
52
- const button = canvas.getByTestId("test");
53
- const onPress = args.onPress;
54
-
55
- await step("Uses a <button> element by default", async () => {
56
- await expect(button.tagName).toBe("BUTTON");
57
- });
58
-
59
- await step("Forwards data- & aria-attributes", async () => {
60
- await expect(button).toHaveAttribute("data-testid", "test");
61
- await expect(button).toHaveAttribute("aria-label", "test-button");
62
- });
63
-
64
- // ATTENTION: react-aria does some complicated science,
65
- // if there is a **KEYSTROKE** before the click (like a tab-key aiming to focus the button),
66
- // the first click is not counted as a valid click
67
- await step("Is clickable", async () => {
68
- button.click();
69
- await expect(onPress).toHaveBeenCalledTimes(1);
70
- button.blur();
71
- });
72
-
73
- await step("Is focusable with <tab> key", async () => {
74
- await userEvent.tab();
75
- await expect(button).toHaveFocus();
76
- });
77
-
78
- await step("Can be triggered with enter", async () => {
79
- await userEvent.keyboard("{enter}");
80
- await expect(onPress).toHaveBeenCalledTimes(2);
81
- });
82
-
83
- await step("Can be triggered with space-bar", async () => {
84
- await expect(button).toHaveFocus();
85
- await userEvent.keyboard(" ");
86
- await expect(onPress).toHaveBeenCalledTimes(3);
87
- });
88
- },
89
- };
90
-
91
- export const Disabled: Story = {
92
- args: {
93
- children: "Disabled Button",
94
- isDisabled: true,
95
- onPress: fn(),
96
-
97
- ["data-testid"]: "test",
98
- },
99
- play: async ({ canvasElement, step, args }) => {
100
- const canvas = within(canvasElement);
101
- const button = canvas.getByTestId("test");
102
-
103
- await step("Can not be clicked", async () => {
104
- await userEvent.click(button);
105
- await userEvent.click(button);
106
- await expect(args.onPress).toHaveBeenCalledTimes(0);
107
- });
108
-
109
- await step("Can not be focused", async () => {
110
- await userEvent.tab();
111
- await expect(button).not.toHaveFocus();
112
- });
113
- },
114
- };
115
-
116
- export const AsLink: Story = {
117
- args: {
118
- children: "Link disguised as Button",
119
- as: "a",
120
- href: "/",
121
- ["data-testid"]: "test",
122
- },
123
- play: async ({ canvasElement, step }) => {
124
- const canvas = within(canvasElement);
125
- const link = canvas.getByTestId("test");
126
-
127
- await step("Uses an <a> element", async () => {
128
- await expect(link.tagName).toBe("A");
129
- });
130
- },
131
- };
132
-
133
- export const WithAsChild: Story = {
134
- args: {
135
- children: (
136
- <a>
137
- <DemoIcon /> I look like a button but am using an a-tag
138
- </a>
139
- ),
140
- asChild: true,
141
-
142
- ["data-testid"]: "test",
143
- },
144
- play: async ({ canvasElement, step }) => {
145
- const canvas = within(canvasElement);
146
- const link = canvas.getByTestId("test");
147
-
148
- await step("Uses an <a> element", async () => {
149
- await expect(link.tagName).toBe("A");
150
- });
151
- },
152
- };
153
-
154
- export const Sizes: Story = {
155
- args: {
156
- children: "Demo Button",
157
- },
158
- render: (args) => {
159
- return (
160
- <Stack direction="row" gap="400" alignItems="center">
161
- {sizes.map((size) => (
162
- <Button key={size as string} {...args} size={size} />
163
- ))}
164
- </Stack>
165
- );
166
- },
167
- };
168
-
169
- export const Variants: Story = {
170
- args: {
171
- children: "Demo Button",
172
- },
173
- render: (args) => {
174
- return (
175
- <Stack direction="row" gap="400" alignItems="center">
176
- {variants.map((size) => (
177
- <Button key={size as string} {...args} variant={size} />
178
- ))}
179
- </Stack>
180
- );
181
- },
182
- };
183
-
184
- export const Tones: Story = {
185
- args: {
186
- children: "Demo Button",
187
- },
188
- render: (args) => {
189
- return (
190
- <Stack>
191
- {tones.map((tone) => (
192
- <Stack
193
- key={tone as string}
194
- direction="row"
195
- gap="400"
196
- alignItems="center"
197
- >
198
- {variants.map((variant) => (
199
- <Button
200
- key={variant as string}
201
- {...args}
202
- variant={variant}
203
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
204
- tone={tone}
205
- />
206
- ))}
207
- </Stack>
208
- ))}
209
- </Stack>
210
- );
211
- },
212
- };
213
-
214
- const buttonRef = createRef<HTMLButtonElement>();
215
-
216
- export const WithRef: Story = {
217
- args: {
218
- children: "Demo Button",
219
- },
220
- render: (args) => {
221
- return (
222
- <Button ref={buttonRef} {...args}>
223
- {args.children}
224
- </Button>
225
- );
226
- },
227
- play: async ({ canvasElement, step }) => {
228
- const canvas = within(canvasElement);
229
- const button = canvas.getByRole("button");
230
-
231
- await step("Does accept ref's", async () => {
232
- await expect(buttonRef.current).toBe(button);
233
- });
234
- },
235
- };
236
-
237
- const Spacer = () => <Box flexGrow="1" />;
238
- export const ComplexIconLayouts: Story = {
239
- args: {
240
- children: "Demo Button",
241
- },
242
- render: (args) => {
243
- const [dir, setDir] = useState<"ltr" | "rtl">("ltr");
244
- return (
245
- <>
246
- <Button mb="800" onClick={() => setDir(dir === "ltr" ? "rtl" : "ltr")}>
247
- Change direction
248
- </Button>
249
- <Stack
250
- direction="column"
251
- gap="400"
252
- width="1/3"
253
- style={{ direction: dir }}
254
- >
255
- <Button {...args}>
256
- <DemoIcon />
257
- {args.children}
258
- </Button>
259
- <Button {...args}>
260
- Demo
261
- <DemoIcon />
262
- Button
263
- </Button>
264
- <Button {...args}>
265
- <Spacer />
266
- <DemoIcon />
267
- {args.children}
268
- </Button>
269
- <Button {...args}>
270
- <DemoIcon />
271
- {args.children}
272
- <Spacer />
273
- </Button>
274
- <Button {...args}>
275
- <DemoIcon />
276
- <Spacer />
277
- {args.children}
278
- </Button>
279
- <Button {...args}>
280
- {args.children}
281
- <Spacer />
282
- <DemoIcon />
283
- </Button>
284
- </Stack>
285
- </>
286
- );
287
- },
288
- };
289
-
290
- export const SmokeTest: Story = {
291
- args: {
292
- children: "Button",
293
- onPress: fn(),
294
- ["data-testid"]: "test",
295
- ["aria-label"]: "test-button",
296
- },
297
- render: (args) => {
298
- return (
299
- <Stack gap="1200">
300
- {tones.map((tone) => (
301
- <Stack key={tone as string} direction="column" gap="400">
302
- {sizes.map((size) => (
303
- <Stack direction="row" key={size as string}>
304
- {variants.map((variant) => (
305
- <Box key={variant as string}>
306
- <Stack direction="column" css={{ "> *": { flex: "none" } }}>
307
- <Box>
308
- <Button
309
- {...args}
310
- variant={variant}
311
- size={size}
312
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
313
- tone={tone}
314
- >
315
- <DemoIcon />
316
- {JSON.stringify(variant)} {args.children}
317
- <DemoIcon />
318
- </Button>
319
- </Box>
320
- <Box>
321
- <Button
322
- {...args}
323
- as="a"
324
- variant={variant}
325
- size={size}
326
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
327
- tone={tone}
328
- isDisabled
329
- >
330
- <DemoIcon />
331
- {JSON.stringify(variant)} {args.children}
332
- <DemoIcon />
333
- </Button>
334
- </Box>
335
- <Box>
336
- <Button
337
- {...args}
338
- variant={variant}
339
- size={size}
340
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
341
- tone={tone}
342
- >
343
- <DemoIcon />
344
- {JSON.stringify(variant)} {args.children}
345
- </Button>
346
- </Box>
347
- <Box>
348
- <Button
349
- {...args}
350
- variant={variant}
351
- size={size}
352
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
353
- tone={tone}
354
- >
355
- {JSON.stringify(variant)} {args.children}
356
- <DemoIcon />
357
- </Button>
358
- </Box>
359
- </Stack>
360
- </Box>
361
- ))}
362
- </Stack>
363
- ))}
364
- </Stack>
365
- ))}
366
- </Stack>
367
- );
368
- },
369
- };
@@ -1,37 +0,0 @@
1
- import { forwardRef, useRef } from "react";
2
- import { useButton, useObjectRef, mergeProps } from "react-aria";
3
- import { mergeRefs } from "@chakra-ui/react";
4
- import { ButtonRoot } from "./button.slots.tsx";
5
- import type { ButtonProps } from "./button.types.ts";
6
-
7
- export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
8
- (props, forwardedRef) => {
9
- const { as, asChild, children, ...rest } = props;
10
-
11
- // create a local ref (because the consumer may not provide a forwardedRef)
12
- const localRef = useRef<HTMLButtonElement>(null);
13
- // merge the local ref with a potentially forwarded ref
14
- const ref = useObjectRef(mergeRefs(localRef, forwardedRef));
15
-
16
- // if asChild is set, for react-aria to add the button-role, the elementType
17
- // has to be manually set to something else than button
18
- const elementType = as || (asChild ? "a" : "button") || "button";
19
-
20
- const { buttonProps } = useButton(
21
- {
22
- ...rest,
23
- elementType,
24
- },
25
- ref
26
- );
27
-
28
- return (
29
- <ButtonRoot {...mergeProps(rest, buttonProps, { as, asChild, ref })}>
30
- {children}
31
- </ButtonRoot>
32
- );
33
- }
34
- );
35
-
36
- // Manually assign a displayName for debugging purposes
37
- Button.displayName = "Button";
@@ -1,14 +0,0 @@
1
- import type { ButtonRootProps } from "./button.slots.tsx";
2
- import type { AriaButtonProps } from "react-aria";
3
-
4
- /** combine chakra-button props with aria-button props */
5
- type FunctionalButtonProps = ButtonRootProps &
6
- AriaButtonProps & {
7
- [key: `data-${string}`]: unknown;
8
- };
9
-
10
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
11
- export interface ButtonProps extends FunctionalButtonProps {
12
- // TODO: evaluate if we should require setting a tone
13
- // tone: FunctionalButtonProps["tone"];
14
- }
@@ -1,2 +0,0 @@
1
- export * from "./button.tsx";
2
- export * from "./button.types.ts";
@@ -1,92 +0,0 @@
1
- ---
2
- id: Components-Card
3
- title: Card
4
- description: A versatile bordered container for grouping related content
5
- documentState: InitialDraft
6
- order: 999
7
- menu:
8
- - Components
9
- - Card
10
- tags:
11
- - component
12
- ---
13
-
14
- # Card
15
-
16
- A versatile bordered container for grouping related content
17
-
18
- ## Basic Usage
19
-
20
- [Explain the basic usage / usecase of the component].
21
-
22
- ```jsx-live
23
- const App = () => <Card>I am Card!</Card>
24
- ```
25
-
26
-
27
- ### Sizes
28
-
29
- Available sizes.
30
-
31
- ```jsx-live
32
- const App = () => {
33
-
34
- const sizes = ['2xl', 'xl', 'lg', 'md', 'sm', 'xs', '2xs'];
35
-
36
- return (
37
- <Stack direction="horizontal" alignItems="center">
38
- {sizes.map(size => (
39
- <Card key={size} size={size}>'{size}' Card</Card>
40
- ))}
41
- </Stack>
42
- )
43
- }
44
- ```
45
-
46
- ### Variants
47
-
48
- Available variants.
49
-
50
- ```jsx-live
51
- const App = () => {
52
-
53
- const variants = ['solid', 'subtle', 'outline', 'ghost', 'plain'];
54
-
55
- return (
56
- <Stack direction="horizontal">
57
- {variants.map(variant => (
58
- <Card key={variant} variant={variant}>'{variant}' Card</Card>
59
- ))}
60
- </Stack>
61
- )
62
- }
63
- ```
64
-
65
- ### Colors
66
-
67
- [Explain usage with different colors/semantics.]
68
-
69
- ```jsx-live
70
- const App = () => {
71
- const variants = ["solid", "subtle", "outline", "ghost", "link", "plain"];
72
- const colors = ["neutral", "primary", "info", "success", "danger", "error"];
73
-
74
- return (
75
- <Stack>
76
- {colors.map((color) => (
77
- <Stack key={color} direction="horizontal">
78
- {variants.map((variant) => (
79
- <Card colorPalette={color} key={variant} variant={variant}>
80
- '{variant}' Card
81
- </Card>
82
- ))}
83
- </Stack>
84
- ))}
85
- </Stack>
86
- );
87
- };
88
- ```
89
-
90
- ## Props
91
-
92
- <PropTable id="Card" />
@@ -1,71 +0,0 @@
1
- import { defineSlotRecipe } from "@chakra-ui/react";
2
-
3
- /**
4
- * Recipe configuration for the Card component.
5
- * Defines the styling variants and base styles using Chakra UI's recipe system.
6
- */
7
- export const cardRecipe = defineSlotRecipe({
8
- slots: ["root", "header", "content"],
9
-
10
- className: "nimbus-card",
11
-
12
- base: {
13
- root: {
14
- colorPalette: "slate",
15
- display: "inline-flex",
16
- alignItems: "flex-start",
17
- borderRadius: "300",
18
- focusVisibleRing: "outside",
19
- },
20
- },
21
-
22
- variants: {
23
- cardPadding: {
24
- sm: {
25
- root: {
26
- padding: "200",
27
- },
28
- },
29
- md: {
30
- root: {
31
- padding: "400",
32
- },
33
- },
34
- lg: {
35
- root: {
36
- padding: "600",
37
- },
38
- },
39
- },
40
-
41
- borderStyle: {
42
- none: {},
43
- outlined: {
44
- root: {
45
- border: "solid-25",
46
- borderColor: "colorPalette.3",
47
- },
48
- },
49
- },
50
- elevation: {
51
- none: {},
52
- elevated: {
53
- root: {
54
- shadow: "1",
55
- },
56
- },
57
- },
58
- backgroundStyle: {
59
- default: {
60
- root: {
61
- backgroundColor: "colorPalette.contrast",
62
- },
63
- },
64
- muted: {
65
- root: {
66
- backgroundColor: "colorPalette.2",
67
- },
68
- },
69
- },
70
- },
71
- });
@@ -1,50 +0,0 @@
1
- import {
2
- type HTMLChakraProps,
3
- type RecipeProps,
4
- type UnstyledProp,
5
- createSlotRecipeContext,
6
- } from "@chakra-ui/react";
7
-
8
- import { cardRecipe } from "./card.recipe";
9
-
10
- /**
11
- * Base recipe props interface that combines Chakra UI's recipe props
12
- * with the unstyled prop option for the div element.
13
- */
14
- interface CardRecipeProps extends RecipeProps<"div">, UnstyledProp {}
15
-
16
- /**
17
- * Root props interface that extends Chakra's HTML props with our recipe props.
18
- * This creates a complete set of props for the root element, combining
19
- * HTML attributes, Chakra's styling system, and our custom recipe props.
20
- */
21
- export interface CardRootProps
22
- extends HTMLChakraProps<"div", CardRecipeProps> {}
23
-
24
- export interface CardHeaderProps
25
- extends HTMLChakraProps<"div", CardRecipeProps> {}
26
-
27
- export interface CardContentProps
28
- extends HTMLChakraProps<"div", CardRecipeProps> {}
29
-
30
- const { withProvider, withContext } = createSlotRecipeContext({
31
- recipe: cardRecipe,
32
- });
33
-
34
- /**
35
- * Root component that provides the styling context for the Card component.
36
- * Uses Chakra UI's recipe context system for consistent styling across instances.
37
- */
38
- export const CardRoot = withProvider<HTMLDivElement, CardRootProps>(
39
- "div",
40
- "root"
41
- );
42
-
43
- export const CardHeader = withContext<HTMLDivElement, CardHeaderProps>(
44
- "div",
45
- "header"
46
- );
47
- export const CardContent = withContext<HTMLDivElement, CardContentProps>(
48
- "div",
49
- "content"
50
- );