@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,200 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unsafe-call */
2
- import type { Meta, StoryObj } from "@storybook/react";
3
- import { Checkbox } from "./checkbox";
4
- import { Stack } from "@/components";
5
- import { userEvent, within, expect, fn } from "@storybook/test";
6
-
7
- const meta: Meta<typeof Checkbox> = {
8
- title: "components/Checkbox",
9
- component: Checkbox,
10
- };
11
-
12
- export default meta;
13
-
14
- /**
15
- * Story type for TypeScript support
16
- * StoryObj provides type checking for our story configurations
17
- */
18
- type Story = StoryObj<typeof Checkbox>;
19
-
20
- /**
21
- * Base Story showcasing the default Checkbox state
22
- */
23
- export const Base: Story = {
24
- args: {
25
- children: "Checkbox Label",
26
- onChange: fn(),
27
- // @ts-expect-error: data-testid is not a valid prop
28
- "data-testid": "test-checkbox",
29
- "aria-label": "test-label",
30
- },
31
- play: async ({ canvasElement, args, step }) => {
32
- const canvas = within(canvasElement);
33
- const htmlLabel = canvasElement.querySelector(
34
- '[data-slot="root"]'
35
- ) as HTMLLabelElement;
36
- const displayLabel = canvasElement.querySelector(
37
- '[data-slot="label"]'
38
- ) as HTMLSpanElement;
39
- const htmlInput = canvas.getByTestId("test-checkbox");
40
- const onChange = args.onChange;
41
-
42
- await step(
43
- "Forwards data- & aria-attributes to the actual html-input",
44
- async () => {
45
- await expect(htmlInput.tagName).toBe("INPUT");
46
- await expect(htmlInput).toHaveAttribute("data-testid", "test-checkbox");
47
- await expect(htmlInput).toHaveAttribute("aria-label", "test-label");
48
- }
49
- );
50
-
51
- await step("Can be focused with the keyboard", async () => {
52
- await userEvent.keyboard("{tab}");
53
- await expect(htmlInput).toHaveFocus();
54
- });
55
-
56
- await step("Can be triggered with space-bar", async () => {
57
- await userEvent.keyboard(" ");
58
- await expect(onChange).toHaveBeenCalledTimes(1);
59
- await userEvent.keyboard(" ");
60
- await expect(onChange).toHaveBeenCalledTimes(2);
61
- });
62
- await step("Can not be triggered with enter", async () => {
63
- await userEvent.keyboard("{enter}");
64
- await expect(onChange).toHaveBeenCalledTimes(2);
65
- });
66
-
67
- await step("Can be triggered by clicking on root & label", async () => {
68
- htmlLabel.click();
69
- await expect(onChange).toHaveBeenCalledTimes(3);
70
- displayLabel.click();
71
- await expect(onChange).toHaveBeenCalledTimes(4);
72
- });
73
- },
74
- };
75
-
76
- export const Disabled: Story = {
77
- args: {
78
- children: "Disabled Checkbox",
79
- // @ts-expect-error: data-testid is not a valid prop
80
- "data-testid": "test-checkbox",
81
- isDisabled: true,
82
- isSelected: false,
83
- onChange: fn(),
84
- },
85
-
86
- play: async ({ canvasElement, step, args }) => {
87
- const canvas = within(canvasElement);
88
- const htmlLabel = canvasElement.querySelector(
89
- '[data-slot="root"]'
90
- ) as HTMLLabelElement;
91
- const htmlInput = canvas.getByTestId("test-checkbox");
92
-
93
- await step("input has html 'disabled' attribute", async () => {
94
- await expect(htmlInput).toHaveAttribute("disabled");
95
- });
96
-
97
- await step("Can not be focused with the keyboard", async () => {
98
- await userEvent.keyboard("{tab}");
99
- await expect(htmlInput).not.toHaveFocus();
100
- });
101
-
102
- await step(
103
- "Can not be triggered by clicking on the root- or label-element",
104
- async () => {
105
- //await expect(htmlInput).toBeDisabled();
106
- await expect(htmlInput).not.toBeChecked();
107
- htmlLabel.click();
108
- await expect(htmlInput).not.toBeChecked();
109
- await expect(args.onChange).not.toBeCalled();
110
- }
111
- );
112
- },
113
- };
114
-
115
- export const Invalid: Story = {
116
- args: {
117
- children: "Invalid Checkbox",
118
- // @ts-expect-error: data-testid is not a valid prop
119
- "data-testid": "test-checkbox",
120
- isInvalid: true,
121
- onChange: fn(),
122
- },
123
-
124
- play: async ({ canvasElement, step }) => {
125
- const canvas = within(canvasElement);
126
- const htmlInput = canvas.getByTestId("test-checkbox");
127
- await step("html input state is invalid", async () => {
128
- await expect(htmlInput).toBeInvalid();
129
- });
130
- },
131
- };
132
-
133
- export const InvisibleLabel: Story = {
134
- args: {
135
- // @ts-expect-error: data-testid is not a valid prop
136
- "data-testid": "test-checkbox",
137
- "aria-label": "Checkbox without label",
138
- },
139
-
140
- play: async ({ canvasElement, step, args }) => {
141
- const canvas = within(canvasElement);
142
- const htmlInput = canvas.getByTestId("test-checkbox");
143
-
144
- await step("Has alternative label", async () => {
145
- await expect(htmlInput).toHaveAttribute("aria-label", args["aria-label"]);
146
- });
147
- },
148
- };
149
-
150
- /**
151
- * Smoke Test
152
- * This story attempts to capture all visual permutations
153
- */
154
- export const SmokeTest: Story = {
155
- render: () => {
156
- return (
157
- <Stack gap="1000">
158
- {[false, true].map((isInvalid, j) => (
159
- <Stack direction="row" key={j}>
160
- {[false, true].map((isDisabled, i) => (
161
- <Stack
162
- width="1/2"
163
- key={i}
164
- direction="column"
165
- alignItems="flex-start"
166
- >
167
- <Checkbox
168
- isSelected={false}
169
- isDisabled={isDisabled}
170
- isInvalid={isInvalid}
171
- >
172
- Unchecked, {isDisabled ? "disabled" : "not disabled"},{" "}
173
- {isInvalid ? "invalid" : ""}
174
- </Checkbox>
175
-
176
- <Checkbox
177
- isDisabled={isDisabled}
178
- isInvalid={isInvalid}
179
- isSelected
180
- >
181
- Checked, {isDisabled ? "disabled" : "not disabled"},{" "}
182
- {isInvalid ? "invalid" : ""}
183
- </Checkbox>
184
-
185
- <Checkbox
186
- isDisabled={isDisabled}
187
- isInvalid={isInvalid}
188
- isIndeterminate
189
- >
190
- Indeterminate, {isDisabled ? "disabled" : "not disabled"},{" "}
191
- {isInvalid ? "invalid" : ""}
192
- </Checkbox>
193
- </Stack>
194
- ))}
195
- </Stack>
196
- ))}
197
- </Stack>
198
- );
199
- },
200
- };
@@ -1,77 +0,0 @@
1
- import { forwardRef, useRef } from "react";
2
- import { useToggleState } from "react-stately";
3
- import { useSlotRecipe } from "@chakra-ui/react";
4
- import { VisuallyHidden } from "@/components";
5
- import { Check, Remove as Minus } from "@commercetools/nimbus-icons";
6
-
7
- import {
8
- useFocusRing,
9
- useCheckbox,
10
- useObjectRef,
11
- mergeProps,
12
- } from "react-aria";
13
-
14
- import { mergeRefs } from "@chakra-ui/react";
15
- import type { CheckboxProps } from "./checkbox.types";
16
- import {
17
- CheckboxIndicator,
18
- CheckboxRoot,
19
- CheckboxLabel,
20
- } from "./checkbox.slots";
21
-
22
- /**
23
- * Checkbox
24
- * ============================================================
25
- * displays a checkbox and an associated label
26
- *
27
- * Features:
28
- *
29
- * - allows forwarding refs to the underlying DOM element
30
- * - accepts all native html 'HTMLDivElement' attributes (including aria- & data-attributes)
31
- * - supports 'variants', 'sizes', etc. configured in the recipe
32
- * - allows overriding styles by using style-props
33
- * - supports 'asChild' and 'as' to modify the underlying html-element (polymorphic)
34
- */
35
- export const Checkbox = forwardRef<HTMLInputElement, CheckboxProps>(
36
- (props, forwardedRef) => {
37
- const localRef = useRef<HTMLInputElement>(null);
38
- const ref = useObjectRef(mergeRefs(localRef, forwardedRef));
39
-
40
- const recipe = useSlotRecipe({ key: "checkbox" });
41
- const [recipeProps] = recipe.splitVariantProps(props);
42
-
43
- const state = useToggleState(props);
44
- const { inputProps } = useCheckbox(props, state, ref);
45
-
46
- const { isFocused, focusProps } = useFocusRing();
47
- const isSelected = state.isSelected && !props.isIndeterminate;
48
- const isIndeterminate = props.isIndeterminate;
49
-
50
- const stateProps = {
51
- "data-selected": isSelected,
52
- "data-indeterminate": isIndeterminate,
53
- "data-invalid": props.isInvalid,
54
- "data-disabled": props.isDisabled,
55
- "data-focus": isFocused || undefined,
56
- };
57
-
58
- return (
59
- <CheckboxRoot data-slot="root" {...recipeProps} {...stateProps}>
60
- <CheckboxIndicator data-slot="indicator" {...stateProps}>
61
- {isSelected && <Check />}
62
- {isIndeterminate && <Minus />}
63
- <VisuallyHidden as="span">
64
- <input {...mergeProps(inputProps, focusProps)} ref={ref} />
65
- </VisuallyHidden>
66
- </CheckboxIndicator>
67
-
68
- {props.children && (
69
- <CheckboxLabel data-slot="label" {...stateProps}>
70
- {props.children}
71
- </CheckboxLabel>
72
- )}
73
- </CheckboxRoot>
74
- );
75
- }
76
- );
77
- Checkbox.displayName = "Checkbox";
@@ -1,22 +0,0 @@
1
- import type { CheckboxRootProps } from "./checkbox.slots";
2
- import type { RecipeVariantProps } from "@chakra-ui/react";
3
- import { checkboxSlotRecipe } from "./checkbox.recipe";
4
- import type { AriaCheckboxProps } from "react-aria";
5
-
6
- /**
7
- * Combines the root props with Chakra UI's recipe variant props.
8
- * This allows the component to accept both structural props from Root
9
- * and styling variants from the recipe.
10
- */
11
- type CheckboxVariantProps = CheckboxRootProps &
12
- RecipeVariantProps<typeof checkboxSlotRecipe> &
13
- AriaCheckboxProps;
14
-
15
- /**
16
- * Main props interface for the Checkbox component.
17
- * Extends CheckboxVariantProps to include both root props and variant props,
18
- * while adding support for React children.
19
- */
20
- export interface CheckboxProps extends CheckboxVariantProps {
21
- children?: React.ReactNode;
22
- }
@@ -1,2 +0,0 @@
1
- export * from './checkbox'
2
- export * from './checkbox.types'
@@ -1,17 +0,0 @@
1
- ---
2
- id: Code
3
- title: Code
4
- description: renders code blocks
5
- documentState: InitialDraft
6
- order: 999
7
- menu:
8
- - Components
9
- - Typography
10
- - Code
11
- tags:
12
- - code
13
- ---
14
-
15
- # Code
16
-
17
- Add description later.
@@ -1,63 +0,0 @@
1
- import { defineRecipe } from "@chakra-ui/react";
2
-
3
- export const codeRecipe = defineRecipe({
4
- className: "nimbus-code",
5
- base: {
6
- fontFamily: "mono",
7
- alignItems: "center",
8
- display: "inline-flex",
9
- borderRadius: "100",
10
- },
11
- variants: {
12
- variant: {
13
- solid: {
14
- bg: "colorPalette.4",
15
- color: "colorPalette.11",
16
- },
17
- subtle: {
18
- bg: "colorPalette.3",
19
- color: "colorPalette.11",
20
- },
21
- outline: {
22
- color: "colorPalette.fg",
23
- shadow: "inset 0 0 0px 1px var(--shadow-color)",
24
- shadowColor: "colorPalette.muted",
25
- },
26
- surface: {
27
- bg: "colorPalette.subtle",
28
- color: "colorPalette.fg",
29
- shadow: "inset 0 0 0px 1px var(--shadow-color)",
30
- shadowColor: "colorPalette.muted",
31
- },
32
- plain: {
33
- color: "colorPalette.fg",
34
- },
35
- },
36
- size: {
37
- xs: {
38
- textStyle: "2xs",
39
- px: "100",
40
- minH: "400",
41
- },
42
- sm: {
43
- textStyle: "xs",
44
- px: "150",
45
- minH: "500",
46
- },
47
- md: {
48
- textStyle: "sm",
49
- px: "200",
50
- minH: "600",
51
- },
52
- lg: {
53
- textStyle: "sm",
54
- px: "250",
55
- minH: "700",
56
- },
57
- },
58
- },
59
- defaultVariants: {
60
- variant: "solid",
61
- size: "md",
62
- },
63
- });
@@ -1 +0,0 @@
1
- export { Code } from "@chakra-ui/react";
@@ -1 +0,0 @@
1
- export * from "./code.tsx";
@@ -1,20 +0,0 @@
1
- ---
2
- id: Dialog
3
- title: Dialog
4
- description: displays a dialog
5
- documentState: InitialDraft
6
- order: 999
7
- menu:
8
- - Components
9
- - Feedback
10
- - Dialog
11
- tags:
12
- - dialog
13
- - modal
14
- ---
15
-
16
- # Dialog
17
-
18
- ## Props
19
-
20
- <PropTables ids="DialogRoot, DialogFooter, DialogHeader, DialogBody, DialogBackdrop, DialogTitle, DialogDescription, DialogTrigger, DialogActionTrigger" />
@@ -1,254 +0,0 @@
1
- import { defineSlotRecipe } from "@chakra-ui/react";
2
-
3
- export const dialogSlotRecipe = defineSlotRecipe({
4
- slots: [
5
- "trigger",
6
- "backdrop",
7
- "positioner",
8
- "content",
9
- "title",
10
- "description",
11
- "closeTrigger",
12
- "header",
13
- "body",
14
- "footer",
15
- "backdrop",
16
- ],
17
- className: "nimbus-dialog",
18
- base: {
19
- backdrop: {
20
- bg: {
21
- _dark: "bg/50",
22
- _light: "fg/50",
23
- },
24
- pos: "fixed",
25
- left: 0,
26
- top: 0,
27
- w: "100vw",
28
- h: "100dvh",
29
- zIndex: "modal",
30
- _open: {
31
- animationName: "fade-in",
32
- animationDuration: "slow",
33
- },
34
- _closed: {
35
- animationName: "fade-out",
36
- animationDuration: "moderate",
37
- },
38
- },
39
- positioner: {
40
- display: "flex",
41
- width: "100vw",
42
- height: "100dvh",
43
- position: "fixed",
44
- left: 0,
45
- top: 0,
46
- "--dialog-z-index": "zIndex.modal",
47
- zIndex: "calc(var(--dialog-z-index) + var(--layer-index, 0))",
48
- justifyContent: "center",
49
- overscrollBehaviorY: "none",
50
- },
51
- content: {
52
- display: "flex",
53
- flexDirection: "column",
54
- position: "relative",
55
- width: "100%",
56
- outline: 0,
57
- borderRadius: "200",
58
- textStyle: "sm",
59
- my: "var(--dialog-margin, var(--dialog-base-margin))",
60
- "--dialog-z-index": "zIndex.modal",
61
- zIndex: "calc(var(--dialog-z-index) + var(--layer-index, 0))",
62
- bg: "bg",
63
- boxShadow: "lg",
64
- _open: {
65
- animationDuration: "moderate",
66
- },
67
- _closed: {
68
- animationDuration: "faster",
69
- },
70
- },
71
- header: {
72
- flex: 0,
73
- px: "600",
74
- pt: "600",
75
- pb: "400",
76
- },
77
- body: {
78
- flex: "1",
79
- px: "600",
80
- pt: "200",
81
- pb: "600",
82
- },
83
- footer: {
84
- display: "flex",
85
- alignItems: "center",
86
- justifyContent: "flex-end",
87
- gap: "300",
88
- px: "600",
89
- pt: "200",
90
- pb: "400",
91
- },
92
- title: {
93
- textStyle: "lg",
94
- fontWeight: "semibold",
95
- },
96
- description: {
97
- color: "fg.muted",
98
- },
99
- },
100
- variants: {
101
- placement: {
102
- center: {
103
- positioner: {
104
- alignItems: "center",
105
- },
106
- content: {
107
- "--dialog-base-margin": "auto",
108
- mx: "auto",
109
- },
110
- },
111
- top: {
112
- positioner: {
113
- alignItems: "flex-start",
114
- },
115
- content: {
116
- "--dialog-base-margin": "spacing.1600",
117
- mx: "auto",
118
- },
119
- },
120
- bottom: {
121
- positioner: {
122
- alignItems: "flex-end",
123
- },
124
- content: {
125
- "--dialog-base-margin": "spacing.1600",
126
- mx: "auto",
127
- },
128
- },
129
- },
130
- scrollBehavior: {
131
- inside: {
132
- positioner: {
133
- overflow: "hidden",
134
- },
135
- content: {
136
- maxH: "calc(100% - 7.5rem)",
137
- },
138
- body: {
139
- overflow: "auto",
140
- },
141
- },
142
- outside: {
143
- positioner: {
144
- overflow: "auto",
145
- pointerEvents: "auto",
146
- },
147
- },
148
- },
149
- size: {
150
- xs: {
151
- content: {
152
- maxW: "sm",
153
- },
154
- },
155
- sm: {
156
- content: {
157
- maxW: "md",
158
- },
159
- },
160
- md: {
161
- content: {
162
- maxW: "lg",
163
- },
164
- },
165
- lg: {
166
- content: {
167
- maxW: "2xl",
168
- },
169
- },
170
- xl: {
171
- content: {
172
- maxW: "4xl",
173
- },
174
- },
175
- cover: {
176
- positioner: {
177
- padding: "1000",
178
- },
179
- content: {
180
- width: "100%",
181
- height: "100%",
182
- "--dialog-margin": "0",
183
- },
184
- },
185
- full: {
186
- content: {
187
- maxW: "100vw",
188
- minH: "100vh",
189
- "--dialog-margin": "0",
190
- borderRadius: "0",
191
- },
192
- },
193
- },
194
- motionPreset: {
195
- scale: {
196
- content: {
197
- _open: {
198
- animationName: "scale-in, fade-in",
199
- },
200
- _closed: {
201
- animationName: "scale-out, fade-out",
202
- },
203
- },
204
- },
205
- "slide-in-bottom": {
206
- content: {
207
- _open: {
208
- animationName: "slide-from-bottom, fade-in",
209
- },
210
- _closed: {
211
- animationName: "slide-to-bottom, fade-out",
212
- },
213
- },
214
- },
215
- "slide-in-top": {
216
- content: {
217
- _open: {
218
- animationName: "slide-from-top, fade-in",
219
- },
220
- _closed: {
221
- animationName: "slide-to-top, fade-out",
222
- },
223
- },
224
- },
225
- "slide-in-left": {
226
- content: {
227
- _open: {
228
- animationName: "slide-from-left, fade-in",
229
- },
230
- _closed: {
231
- animationName: "slide-to-left, fade-out",
232
- },
233
- },
234
- },
235
- "slide-in-right": {
236
- content: {
237
- _open: {
238
- animationName: "slide-from-right, fade-in",
239
- },
240
- _closed: {
241
- animationName: "slide-to-right, fade-out",
242
- },
243
- },
244
- },
245
- none: {},
246
- },
247
- },
248
- defaultVariants: {
249
- size: "md",
250
- scrollBehavior: "outside",
251
- placement: "top",
252
- motionPreset: "scale",
253
- },
254
- });