@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,48 +0,0 @@
1
- ---
2
- id: Components-tooltip
3
- title: Tooltip
4
- description:
5
- A contextual popup that displays a description for an element. See
6
- https://www.w3.org/TR/wai-aria-1.2/#tooltip
7
- documentState: InitialDraft
8
- order: 999
9
- menu:
10
- - Components
11
- - Media
12
- - Tooltip
13
- tags:
14
- - component
15
- - media
16
- ---
17
-
18
- # Tooltip
19
-
20
- A contextual popup that displays a description for an element.
21
-
22
- [React Aria Components Tooltip Documentation](https://react-spectrum.adobe.com/react-aria/Tooltip.html)
23
- [Tooltip Aria Pattern](https://www.w3.org/TR/wai-aria-1.2/#tooltip)
24
-
25
- ## Basic Usage
26
-
27
- All instances of `Tooltip` consist of two components, the `TooltipTrigger` and
28
- the `Tooltip`.
29
-
30
- The `TooltipTrigger` is required to wrap both the trigger element and the
31
- `Tooltip`.
32
-
33
- ```jsx-live
34
- const App = () => (
35
- <TooltipTrigger>
36
- <Button>Trigger Element</Button>
37
- <Tooltip>Tooltip</Tooltip>
38
- </TooltipTrigger>
39
- )
40
- ```
41
-
42
- ## Tooltip Trigger Props
43
-
44
- <PropTable id="TooltipTrigger" />
45
-
46
- ## Tooltip Props
47
-
48
- <PropTable id="Tooltip" />
@@ -1,26 +0,0 @@
1
- import { defineRecipe } from "@chakra-ui/react";
2
-
3
- /**
4
- * Recipe configuration for the Tooltip component.
5
- * Defines the styling variants and base styles using Chakra UI's recipe system.
6
- */
7
- export const tooltipRecipe = defineRecipe({
8
- // Unique class name prefix for the component
9
- className: "nimbus-tooltip",
10
-
11
- // Base styles applied to all instances of the component
12
- base: {
13
- color: "white",
14
- textStyle: "xs",
15
- fontWeight: "400",
16
- background: "slate.12",
17
- display: "inline-flex",
18
- alignItems: "center",
19
- borderRadius: "100",
20
- paddingX: "300",
21
- paddingY: "100",
22
- margin: "100",
23
- maxW: "6400",
24
- boxShadow: "1",
25
- },
26
- });
@@ -1,35 +0,0 @@
1
- import {
2
- type HTMLChakraProps,
3
- type RecipeProps,
4
- type UnstyledProp,
5
- createRecipeContext,
6
- } from "@chakra-ui/react";
7
-
8
- import { type TooltipProps as RATooltipProps } from "react-aria-components";
9
-
10
- import { tooltipRecipe } from "./tooltip.recipe";
11
-
12
- /**
13
- * Base recipe props interface that combines Chakra UI's recipe props
14
- */
15
- interface TooltipRecipeProps extends RecipeProps<"div">, UnstyledProp {}
16
-
17
- /**
18
- * Root props interface that extends Chakra's HTML props with our recipe props.
19
- * This creates a complete set of props for the root element, combining
20
- * HTML attributes, Chakra's styling system, and our custom recipe props.
21
- */
22
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
23
- export interface TooltipRootProps
24
- extends HTMLChakraProps<"div", TooltipRecipeProps> {}
25
-
26
- const { withContext } = createRecipeContext({ recipe: tooltipRecipe });
27
-
28
- /**
29
- * Root component that provides the styling context for the Tooltip component.
30
- * Uses Chakra UI's recipe context system for consistent styling across instances.
31
- */
32
- export const TooltipRoot = withContext<
33
- HTMLDivElement,
34
- TooltipRootProps & RATooltipProps
35
- >("div");
@@ -1,139 +0,0 @@
1
- import { createRef } from "react";
2
- import type { Meta, StoryObj } from "@storybook/react";
3
- import { within, expect } from "@storybook/test";
4
- import {
5
- Tooltip,
6
- TooltipTrigger,
7
- Button,
8
- Stack,
9
- type TooltipProps,
10
- } from "@/components";
11
-
12
- const placements = {
13
- top: ["top", "top left", "top right", "top start", "top end"],
14
- bottom: [
15
- "bottom",
16
- "bottom left",
17
- "bottom right",
18
- "bottom start",
19
- "bottom end",
20
- ],
21
- left: ["left", "left top", "left bottom"],
22
- right: ["right", "right top", "right bottom"],
23
- start: ["start", "start top", "start bottom"],
24
- end: ["end", "end top", "end bottom"],
25
- };
26
-
27
- const allPlacements = Object.values(placements).flatMap((x) => x);
28
-
29
- const meta: Meta<typeof Tooltip> = {
30
- title: "components/tooltip/Tooltip",
31
- component: Tooltip,
32
- argTypes: {
33
- placement: {
34
- options: allPlacements,
35
- control: { type: "select" },
36
- },
37
- },
38
- render: (args) => (
39
- <TooltipTrigger delay={0} closeDelay={0}>
40
- <Button>hover/focus me</Button>
41
- <Tooltip {...args} />
42
- </TooltipTrigger>
43
- ),
44
- };
45
-
46
- export default meta;
47
-
48
- /**
49
- * Story type for TypeScript support
50
- * StoryObj provides type checking for our story configurations
51
- */
52
- type Story = StoryObj<typeof Tooltip>;
53
-
54
- /**
55
- * Demonstrates the most basic implementation
56
- */
57
- const tooltipRef = createRef<HTMLDivElement>();
58
- export const Base: Story = {
59
- args: {
60
- children: "Demo Tooltip",
61
- ref: tooltipRef,
62
- },
63
- play: async ({ canvasElement, step }) => {
64
- // need to get the parent node in order to have the tooltip portal in scope
65
- const canvas = within(
66
- (canvasElement.parentNode as HTMLElement) ?? canvasElement
67
- );
68
-
69
- await step("it renders a tooltip with the proper text", async () => {
70
- const button = canvas.getByRole("button", { name: "hover/focus me" });
71
- button.click();
72
- button.focus();
73
- await canvas.findByRole("tooltip", {
74
- name: "Demo Tooltip",
75
- });
76
- });
77
- await step("it forwards a ref to the tooltip", async () => {
78
- const button = canvas.getByRole("button", { name: "hover/focus me" });
79
-
80
- button.focus();
81
- const tooltip = await canvas.findByRole("tooltip", {
82
- name: "Demo Tooltip",
83
- });
84
- await expect(tooltipRef.current).toBe(tooltip);
85
- });
86
- },
87
- };
88
-
89
- /**
90
- * Shows all possible placements
91
- */
92
- export const Placement: Story = {
93
- args: {},
94
- render: () => {
95
- return (
96
- <Stack
97
- direction="column"
98
- alignItems="start"
99
- marginY="1000"
100
- marginX="2000"
101
- >
102
- {Object.entries(placements).map(([type, values]) => (
103
- <Stack direction="row" alignItems="center" key={type} wrap="wrap">
104
- {values.map((placement) => (
105
- <TooltipTrigger key={placement} delay={0}>
106
- <Button w="200px" h="60px">
107
- {placement}
108
- </Button>
109
- <Tooltip placement={placement as TooltipProps["placement"]}>
110
- {placement}
111
- </Tooltip>
112
- </TooltipTrigger>
113
- ))}
114
- </Stack>
115
- ))}
116
- </Stack>
117
- );
118
- },
119
- play: async ({ canvasElement, step }) => {
120
- const canvas = within(
121
- (canvasElement.parentNode as HTMLElement) ?? canvasElement
122
- );
123
- for (const placement of allPlacements) {
124
- await step(`Implements ${placement} placement on focus`, async () => {
125
- const button = await canvas.findByRole("button", {
126
- name: placement,
127
- });
128
-
129
- button.focus();
130
-
131
- const tooltip = await canvas.findByRole("tooltip", {
132
- name: placement,
133
- });
134
-
135
- await expect(tooltip).toHaveTextContent(placement);
136
- });
137
- }
138
- },
139
- };
@@ -1,31 +0,0 @@
1
- import { forwardRef } from "react";
2
- import { Tooltip as RATooltip } from "react-aria-components";
3
- import { TooltipRoot } from "./tooltip.slots";
4
- import type { TooltipProps } from "./tooltip.types";
5
-
6
- /**
7
- * Tooltip
8
- * ============================================================
9
- * A contextual popup that displays a description for an element, uses `Tooltip` component from `react-aria-components`.
10
- *
11
- * Features:
12
- * - allows forwarding refs to the underlying DOM element
13
- * - accepts all native html 'HTMLDivElement' attributes (including aria- & data-attributes)
14
- * - allows overriding styles by using style-props
15
- *
16
- * Further Context:
17
- * - [React Aria Components Tooltip Documentation](https://react-spectrum.adobe.com/react-aria/Tooltip.html)
18
- * - [ARIA Tooltip Pattern](https://www.w3.org/TR/wai-aria-1.2/#tooltip)
19
- */
20
- export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
21
- function Tooltip({ children, placement = "bottom", ...props }, forwardedRef) {
22
- return (
23
- <TooltipRoot ref={forwardedRef} asChild {...props}>
24
- <RATooltip placement={placement} {...props}>
25
- {children}
26
- </RATooltip>
27
- </TooltipRoot>
28
- );
29
- }
30
- );
31
- Tooltip.displayName = "Tooltip";
@@ -1,44 +0,0 @@
1
- import type { PropsWithChildren } from "react";
2
- import type {
3
- TooltipProps as RATooltipProps,
4
- TooltipTriggerComponentProps,
5
- } from "react-aria-components";
6
- import type { TooltipRootProps } from "./tooltip.slots";
7
- import type { RecipeVariantProps } from "@chakra-ui/react";
8
- import { tooltipRecipe } from "./tooltip.recipe";
9
-
10
- /**
11
- * For use in components that use the polymorphic `as` and `asChild` props
12
- * internally, but do not make them available to the consumer.
13
- *
14
- * Long rambling background:
15
- * React-Aria's components cannot be configured to use `as` and `asChild` internally,
16
- * and cannot be directly styled by chakra's styledSystem. Therefore components
17
- * from `react-aria-components` should be wrapped in a chakra `withContext`
18
- * root component to set the styles onto the `r-a-c` component using `asChild`.
19
- * This means that we need to allow polymorphism internally, but should not
20
- * allow it in the external props api since it would not work.
21
- */
22
- type ExcludePolymorphicFromProps<T> = Omit<T, "as" | "asChild">;
23
-
24
- /**
25
- * Combines the root props with Chakra UI's recipe variant props, and
26
- * react-aria-component's TooltipProps
27
- * This allows the component to accept:
28
- * - structural props from Root
29
- * - styling variants from the recipe
30
- * - a11y/state related props from react-aria-components Tooltip
31
- */
32
- type TooltipVariantProps = ExcludePolymorphicFromProps<
33
- TooltipRootProps & RecipeVariantProps<typeof tooltipRecipe> & RATooltipProps
34
- >;
35
-
36
- /**
37
- * Main props interface for the Tooltip components
38
- * Extends TooltipVariantProps to include root props, variant props,
39
- * and react-aria props, while adding support for React children.
40
- */
41
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
42
- export interface TooltipProps extends PropsWithChildren<TooltipVariantProps> {}
43
- // eslint-disable-next-line @typescript-eslint/no-empty-object-type
44
- export interface TooltipTriggerProps extends TooltipTriggerComponentProps {}
@@ -1 +0,0 @@
1
- export * from "./visually-hidden";
@@ -1,61 +0,0 @@
1
- ---
2
- id: Components-VisuallyHidden
3
- title: VisuallyHidden
4
- description: makes content accessible to screen readers but hides it visually
5
- documentState: InitialDraft
6
- order: 999
7
- menu:
8
- - Components
9
- - Accessibility
10
- - VisuallyHidden
11
- tags:
12
- - component
13
- ---
14
-
15
- # VisuallyHidden
16
-
17
- Makes content accessible to screen readers but hides it visually.
18
-
19
- ## Basic Usage
20
-
21
- Just wrap the content you want to hide visually, but keep accessible to screen
22
- readers, with the `VisuallyHidden` component.
23
-
24
- ```jsx
25
- const App = () => <VisuallyHidden>I am VisuallyHidden!</VisuallyHidden>;
26
- ```
27
-
28
- ## Focusable Content
29
-
30
- If the content you want to hide visually contains focusable elements, add the
31
- `isFocusable` property to the `VisuallyHidden` component. The content then
32
- becomes visible if the first focusable element inside is focused with the
33
- _keyboard_.
34
-
35
- ```jsx-live
36
- const App = () => (
37
- <VisuallyHidden isFocusable>
38
- <Button>I can have focus</Button>
39
- </VisuallyHidden>
40
- );
41
- ```
42
-
43
- ## Inline Content
44
-
45
- `VisuallyHidden` uses a `<div>` element by default to render into the DOM. If
46
- you need to hide inline content, you can use the `as` prop to render a `<span>`
47
- element instead, keeping the `html` semantics intact.
48
-
49
- ```jsx-live
50
- const App = () => (
51
- <p>
52
- Text that will be visible.
53
- <VisuallyHidden as="span">I will blend just in.</VisuallyHidden>
54
- Text that will be visible.
55
- </p>
56
- );
57
- ```
58
-
59
- ## Props
60
-
61
- <PropTable id="VisuallyHidden" />
@@ -1,124 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/react";
2
- import { VisuallyHidden } from "./visually-hidden";
3
- import { Button } from "@/components";
4
- import { expect, userEvent, within } from "@storybook/test";
5
-
6
- // CSS property combination, that makes content invisible to the viewer
7
- const invisibleCssProps = {
8
- clip: "rect(0px, 0px, 0px, 0px)",
9
- clipPath: "inset(50%)",
10
- height: "1px",
11
- margin: "-1px",
12
- overflow: "hidden",
13
- padding: "0px",
14
- position: "absolute",
15
- width: "1px",
16
- whiteSpace: "nowrap",
17
- };
18
-
19
- /**
20
- * hides content from the viewers eye but keeps it visible to screen readers.
21
- * Makes it visible if focused.
22
- */
23
- const meta: Meta<typeof VisuallyHidden> = {
24
- title: "utils/VisuallyHidden",
25
- component: VisuallyHidden,
26
- };
27
-
28
- export default meta;
29
-
30
- /**
31
- * Story type for TypeScript support
32
- * StoryObj provides type checking for our story configurations
33
- */
34
- type Story = StoryObj<typeof VisuallyHidden>;
35
-
36
- /**
37
- * You should not see anything here, that's the whole purpose of this component.
38
- */
39
- export const Base: Story = {
40
- render: () => {
41
- return (
42
- <VisuallyHidden data-testid="container">
43
- <div data-testid="content">I should not be visible.</div>
44
- <Button data-testid="button" onClick={() => alert("meh")}>
45
- I should not be focusable.
46
- </Button>
47
- </VisuallyHidden>
48
- );
49
- },
50
- play: async ({ canvasElement, step }) => {
51
- const canvas = within(canvasElement);
52
- const container = canvas.getByTestId("container");
53
- const content = canvas.getByTestId("content");
54
- const button = canvas.getByTestId("button");
55
-
56
- await step("container is in the document, but invisible", async () => {
57
- await expect(container).toBeInTheDocument();
58
- await expect(container).toHaveStyle(invisibleCssProps);
59
- });
60
-
61
- await step("content is inside container", async () => {
62
- await expect(content.parentElement).toBe(container);
63
- });
64
-
65
- await step("button is focusable", async () => {
66
- await userEvent.tab();
67
- await expect(button).toHaveFocus();
68
- });
69
- },
70
- };
71
-
72
- /**
73
- * Use a `as="span"` if you want to hide inline-content visually.
74
- */
75
- export const SpanAsContainer: Story = {
76
- render: () => {
77
- return (
78
- <VisuallyHidden as="span" data-testid="container">
79
- <span data-testid="content">I am a span inside a span</span>
80
- </VisuallyHidden>
81
- );
82
- },
83
- play: async ({ canvasElement, step }) => {
84
- const canvas = within(canvasElement);
85
- const container = canvas.getByTestId("container");
86
- const content = canvas.getByTestId("content");
87
-
88
- await step("container uses a span element", async () => {
89
- await expect(content.parentElement).toBe(container);
90
- await expect(container.tagName).toBe("SPAN");
91
- });
92
- },
93
- };
94
-
95
- /**
96
- * `<VisuallyHidden/>` contains content that can be focused, but only if `isFocusable`
97
- * is set to true, it will become visible when focused
98
- */
99
- export const VisibleWhenFocused: Story = {
100
- render: () => {
101
- return (
102
- <VisuallyHidden data-testid="container" isFocusable>
103
- <Button data-testid="button">Skip Navigation</Button>
104
- </VisuallyHidden>
105
- );
106
- },
107
- play: async ({ canvasElement, step }) => {
108
- const canvas = within(canvasElement);
109
- const container = canvas.getByTestId("container");
110
- const button = canvas.getByTestId("button");
111
-
112
- await step("when button is focused, container is visible", async () => {
113
- await userEvent.tab();
114
- await expect(button).toHaveFocus();
115
-
116
- // Check for a subset of properties to make sure they are not applied
117
- const { height, width, clip, position } = invisibleCssProps;
118
- await expect(container).not.toHaveStyle({ clip });
119
- await expect(container).not.toHaveStyle({ position });
120
- await expect(container).not.toHaveStyle({ height });
121
- await expect(container).not.toHaveStyle({ width });
122
- });
123
- },
124
- };
@@ -1,18 +0,0 @@
1
- import {
2
- VisuallyHidden as ReactAriaViusallyHidden,
3
- type VisuallyHiddenProps as ReactAriaVisuallyHiddenProps,
4
- } from "react-aria";
5
-
6
- export interface VisuallyHiddenProps
7
- extends Omit<ReactAriaVisuallyHiddenProps, "elementType"> {
8
- /** specifies the element type to render, use `span` for inline content
9
- * and `div` for block content */
10
- as?: "span" | "div";
11
- }
12
-
13
- export const VisuallyHidden = (props: VisuallyHiddenProps) => {
14
- const { as = "div", ...leftoverProps } = props;
15
- return <ReactAriaViusallyHidden elementType={as} {...leftoverProps} />;
16
- };
17
-
18
- VisuallyHidden.displayName = "VisuallyHidden";
@@ -1,21 +0,0 @@
1
- ---
2
- id: Components-Accessibility
3
- title: Accessibility
4
- description: Components designed to enhance accessibility and ARIA compliance.
5
- documentState: InitialDraft
6
- order: 11
7
- menu:
8
- - Components
9
- - Accessibility
10
- tags:
11
- - document
12
- icon: Blind
13
- ---
14
-
15
- # Accessibility
16
-
17
- Components designed to enhance accessibility and ARIA compliance.
18
-
19
- - **Screen Reader Aids**: e.g., VisuallyHidden, AccessibleLabel.
20
- - **Keyboard Navigation**: e.g., FocusTrap, SkipLink.
21
- - **ARIA Enhancers**: e.g., AriaLiveRegion.