@commercetools/nimbus 0.0.2 → 0.0.3

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 +11183 -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 +63 -39
  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,18 +0,0 @@
1
- import AlertTitle from "./components/alert.title";
2
- import AlertDescription from "./components/alert.description";
3
- import AlertActions from "./components/alert.actions";
4
- import AlertDismissButton from "./components/alert.dismiss-button";
5
- import AlertRoot from "./components/alert.root";
6
-
7
- /**
8
- * Alert
9
- * ============================================================
10
- * Provides feedback to the user about the status of an action or system event
11
- */
12
- export const Alert = {
13
- Root: AlertRoot,
14
- Title: AlertTitle,
15
- Description: AlertDescription,
16
- Actions: AlertActions,
17
- DismissButton: AlertDismissButton,
18
- };
@@ -1,70 +0,0 @@
1
- import type {
2
- HTMLChakraProps,
3
- RecipeProps,
4
- RecipeVariantProps,
5
- } from "@chakra-ui/react";
6
- import { alertRecipe } from "./alert.recipe";
7
- import type { TextProps } from "../text";
8
- import type { ButtonProps } from "../button";
9
- import type {
10
- ForwardRefExoticComponent,
11
- PropsWithChildren,
12
- RefAttributes,
13
- } from "react";
14
-
15
- // ============================================================
16
- // Root Component (`<Alert>`)
17
- // ============================================================
18
-
19
- /** Base Chakra styling props for the root `div` slot. */
20
- export type AlertRootProps = HTMLChakraProps<"div", RecipeProps<"div">>;
21
-
22
- /** Combined root props including Chakra styles and recipe variants. */
23
- type AlertVariantProps = AlertRootProps &
24
- RecipeVariantProps<typeof alertRecipe>;
25
-
26
- /** Final external props for the `<Alert>` component (variants + children + data-* attrs). */
27
- export type AlertProps = PropsWithChildren<AlertVariantProps> & {
28
- // Allow passthrough of data-* attributes
29
- [key: `data-${string}`]: unknown;
30
- };
31
-
32
- /** Type signature for the main `Alert` component (using `forwardRef`). */
33
- export type AlertRootComponent = ForwardRefExoticComponent<
34
- AlertProps & RefAttributes<HTMLDivElement>
35
- >;
36
-
37
- // ============================================================
38
- // Icon Slot
39
- // ============================================================
40
-
41
- /** Base Chakra styling props for the `icon` slot (`div`). */
42
- export type AlertIconProps = HTMLChakraProps<"div", RecipeProps<"div">>;
43
-
44
- // ============================================================
45
- // Title Sub-Component (`<Alert.Title>`)
46
- // ============================================================
47
-
48
- /** Props for the `Alert.Title` sub-component (inherits from Text). */
49
- export type AlertTitleProps = TextProps;
50
-
51
- // ============================================================
52
- // Description Sub-Component (`<Alert.Description>`)
53
- // ============================================================
54
-
55
- /** Props for the `Alert.Description` sub-component (inherits from Text). */
56
- export type AlertDescriptionProps = TextProps;
57
-
58
- // ============================================================
59
- // Actions Sub-Component (`<Alert.Actions>`)
60
- // ============================================================
61
-
62
- /** Base Chakra styling props for the `actions` slot (`div`). */
63
- export type AlertActionsProps = HTMLChakraProps<"div", RecipeProps<"div">>;
64
-
65
- // ============================================================
66
- // DismissButton Sub-Component (`<Alert.DismissButton>`)
67
- // ============================================================
68
-
69
- /** Props for the `Alert.DismissButton` sub-component (inherits from Button). */
70
- export type AlertDismissButtonProps = ButtonProps;
@@ -1,27 +0,0 @@
1
- import { useContext, useEffect } from "react";
2
- import { AlertActions as AlertActionsSlot } from "../alert.slots";
3
- import type { AlertActionsProps } from "../alert.types";
4
- import { AlertContext } from "./alert.root";
5
-
6
- const AlertActions = ({ children, ...props }: AlertActionsProps) => {
7
- const context = useContext(AlertContext);
8
-
9
- useEffect(() => {
10
- if (context) {
11
- const slotElement = (
12
- <AlertActionsSlot {...props}>{children}</AlertActionsSlot>
13
- );
14
- // Register it with the parent
15
- context.setActions(slotElement);
16
-
17
- // On unmount, remove it
18
- return () => context.setActions(null);
19
- }
20
- }, [children, props]);
21
-
22
- return null;
23
- };
24
-
25
- AlertActions.displayName = "Alert.Actions";
26
-
27
- export default AlertActions;
@@ -1,27 +0,0 @@
1
- import { useContext, useEffect } from "react";
2
- import { AlertDescription as AlertDescriptionSlot } from "../alert.slots";
3
- import type { AlertDescriptionProps } from "../alert.types";
4
- import { AlertContext } from "./alert.root";
5
-
6
- const AlertDescription = ({ children, ...props }: AlertDescriptionProps) => {
7
- const context = useContext(AlertContext);
8
-
9
- useEffect(() => {
10
- if (context) {
11
- const slotElement = (
12
- <AlertDescriptionSlot {...props}>{children}</AlertDescriptionSlot>
13
- );
14
- // Register it with the parent
15
- context.setDescription(slotElement);
16
-
17
- // On unmount, remove it
18
- return () => context.setDescription(null);
19
- }
20
- }, [children, props]);
21
-
22
- return null;
23
- };
24
-
25
- AlertDescription.displayName = "Alert.Description";
26
-
27
- export default AlertDescription;
@@ -1,41 +0,0 @@
1
- import { useContext, useEffect } from "react";
2
- import { AlertDismissButton as AlertDismissButtonSlot } from "../alert.slots";
3
- import type { AlertDismissButtonProps } from "../alert.types";
4
- import { Clear } from "@commercetools/nimbus-icons";
5
- import { IconButton } from "../../icon-button";
6
- import { AlertContext } from "./alert.root";
7
-
8
- const AlertDismissButton = ({
9
- children,
10
- ...props
11
- }: AlertDismissButtonProps) => {
12
- const context = useContext(AlertContext);
13
-
14
- useEffect(() => {
15
- if (context) {
16
- const slotElement = (
17
- <AlertDismissButtonSlot>
18
- <IconButton
19
- aria-label="Dismiss"
20
- {...props}
21
- variant="ghost"
22
- size="2xs"
23
- >
24
- <Clear role="img" />
25
- </IconButton>
26
- </AlertDismissButtonSlot>
27
- );
28
- // Register it with the parent
29
- context.setDismiss(slotElement);
30
-
31
- // On unmount, remove it
32
- return () => context.setDismiss(null);
33
- }
34
- }, [children, props]);
35
-
36
- return null;
37
- };
38
-
39
- AlertDismissButton.displayName = "Alert.DismissButton";
40
-
41
- export default AlertDismissButton;
@@ -1,92 +0,0 @@
1
- import {
2
- createContext,
3
- forwardRef,
4
- useMemo,
5
- useState,
6
- type ReactNode,
7
- } from "react";
8
- import { AlertRoot as AlertRootSlot, AlertIcon } from "../alert.slots";
9
- import type { AlertProps, AlertRootComponent } from "../alert.types";
10
- import { Box } from "../../box";
11
- import { Stack } from "../../stack";
12
- import {
13
- CheckCircleOutline,
14
- ErrorOutline,
15
- Info,
16
- WarningAmber,
17
- } from "@commercetools/nimbus-icons";
18
-
19
- const getIconFromTone = (tone: AlertProps["tone"]) => {
20
- switch (tone) {
21
- case "critical":
22
- return <ErrorOutline />;
23
- case "info":
24
- return <Info />;
25
- case "warning":
26
- return <WarningAmber />;
27
- case "positive":
28
- return <CheckCircleOutline />;
29
- default:
30
- return null;
31
- }
32
- };
33
-
34
- type AlertContextValue = {
35
- setTitle: (title: ReactNode) => void;
36
- setDescription: (description: ReactNode) => void;
37
- setActions: (actions: ReactNode) => void;
38
- setDismiss: (dismiss: ReactNode) => void;
39
- };
40
-
41
- export const AlertContext = createContext<AlertContextValue | undefined>(
42
- undefined
43
- );
44
-
45
- /**
46
- * Alert
47
- * ============================================================
48
- * Provides feedback to the user about the status of an action or system event
49
- */
50
- const AlertRoot: AlertRootComponent = forwardRef<HTMLDivElement, AlertProps>(
51
- ({ children, ...props }, ref) => {
52
- const [titleNode, setTitle] = useState<ReactNode>(null);
53
- const [descriptionNode, setDescription] = useState<ReactNode>(null);
54
- const [actionsNode, setActions] = useState<ReactNode>(null);
55
- const [dismissNode, setDismiss] = useState<ReactNode>(null);
56
-
57
- // Memoize the context value so we don't cause unnecessary re-renders
58
- const contextValue = useMemo(
59
- () => ({
60
- setTitle,
61
- setDescription,
62
- setActions,
63
- setDismiss,
64
- }),
65
- [setTitle, setDescription, setActions, setDismiss]
66
- );
67
-
68
- return (
69
- <AlertContext.Provider value={contextValue}>
70
- <AlertRootSlot ref={ref} {...props} role="alert">
71
- <AlertIcon alignItems="flex-start">
72
- {getIconFromTone(props.tone)}
73
- </AlertIcon>
74
- <Stack flex="1" gap="200">
75
- <Box>
76
- {titleNode}
77
- {descriptionNode}
78
- </Box>
79
- {actionsNode}
80
- </Stack>
81
- {dismissNode}
82
-
83
- {children}
84
- </AlertRootSlot>
85
- </AlertContext.Provider>
86
- );
87
- }
88
- );
89
-
90
- AlertRoot.displayName = "Alert.Root";
91
-
92
- export default AlertRoot;
@@ -1,29 +0,0 @@
1
- import { useContext, useEffect } from "react";
2
- import { AlertTitle as AlertTitleSlot } from "../alert.slots";
3
- import type { AlertTitleProps } from "../alert.types";
4
- import { AlertContext } from "./alert.root";
5
-
6
- const AlertTitle = ({ children, ...props }: AlertTitleProps) => {
7
- const context = useContext(AlertContext);
8
-
9
- useEffect(() => {
10
- if (context) {
11
- const slotElement = (
12
- <AlertTitleSlot {...props} fontWeight="600">
13
- {children}
14
- </AlertTitleSlot>
15
- );
16
- // Register it with the parent
17
- context.setTitle(slotElement);
18
-
19
- // On unmount, remove it
20
- return () => context.setTitle(null);
21
- }
22
- }, [children, props]);
23
-
24
- return null;
25
- };
26
-
27
- AlertTitle.displayName = "Alert.Title";
28
-
29
- export default AlertTitle;
@@ -1,2 +0,0 @@
1
- export * from "./alert";
2
- export * from "./alert.types";
@@ -1,80 +0,0 @@
1
- ---
2
- id: Components-Avatar
3
- title: Avatar
4
- description: >-
5
- A reusable Avatar component to display user profile pictures or initials that
6
- is flexible and customizable for various use cases.
7
- documentState: InitialDraft
8
- order: 999
9
- menu:
10
- - Components
11
- - Media
12
- - Avatar
13
- tags:
14
- - component
15
- figmaLink: >-
16
- https://www.figma.com/design/AvtPX6g7OGGCRvNlatGOIY/New-Design-System?node-id=180-1106&t=MVbo0ZHDE08wKshT-0
17
- ---
18
-
19
- # Avatar
20
-
21
- A reusable Avatar component that displays user profile pictures or initials.
22
- It's accessible, keyboard-navigable, and follows WCAG guidelines.
23
-
24
- ## Basic Usage
25
-
26
- Use the Avatar component to represent a user with either their profile picture
27
- or initials.
28
-
29
- ```jsx-live
30
- const App = () => (
31
- <Stack direction="horizontal">
32
- <Avatar firstName="John" lastName="Doe" src="https://thispersondoesnotexist.com/ " />
33
- <Avatar firstName="Jane" lastName="Smith" /> {/* Shows initials when no image */}
34
- </Stack>
35
- )
36
- ```
37
-
38
- ## Features
39
-
40
- ### Sizes
41
-
42
- Available in multiple sizes to suit different contexts:
43
-
44
- ```jsx-live
45
- const App = () => {
46
- const sizes = ["md", "xs", "2xs"];
47
-
48
- return (
49
- <Stack direction="horizontal" alignItems="center">
50
- {sizes.map(size => (
51
- <Avatar
52
- key={size}
53
- size={size}
54
- firstName="John"
55
- lastName="Doe"
56
- src="https://thispersondoesnotexist.com/ "
57
- />
58
- ))}
59
- </Stack>
60
- )
61
- }
62
- ```
63
-
64
- ### Fallback Behavior
65
-
66
- The component handles various scenarios gracefully:
67
-
68
- - Shows initials when no image is provided
69
-
70
- ```jsx-live
71
- const App = () => (
72
- <Stack direction="horizontal">
73
- <Avatar firstName="John" lastName="Doe"/> {/* Shows JD */}
74
- </Stack>
75
- )
76
- ```
77
-
78
- ## Props
79
-
80
- <PropTable id="Avatar" />
@@ -1,36 +0,0 @@
1
- import { defineRecipe } from "@chakra-ui/react";
2
-
3
- export const avatarRecipe = defineRecipe({
4
- className: "avatar",
5
- base: {
6
- display: "inline-flex",
7
- alignItems: "center",
8
- justifyContent: "center",
9
- verticalAlign: "middle",
10
- overflow: "hidden",
11
- userSelect: "none",
12
- borderRadius: "full",
13
- flexShrink: 0,
14
- fontWeight: "600",
15
- backgroundColor: "colorPalette.3",
16
- colorPalette: "primary",
17
- color: "colorPalette.11",
18
- focusVisibleRing: "outside",
19
- "button&": {
20
- cursor: "button",
21
- },
22
- _disabled: {
23
- layerStyle: "disabled",
24
- },
25
- },
26
- variants: {
27
- size: {
28
- md: { width: 1000, height: 1000, textStyle: "sm" },
29
- xs: { width: 800, height: 800, textStyle: "xs" },
30
- "2xs": { width: 600, height: 600, textStyle: "xs" },
31
- },
32
- },
33
- defaultVariants: {
34
- size: "md",
35
- },
36
- });
@@ -1,16 +0,0 @@
1
- import {
2
- type HTMLChakraProps,
3
- type RecipeProps,
4
- type UnstyledProp,
5
- createRecipeContext,
6
- } from "@chakra-ui/react";
7
- import { avatarRecipe } from "./avatar.recipe";
8
-
9
- interface AvatarRecipeProps extends RecipeProps<"div">, UnstyledProp {}
10
-
11
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
12
- export interface AvatarRootProps
13
- extends HTMLChakraProps<"div", AvatarRecipeProps> {}
14
- const { withContext } = createRecipeContext({ recipe: avatarRecipe });
15
-
16
- export const AvatarRoot = withContext<HTMLElement, AvatarRootProps>("figure");
@@ -1,136 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { Avatar } from "./avatar";
3
- import type { AvatarProps } from "./avatar.types";
4
- import { within, expect } from "@storybook/test";
5
- import { Button, Stack } from "@/components";
6
-
7
- /**
8
- * Storybook metadata configuration
9
- * - title: determines the location in the sidebar
10
- * - component: references the component being documented
11
- */
12
- const meta: Meta<typeof Avatar> = {
13
- title: "components/Avatar",
14
- component: Avatar,
15
- };
16
-
17
- export default meta;
18
- type Story = StoryObj<typeof Avatar>;
19
-
20
- const sizes: AvatarProps["size"][] = ["md", "xs", "2xs"];
21
-
22
- const colorPalettes: AvatarProps["colorPalette"][] = [
23
- "red",
24
- "green",
25
- "blue",
26
- "amber",
27
- ];
28
-
29
- const avatarImg = "https://thispersondoesnotexist.com/ ";
30
-
31
- export const Base: Story = {
32
- args: {
33
- src: avatarImg,
34
- ["aria-label"]: "avatar",
35
- alt: "avatar",
36
- },
37
- play: async ({ canvasElement, step }) => {
38
- const canvas = within(canvasElement);
39
- const avatar = canvas.getByLabelText("avatar");
40
-
41
- await step("Uses a <figure> element by default", async () => {
42
- await expect(avatar.tagName).toBe("FIGURE");
43
- });
44
- },
45
- };
46
-
47
- export const Sizes: Story = {
48
- args: {
49
- src: avatarImg,
50
- ["aria-label"]: "avatar",
51
- alt: "avatar",
52
- },
53
- render: (args) => {
54
- return (
55
- <Stack direction="row" gap="400" alignItems="center">
56
- {sizes.map((size) => (
57
- <Avatar key={size as string} {...args} size={size} alt="avatar" />
58
- ))}
59
- </Stack>
60
- );
61
- },
62
- };
63
-
64
- export const BaseWithInitials: Story = {
65
- args: {
66
- firstName: "John",
67
- lastName: "Doe",
68
- ["aria-label"]: "avatar",
69
- alt: "avatar",
70
- },
71
- play: async ({ canvasElement, step }) => {
72
- const canvas = within(canvasElement);
73
- const avatar = canvas.getByLabelText("avatar");
74
- await step(
75
- "Take first letters of first and last name to make initials",
76
- async () => {
77
- await expect(avatar).toHaveTextContent("JD");
78
- }
79
- );
80
- },
81
- };
82
-
83
- export const SizesWithInitials: Story = {
84
- args: {
85
- firstName: "Michael",
86
- lastName: "Douglas",
87
- ["aria-label"]: "avatar",
88
- alt: "avatar",
89
- },
90
- render: (args) => {
91
- return (
92
- <Stack direction="row" gap="400" alignItems="center">
93
- {sizes.map((size) => (
94
- <Avatar key={size as string} {...args} size={size} alt="avatar" />
95
- ))}
96
- </Stack>
97
- );
98
- },
99
- };
100
-
101
- export const Colors: Story = {
102
- args: {
103
- firstName: "Michael",
104
- lastName: "Douglas",
105
- ["aria-label"]: "avatar",
106
- alt: "avatar",
107
- },
108
- render: (args) => {
109
- return (
110
- <Stack direction="row" gap="400" alignItems="center">
111
- {colorPalettes.map((colorPalette) => (
112
- <Avatar
113
- key={colorPalette as string}
114
- {...args}
115
- colorPalette={colorPalette}
116
- alt="avatar"
117
- />
118
- ))}
119
- </Stack>
120
- );
121
- },
122
- };
123
-
124
- export const InAButton: Story = {
125
- args: {
126
- src: avatarImg,
127
- },
128
-
129
- render(args) {
130
- return (
131
- <Button unstyled asChild>
132
- <Avatar {...args} as="button" />
133
- </Button>
134
- );
135
- },
136
- };
@@ -1,34 +0,0 @@
1
- import { forwardRef } from "react";
2
- import { Image } from "@chakra-ui/react";
3
- import { type AvatarProps } from "./avatar.types";
4
- import { AvatarRoot } from "./avatar.slots.tsx";
5
-
6
- function getInitials(firstName: string, lastName: string) {
7
- return (
8
- firstName.split("")[0].toUpperCase() + lastName.split("")[0].toUpperCase()
9
- );
10
- }
11
-
12
- export const Avatar = forwardRef<HTMLDivElement, AvatarProps>((props, ref) => {
13
- const { firstName, lastName, src, alt, ...rest } = props;
14
-
15
- const fullName = `${firstName} ${lastName}`;
16
-
17
- const sharedProps = {
18
- "aria-label": `${fullName} avatar`,
19
- ref,
20
- ...rest,
21
- };
22
- return (
23
- <AvatarRoot {...sharedProps}>
24
- {src ? (
25
- // TODO: implement more robust error handling for image
26
- <Image src={src} alt={alt || fullName} />
27
- ) : (
28
- getInitials(firstName, lastName)
29
- )}
30
- </AvatarRoot>
31
- );
32
- });
33
-
34
- Avatar.displayName = "Avatar";
@@ -1,33 +0,0 @@
1
- import type { HTMLAttributes } from "react";
2
- import type { RecipeVariantProps } from "@chakra-ui/react";
3
- import { avatarRecipe } from "./avatar.recipe.tsx";
4
- import type { AvatarRootProps } from "./avatar.slots";
5
- export interface AvatarComponentProps
6
- extends HTMLAttributes<HTMLDivElement>,
7
- RecipeVariantProps<typeof avatarRecipe> {
8
- /**
9
- * The first name used to show initials
10
- */
11
- firstName: string;
12
- /**
13
- * The last name used to show initials
14
- */
15
- lastName: string;
16
- /**
17
- * The image URL
18
- */
19
- src?: string;
20
- /**
21
- * Alt text for the avatar image
22
- */
23
- alt?: string;
24
- /**
25
- * If the avatar is disabled
26
- */
27
- isDisabled?: boolean;
28
- }
29
-
30
- type FunctionalAvatarProps = AvatarRootProps & AvatarComponentProps;
31
- export interface AvatarProps extends FunctionalAvatarProps {
32
- children?: React.ReactNode;
33
- }
@@ -1,2 +0,0 @@
1
- export * from './avatar'
2
- export * from './avatar.types'