@commercetools/nimbus 0.0.1 → 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.
- package/dist/index.d.ts +1412 -0
- package/dist/index.js +11183 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.cjs +27 -0
- package/dist/index.umd.cjs.map +1 -0
- package/package.json +33 -6
- package/.storybook/apca-check/index.ts +0 -150
- package/.storybook/main.ts +0 -64
- package/.storybook/preview.tsx +0 -92
- package/.storybook/vitest.setup.ts +0 -13
- package/docs/architecture-decisions/adr-0001-consumer-component-apis.md +0 -177
- package/docs/architecture-decisions/adr-0002-compound-component-extraction.md +0 -82
- package/src/components/accordion/accordion-context.tsx +0 -17
- package/src/components/accordion/accordion.mdx +0 -172
- package/src/components/accordion/accordion.recipe.tsx +0 -98
- package/src/components/accordion/accordion.slots.tsx +0 -39
- package/src/components/accordion/accordion.stories.tsx +0 -188
- package/src/components/accordion/accordion.tsx +0 -16
- package/src/components/accordion/accordion.types.tsx +0 -54
- package/src/components/accordion/components/accordion-content.tsx +0 -28
- package/src/components/accordion/components/accordion-group.tsx +0 -27
- package/src/components/accordion/components/accordion-header.tsx +0 -63
- package/src/components/accordion/components/accordion-item.tsx +0 -87
- package/src/components/accordion/index.ts +0 -2
- package/src/components/alert/alert.mdx +0 -92
- package/src/components/alert/alert.recipe.tsx +0 -65
- package/src/components/alert/alert.slots.tsx +0 -46
- package/src/components/alert/alert.stories.tsx +0 -308
- package/src/components/alert/alert.tsx +0 -18
- package/src/components/alert/alert.types.tsx +0 -70
- package/src/components/alert/components/alert.actions.tsx +0 -27
- package/src/components/alert/components/alert.description.tsx +0 -27
- package/src/components/alert/components/alert.dismiss-button.tsx +0 -41
- package/src/components/alert/components/alert.root.tsx +0 -92
- package/src/components/alert/components/alert.title.tsx +0 -29
- package/src/components/alert/index.ts +0 -2
- package/src/components/avatar/avatar.mdx +0 -80
- package/src/components/avatar/avatar.recipe.tsx +0 -36
- package/src/components/avatar/avatar.slots.tsx +0 -16
- package/src/components/avatar/avatar.stories.tsx +0 -136
- package/src/components/avatar/avatar.tsx +0 -34
- package/src/components/avatar/avatar.types.ts +0 -33
- package/src/components/avatar/index.ts +0 -2
- package/src/components/badge/badge.mdx +0 -91
- package/src/components/badge/badge.recipe.tsx +0 -72
- package/src/components/badge/badge.slots.tsx +0 -8
- package/src/components/badge/badge.stories.tsx +0 -124
- package/src/components/badge/badge.tsx +0 -35
- package/src/components/badge/badge.types.tsx +0 -40
- package/src/components/badge/index.ts +0 -2
- package/src/components/bleed/bleed.tsx +0 -1
- package/src/components/bleed/index.ts +0 -1
- package/src/components/box/box.mdx +0 -115
- package/src/components/box/box.stories.tsx +0 -71
- package/src/components/box/box.tsx +0 -11
- package/src/components/box/index.ts +0 -1
- package/src/components/button/button.mdx +0 -169
- package/src/components/button/button.recipe.ts +0 -185
- package/src/components/button/button.slots.tsx +0 -45
- package/src/components/button/button.stories.tsx +0 -369
- package/src/components/button/button.tsx +0 -37
- package/src/components/button/button.types.ts +0 -14
- package/src/components/button/index.ts +0 -2
- package/src/components/card/card.mdx +0 -92
- package/src/components/card/card.recipe.tsx +0 -71
- package/src/components/card/card.slots.tsx +0 -50
- package/src/components/card/card.stories.tsx +0 -175
- package/src/components/card/card.tsx +0 -9
- package/src/components/card/card.types.ts +0 -22
- package/src/components/card/components/card.content.tsx +0 -29
- package/src/components/card/components/card.header.tsx +0 -28
- package/src/components/card/components/card.root.tsx +0 -62
- package/src/components/card/index.ts +0 -2
- package/src/components/checkbox/checkbox.mdx +0 -78
- package/src/components/checkbox/checkbox.recipe.tsx +0 -116
- package/src/components/checkbox/checkbox.slots.tsx +0 -33
- package/src/components/checkbox/checkbox.stories.tsx +0 -200
- package/src/components/checkbox/checkbox.tsx +0 -77
- package/src/components/checkbox/checkbox.types.tsx +0 -22
- package/src/components/checkbox/index.ts +0 -2
- package/src/components/code/code.mdx +0 -17
- package/src/components/code/code.recipe.ts +0 -63
- package/src/components/code/code.tsx +0 -1
- package/src/components/code/index.ts +0 -1
- package/src/components/dialog/dialog.mdx +0 -20
- package/src/components/dialog/dialog.recipe.ts +0 -254
- package/src/components/dialog/dialog.tsx +0 -61
- package/src/components/dialog/index.ts +0 -1
- package/src/components/em/em.mdx +0 -17
- package/src/components/em/em.tsx +0 -1
- package/src/components/em/index.ts +0 -1
- package/src/components/flex/flex.mdx +0 -41
- package/src/components/flex/flex.tsx +0 -1
- package/src/components/flex/index.ts +0 -1
- package/src/components/grid/grid.mdx +0 -156
- package/src/components/grid/grid.stories.tsx +0 -151
- package/src/components/grid/grid.tsx +0 -29
- package/src/components/grid/index.ts +0 -1
- package/src/components/heading/heading.mdx +0 -23
- package/src/components/heading/heading.recipe.ts +0 -49
- package/src/components/heading/heading.tsx +0 -1
- package/src/components/heading/index.ts +0 -1
- package/src/components/highlight/highlight.mdx +0 -18
- package/src/components/highlight/highlight.tsx +0 -1
- package/src/components/highlight/index.ts +0 -1
- package/src/components/icon-button/icon-button.mdx +0 -98
- package/src/components/icon-button/icon-button.stories.tsx +0 -188
- package/src/components/icon-button/icon-button.tsx +0 -21
- package/src/components/icon-button/icon-button.types.tsx +0 -10
- package/src/components/icon-button/index.ts +0 -2
- package/src/components/index.ts +0 -33
- package/src/components/input/index.ts +0 -1
- package/src/components/input/input.mdx +0 -20
- package/src/components/input/input.recipe.ts +0 -95
- package/src/components/input/input.tsx +0 -1
- package/src/components/input-group/index.ts +0 -1
- package/src/components/input-group/input-group.mdx +0 -20
- package/src/components/input-group/input-group.tsx +0 -44
- package/src/components/kbd/index.ts +0 -1
- package/src/components/kbd/kbd.mdx +0 -18
- package/src/components/kbd/kbd.recipe.ts +0 -57
- package/src/components/kbd/kbd.tsx +0 -1
- package/src/components/link/index.ts +0 -2
- package/src/components/link/link.mdx +0 -77
- package/src/components/link/link.recipe.ts +0 -52
- package/src/components/link/link.slots.tsx +0 -29
- package/src/components/link/link.stories.tsx +0 -204
- package/src/components/link/link.tsx +0 -38
- package/src/components/link/link.types.tsx +0 -26
- package/src/components/list/index.ts +0 -1
- package/src/components/list/list.mdx +0 -18
- package/src/components/list/list.recipe.ts +0 -68
- package/src/components/list/list.tsx +0 -9
- package/src/components/loading-spinner/index.ts +0 -2
- package/src/components/loading-spinner/loading-spinner.mdx +0 -92
- package/src/components/loading-spinner/loading-spinner.recipe.tsx +0 -70
- package/src/components/loading-spinner/loading-spinner.slots.tsx +0 -38
- package/src/components/loading-spinner/loading-spinner.stories.tsx +0 -97
- package/src/components/loading-spinner/loading-spinner.tsx +0 -50
- package/src/components/loading-spinner/loading-spinner.types.tsx +0 -21
- package/src/components/nimbus-provider/color-mode.tsx +0 -32
- package/src/components/nimbus-provider/index.ts +0 -2
- package/src/components/nimbus-provider/nimbus-provider.mdx +0 -21
- package/src/components/nimbus-provider/nimbus-provider.tsx +0 -51
- package/src/components/select/components/select.clear-button.tsx +0 -31
- package/src/components/select/components/select.option-group.tsx +0 -48
- package/src/components/select/components/select.option.tsx +0 -21
- package/src/components/select/components/select.options.tsx +0 -23
- package/src/components/select/components/select.root.tsx +0 -81
- package/src/components/select/index.ts +0 -2
- package/src/components/select/select.mdx +0 -170
- package/src/components/select/select.recipe.tsx +0 -216
- package/src/components/select/select.slots.tsx +0 -58
- package/src/components/select/select.stories.tsx +0 -841
- package/src/components/select/select.tsx +0 -18
- package/src/components/select/select.types.tsx +0 -37
- package/src/components/simple-grid/index.ts +0 -1
- package/src/components/simple-grid/simple-grid.mdx +0 -133
- package/src/components/simple-grid/simple-grid.stories.tsx +0 -143
- package/src/components/simple-grid/simple-grid.tsx +0 -31
- package/src/components/stack/index.ts +0 -1
- package/src/components/stack/stack.mdx +0 -88
- package/src/components/stack/stack.stories.tsx +0 -82
- package/src/components/stack/stack.tsx +0 -15
- package/src/components/table/index.ts +0 -1
- package/src/components/table/table.mdx +0 -23
- package/src/components/table/table.recipe.ts +0 -170
- package/src/components/table/table.tsx +0 -43
- package/src/components/text/index.ts +0 -1
- package/src/components/text/text.mdx +0 -244
- package/src/components/text/text.tsx +0 -23
- package/src/components/text-input/index.ts +0 -2
- package/src/components/text-input/text-input.mdx +0 -118
- package/src/components/text-input/text-input.recipe.tsx +0 -68
- package/src/components/text-input/text-input.slots.tsx +0 -24
- package/src/components/text-input/text-input.stories.tsx +0 -282
- package/src/components/text-input/text-input.tsx +0 -39
- package/src/components/text-input/text-input.types.ts +0 -7
- package/src/components/toggle-button-group/components/toggle-button-group.button.tsx +0 -14
- package/src/components/toggle-button-group/components/toggle-button-group.root.tsx +0 -15
- package/src/components/toggle-button-group/index.ts +0 -2
- package/src/components/toggle-button-group/toggle-button-group.mdx +0 -94
- package/src/components/toggle-button-group/toggle-button-group.recipe.tsx +0 -64
- package/src/components/toggle-button-group/toggle-button-group.slots.tsx +0 -26
- package/src/components/toggle-button-group/toggle-button-group.stories.tsx +0 -311
- package/src/components/toggle-button-group/toggle-button-group.tsx +0 -12
- package/src/components/toggle-button-group/toggle-button-group.types.tsx +0 -62
- package/src/components/tooltip/index.ts +0 -4
- package/src/components/tooltip/make-element-focusable.stories.tsx +0 -56
- package/src/components/tooltip/make-element-focusable.tsx +0 -57
- package/src/components/tooltip/tooltip-trigger.stories.tsx +0 -157
- package/src/components/tooltip/tooltip-trigger.tsx +0 -15
- package/src/components/tooltip/tooltip.mdx +0 -48
- package/src/components/tooltip/tooltip.recipe.ts +0 -26
- package/src/components/tooltip/tooltip.slots.ts +0 -35
- package/src/components/tooltip/tooltip.stories.tsx +0 -139
- package/src/components/tooltip/tooltip.tsx +0 -31
- package/src/components/tooltip/tooltip.types.ts +0 -44
- package/src/components/visually-hidden/index.ts +0 -1
- package/src/components/visually-hidden/visually-hidden.mdx +0 -61
- package/src/components/visually-hidden/visually-hidden.stories.tsx +0 -124
- package/src/components/visually-hidden/visually-hidden.tsx +0 -18
- package/src/docs/accessibility.mdx +0 -21
- package/src/docs/background.mdx +0 -154
- package/src/docs/border.mdx +0 -226
- package/src/docs/changelog.mdx +0 -17
- package/src/docs/components-layout.mdx +0 -22
- package/src/docs/components.mdx +0 -17
- package/src/docs/data-display.mdx +0 -23
- package/src/docs/display.mdx +0 -55
- package/src/docs/effects.mdx +0 -73
- package/src/docs/feedback.mdx +0 -22
- package/src/docs/filters.mdx +0 -268
- package/src/docs/flex-and-grid.mdx +0 -445
- package/src/docs/forms.mdx +0 -22
- package/src/docs/generated/index.mdx +0 -16
- package/src/docs/getting-started.mdx +0 -17
- package/src/docs/home.mdx +0 -56
- package/src/docs/hooks.mdx +0 -16
- package/src/docs/inputs.mdx +0 -21
- package/src/docs/installation.mdx +0 -60
- package/src/docs/interactivity.mdx +0 -278
- package/src/docs/known-issues.mdx +0 -19
- package/src/docs/layout.mdx +0 -301
- package/src/docs/list.mdx +0 -82
- package/src/docs/markdown.mdx +0 -234
- package/src/docs/media.mdx +0 -22
- package/src/docs/naivgation.mdx +0 -22
- package/src/docs/playground.mdx +0 -16
- package/src/docs/rfcs-component-structure-rfcs.mdx +0 -17
- package/src/docs/rfcs-component-structure.mdx +0 -74
- package/src/docs/rfcs-hook-structure.mdx +0 -59
- package/src/docs/sizing.mdx +0 -210
- package/src/docs/spacing.mdx +0 -193
- package/src/docs/style-props-typography.mdx +0 -373
- package/src/docs/style-props.mdx +0 -15
- package/src/docs/svg.mdx +0 -58
- package/src/docs/tables.mdx +0 -95
- package/src/docs/toc.mdx +0 -39
- package/src/docs/tokens/animations.mdx +0 -68
- package/src/docs/tokens/aspect-ratios.mdx +0 -21
- package/src/docs/tokens/blurs.mdx +0 -20
- package/src/docs/tokens/borders.mdx +0 -25
- package/src/docs/tokens/breakpoints.mdx +0 -35
- package/src/docs/tokens/colors.mdx +0 -86
- package/src/docs/tokens/cursors.mdx +0 -21
- package/src/docs/tokens/radii.mdx +0 -23
- package/src/docs/tokens/shadows.mdx +0 -21
- package/src/docs/tokens/sizes.mdx +0 -54
- package/src/docs/tokens/spacing.mdx +0 -35
- package/src/docs/tokens/typography.mdx +0 -61
- package/src/docs/tokens/z-indices.mdx +0 -23
- package/src/docs/tokens-other.mdx +0 -17
- package/src/docs/tokens.mdx +0 -16
- package/src/docs/transforms.mdx +0 -150
- package/src/docs/transitions.mdx +0 -164
- package/src/docs/typography.mdx +0 -17
- package/src/docs/utilities.mdx +0 -17
- package/src/hooks/index.ts +0 -2
- package/src/hooks/use-copy-to-clipboard/use-copy-to-clipboard.mdx +0 -54
- package/src/hooks/use-copy-to-clipboard/use-copy-to-clipboard.ts +0 -1
- package/src/hooks/use-hotkeys/use-hotkeys.mdx +0 -48
- package/src/hooks/use-hotkeys/use-hotkeys.stories.tsx +0 -69
- package/src/hooks/use-hotkeys/use-hotkeys.ts +0 -1
- package/src/index.ts +0 -3
- package/src/test/utils.tsx +0 -20
- package/src/theme/animation-styles.ts +0 -52
- package/src/theme/breakpoints.ts +0 -32
- package/src/theme/global-css.ts +0 -53
- package/src/theme/index.ts +0 -35
- package/src/theme/keyframes.ts +0 -192
- package/src/theme/layer-styles.ts +0 -12
- package/src/theme/recipes/index.ts +0 -21
- package/src/theme/semantic-tokens/colors.ts +0 -55
- package/src/theme/semantic-tokens/index.ts +0 -9
- package/src/theme/semantic-tokens/radii.ts +0 -3
- package/src/theme/semantic-tokens/shadows.ts +0 -4
- package/src/theme/slot-recipes/index.ts +0 -15
- package/src/theme/text-styles.ts +0 -8
- package/src/theme/tokens/animations.ts +0 -4
- package/src/theme/tokens/aspect-ratios.ts +0 -5
- package/src/theme/tokens/blurs.ts +0 -5
- package/src/theme/tokens/borders.ts +0 -4
- package/src/theme/tokens/colors.ts +0 -8
- package/src/theme/tokens/cursor.ts +0 -4
- package/src/theme/tokens/durations.ts +0 -4
- package/src/theme/tokens/easings.ts +0 -4
- package/src/theme/tokens/font-sizes.ts +0 -4
- package/src/theme/tokens/font-weights.ts +0 -4
- package/src/theme/tokens/fonts.ts +0 -4
- package/src/theme/tokens/index.ts +0 -57
- package/src/theme/tokens/letter-spacings.ts +0 -24
- package/src/theme/tokens/line-heights.ts +0 -4
- package/src/theme/tokens/radii.ts +0 -4
- package/src/theme/tokens/sizes.ts +0 -120
- package/src/theme/tokens/spacing.ts +0 -4
- package/src/theme/tokens/z-index.ts +0 -4
- package/src/utils/extractStyleProps.ts +0 -26
- package/src/utils/fixedForwardRef.ts +0 -17
- package/tsconfig.json +0 -38
- package/vite.config.ts +0 -54
- package/vitest.config.ts +0 -50
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: Components-LoadingSpinner
|
|
3
|
-
title: LoadingSpinner
|
|
4
|
-
description: Indicates ongoing processes or loading states
|
|
5
|
-
documentState: InitialDraft
|
|
6
|
-
order: 999
|
|
7
|
-
menu:
|
|
8
|
-
- Components
|
|
9
|
-
- LoadingSpinner
|
|
10
|
-
tags:
|
|
11
|
-
- component
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
# LoadingSpinner
|
|
15
|
-
|
|
16
|
-
Indicates ongoing processes or loading states
|
|
17
|
-
|
|
18
|
-
## Basic Usage
|
|
19
|
-
|
|
20
|
-
[Explain the basic usage / usecase of the component].
|
|
21
|
-
|
|
22
|
-
```jsx-live
|
|
23
|
-
const App = () => <LoadingSpinner>I am LoadingSpinner!</LoadingSpinner>
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
### Sizes
|
|
28
|
-
|
|
29
|
-
Available sizes.
|
|
30
|
-
|
|
31
|
-
```jsx-live
|
|
32
|
-
const App = () => {
|
|
33
|
-
|
|
34
|
-
const sizes = ['2xl', 'xl', 'lg', 'md', 'sm', 'xs', '2xs'];
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<Stack direction="horizontal" alignItems="center">
|
|
38
|
-
{sizes.map(size => (
|
|
39
|
-
<LoadingSpinner key={size} size={size}>'{size}' LoadingSpinner</LoadingSpinner>
|
|
40
|
-
))}
|
|
41
|
-
</Stack>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Variants
|
|
47
|
-
|
|
48
|
-
Available variants.
|
|
49
|
-
|
|
50
|
-
```jsx-live
|
|
51
|
-
const App = () => {
|
|
52
|
-
|
|
53
|
-
const variants = ['solid', 'subtle', 'outline', 'ghost', 'plain'];
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<Stack direction="horizontal">
|
|
57
|
-
{variants.map(variant => (
|
|
58
|
-
<LoadingSpinner key={variant} variant={variant}>'{variant}' LoadingSpinner</LoadingSpinner>
|
|
59
|
-
))}
|
|
60
|
-
</Stack>
|
|
61
|
-
)
|
|
62
|
-
}
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Colors
|
|
66
|
-
|
|
67
|
-
[Explain usage with different colors/semantics.]
|
|
68
|
-
|
|
69
|
-
```jsx-live
|
|
70
|
-
const App = () => {
|
|
71
|
-
const variants = ["solid", "subtle", "outline", "ghost", "link", "plain"];
|
|
72
|
-
const colors = ["neutral", "primary", "info", "success", "danger", "error"];
|
|
73
|
-
|
|
74
|
-
return (
|
|
75
|
-
<Stack>
|
|
76
|
-
{colors.map((color) => (
|
|
77
|
-
<Stack key={color} direction="horizontal">
|
|
78
|
-
{variants.map((variant) => (
|
|
79
|
-
<LoadingSpinner colorPalette={color} key={variant} variant={variant}>
|
|
80
|
-
'{variant}' LoadingSpinner
|
|
81
|
-
</LoadingSpinner>
|
|
82
|
-
))}
|
|
83
|
-
</Stack>
|
|
84
|
-
))}
|
|
85
|
-
</Stack>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Props
|
|
91
|
-
|
|
92
|
-
<PropTable id="LoadingSpinner" />
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { defineRecipe } from "@chakra-ui/react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Recipe configuration for the LoadingSpinner component.
|
|
5
|
-
* Defines the styling variants and base styles using Chakra UI's recipe system.
|
|
6
|
-
*/
|
|
7
|
-
export const loadingSpinnerRecipe = defineRecipe({
|
|
8
|
-
className: "nimbus-loading-spinner",
|
|
9
|
-
|
|
10
|
-
base: {
|
|
11
|
-
display: "inline-flex",
|
|
12
|
-
alignItems: "center",
|
|
13
|
-
justifyContent: "center",
|
|
14
|
-
"& svg": {
|
|
15
|
-
overflow: "visible",
|
|
16
|
-
// This proportionally scales the spinner to fit the container while also scaling padding
|
|
17
|
-
transform: "scale(calc(1 - 2/12))",
|
|
18
|
-
},
|
|
19
|
-
"& svg [data-svg-path='spinner-pointer']": {
|
|
20
|
-
stroke: "colorPalette.10",
|
|
21
|
-
animationName: "spin",
|
|
22
|
-
animationDuration: "0.5s",
|
|
23
|
-
animationTimingFunction: "linear",
|
|
24
|
-
animationIterationCount: "infinite",
|
|
25
|
-
transformOrigin: "center center 0",
|
|
26
|
-
},
|
|
27
|
-
"& svg [data-svg-path='spinner-circle']": {
|
|
28
|
-
stroke: "colorPalette.5",
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
variants: {
|
|
33
|
-
size: {
|
|
34
|
-
"2xs": {
|
|
35
|
-
width: "350",
|
|
36
|
-
height: "350",
|
|
37
|
-
},
|
|
38
|
-
xs: {
|
|
39
|
-
width: "500",
|
|
40
|
-
height: "500",
|
|
41
|
-
},
|
|
42
|
-
sm: {
|
|
43
|
-
width: "600",
|
|
44
|
-
height: "600",
|
|
45
|
-
},
|
|
46
|
-
md: {
|
|
47
|
-
width: "800",
|
|
48
|
-
height: "800",
|
|
49
|
-
},
|
|
50
|
-
lg: {
|
|
51
|
-
width: "1000",
|
|
52
|
-
height: "1000",
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
|
|
56
|
-
tone: {
|
|
57
|
-
primary: {
|
|
58
|
-
colorPalette: "ctvioletAlpha",
|
|
59
|
-
},
|
|
60
|
-
white: {
|
|
61
|
-
colorPalette: "whiteAlpha",
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
defaultVariants: {
|
|
67
|
-
size: "sm",
|
|
68
|
-
tone: "primary",
|
|
69
|
-
},
|
|
70
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type HTMLChakraProps,
|
|
3
|
-
type RecipeProps,
|
|
4
|
-
type UnstyledProp,
|
|
5
|
-
createRecipeContext,
|
|
6
|
-
} from "@chakra-ui/react";
|
|
7
|
-
|
|
8
|
-
import { loadingSpinnerRecipe } from "./loading-spinner.recipe";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Base recipe props interface that combines Chakra UI's recipe props
|
|
12
|
-
* with the unstyled prop option for the div element.
|
|
13
|
-
*/
|
|
14
|
-
export interface LoadingSpinnerRecipeProps
|
|
15
|
-
extends RecipeProps<"div">,
|
|
16
|
-
UnstyledProp {}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Root props interface that extends Chakra's HTML props with our recipe props.
|
|
20
|
-
* This creates a complete set of props for the root element, combining
|
|
21
|
-
* HTML attributes, Chakra's styling system, and our custom recipe props.
|
|
22
|
-
*/
|
|
23
|
-
export type LoadingSpinnerRootProps = Omit<
|
|
24
|
-
HTMLChakraProps<"div", LoadingSpinnerRecipeProps>,
|
|
25
|
-
// We want to omit polymorphic props from the root props since they are not used internally.
|
|
26
|
-
"as" | "asChild"
|
|
27
|
-
>;
|
|
28
|
-
|
|
29
|
-
const { withContext } = createRecipeContext({ recipe: loadingSpinnerRecipe });
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Root component that provides the styling context for the LoadingSpinner component.
|
|
33
|
-
* Uses Chakra UI's recipe context system for consistent styling across instances.
|
|
34
|
-
*/
|
|
35
|
-
export const LoadingSpinnerRoot = withContext<
|
|
36
|
-
HTMLDivElement,
|
|
37
|
-
LoadingSpinnerRootProps
|
|
38
|
-
>("div");
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { LoadingSpinner } from "./loading-spinner";
|
|
3
|
-
import { Stack } from "./../stack";
|
|
4
|
-
import type { LoadingSpinnerProps } from "./loading-spinner.types";
|
|
5
|
-
import { within, expect } from "@storybook/test";
|
|
6
|
-
import { Box } from "@chakra-ui/react";
|
|
7
|
-
|
|
8
|
-
const sizes: LoadingSpinnerProps["size"][] = ["lg", "md", "sm", "xs", "2xs"];
|
|
9
|
-
|
|
10
|
-
const tones: LoadingSpinnerProps["tone"][] = ["primary", "white"];
|
|
11
|
-
|
|
12
|
-
const meta: Meta<typeof LoadingSpinner> = {
|
|
13
|
-
title: "components/LoadingSpinner",
|
|
14
|
-
component: LoadingSpinner,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export default meta;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Story type for TypeScript support
|
|
21
|
-
* StoryObj provides type checking for our story configurations
|
|
22
|
-
*/
|
|
23
|
-
type Story = StoryObj<typeof LoadingSpinner>;
|
|
24
|
-
|
|
25
|
-
export const Base: Story = {
|
|
26
|
-
args: {
|
|
27
|
-
"data-testid": "spinner-test",
|
|
28
|
-
},
|
|
29
|
-
play: async ({ canvasElement, step }) => {
|
|
30
|
-
const canvas = within(canvasElement);
|
|
31
|
-
const spinner = canvas.getByTestId("spinner-test");
|
|
32
|
-
|
|
33
|
-
await step("Uses a <div> wrapper by default", async () => {
|
|
34
|
-
await expect(spinner.tagName).toBe("DIV");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
await step("Has ARIA role='progressbar'", async () => {
|
|
38
|
-
await expect(spinner).toHaveAttribute("role", "progressbar");
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
await step("Has an accessible label", async () => {
|
|
42
|
-
await expect(spinner).toHaveAttribute("aria-label", "Loading data");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
await step("Has default aria-label", async () => {
|
|
46
|
-
await expect(spinner.ariaLabel).toBe("Loading data");
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const Sizes: Story = {
|
|
52
|
-
render: (args) => {
|
|
53
|
-
return (
|
|
54
|
-
<Stack direction="row" gap="400" alignItems="center">
|
|
55
|
-
{sizes.map((size) => (
|
|
56
|
-
<LoadingSpinner key={size as string} {...args} size={size} />
|
|
57
|
-
))}
|
|
58
|
-
</Stack>
|
|
59
|
-
);
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
args: {},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* One tone for a light background and one for a dark background
|
|
67
|
-
*/
|
|
68
|
-
export const Tones: Story = {
|
|
69
|
-
render: (args) => {
|
|
70
|
-
return (
|
|
71
|
-
<Box backgroundColor="blackAlpha.5">
|
|
72
|
-
<Stack direction="row" gap="400" alignItems="center">
|
|
73
|
-
{tones.map((tone) => (
|
|
74
|
-
<LoadingSpinner
|
|
75
|
-
aria-label="Loading even more data"
|
|
76
|
-
key={tone as string}
|
|
77
|
-
{...args}
|
|
78
|
-
tone={tone}
|
|
79
|
-
/>
|
|
80
|
-
))}
|
|
81
|
-
</Stack>
|
|
82
|
-
</Box>
|
|
83
|
-
);
|
|
84
|
-
},
|
|
85
|
-
|
|
86
|
-
args: {
|
|
87
|
-
"data-testid": "spinner-test",
|
|
88
|
-
},
|
|
89
|
-
play: async ({ canvasElement, step }) => {
|
|
90
|
-
const canvas = within(canvasElement);
|
|
91
|
-
const spinner = canvas.getAllByTestId("spinner-test");
|
|
92
|
-
|
|
93
|
-
await step("Forwards aria-label", async () => {
|
|
94
|
-
await expect(spinner[0].ariaLabel).toBe("Loading even more data");
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from "react";
|
|
2
|
-
import { LoadingSpinnerRoot } from "./loading-spinner.slots";
|
|
3
|
-
import type { LoadingSpinnerProps } from "./loading-spinner.types";
|
|
4
|
-
import { mergeProps, useProgressBar } from "react-aria";
|
|
5
|
-
|
|
6
|
-
const circlePath =
|
|
7
|
-
"M22.5 12C22.5 13.3789 22.2284 14.7443 21.7007 16.0182C21.1731 17.2921 20.3996 18.4496 19.4246 19.4246C18.4496 20.3996 17.2921 21.1731 16.0182 21.7007C14.7443 22.2284 13.3789 22.5 12 22.5C10.6211 22.5 9.25574 22.2284 7.98182 21.7007C6.7079 21.1731 5.55039 20.3996 4.57538 19.4246C3.60036 18.4496 2.82694 17.2921 2.29926 16.0182C1.77159 14.7443 1.5 13.3789 1.5 12C1.5 10.6211 1.77159 9.25574 2.29927 7.98182C2.82694 6.7079 3.60037 5.55039 4.57538 4.57538C5.5504 3.60036 6.70791 2.82694 7.98183 2.29926C9.25575 1.77159 10.6211 1.5 12 1.5C13.3789 1.5 14.7443 1.77159 16.0182 2.29927C17.2921 2.82694 18.4496 3.60037 19.4246 4.57538C20.3996 5.5504 21.1731 6.70791 21.7007 7.98183C22.2284 9.25575 22.5 10.6211 22.5 12L22.5 12Z";
|
|
8
|
-
const pointerPath =
|
|
9
|
-
"M12 1.5C13.3789 1.5 14.7443 1.77159 16.0182 2.29927C17.2921 2.82694 18.4496 3.60036 19.4246 4.57538C20.3996 5.55039 21.1731 6.70791 21.7007 7.98183C22.2284 9.25574 22.5 10.6211 22.5 12";
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* LoadingSpinner
|
|
13
|
-
* ============================================================
|
|
14
|
-
* Indicates ongoing processes or loading states
|
|
15
|
-
*/
|
|
16
|
-
export const LoadingSpinner = forwardRef<HTMLDivElement, LoadingSpinnerProps>(
|
|
17
|
-
({ "aria-label": ariaLabel = "Loading data", ...props }, ref) => {
|
|
18
|
-
const { progressBarProps } = useProgressBar({
|
|
19
|
-
isIndeterminate: true,
|
|
20
|
-
"aria-label": ariaLabel,
|
|
21
|
-
...props,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<LoadingSpinnerRoot
|
|
26
|
-
ref={ref}
|
|
27
|
-
{...mergeProps(props, progressBarProps)}
|
|
28
|
-
aria-label={ariaLabel}
|
|
29
|
-
>
|
|
30
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
|
|
31
|
-
<path
|
|
32
|
-
d={circlePath}
|
|
33
|
-
data-svg-path="spinner-circle"
|
|
34
|
-
strokeWidth="3"
|
|
35
|
-
strokeLinecap="round"
|
|
36
|
-
strokeLinejoin="round"
|
|
37
|
-
/>
|
|
38
|
-
<path
|
|
39
|
-
d={pointerPath}
|
|
40
|
-
data-svg-path="spinner-pointer"
|
|
41
|
-
strokeWidth="3"
|
|
42
|
-
strokeLinecap="round"
|
|
43
|
-
strokeLinejoin="round"
|
|
44
|
-
/>
|
|
45
|
-
</svg>
|
|
46
|
-
</LoadingSpinnerRoot>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
);
|
|
50
|
-
LoadingSpinner.displayName = "LoadingSpinner";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { LoadingSpinnerRootProps } from "./loading-spinner.slots";
|
|
2
|
-
import type { RecipeVariantProps } from "@chakra-ui/react";
|
|
3
|
-
import { loadingSpinnerRecipe } from "./loading-spinner.recipe";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Combines the root props with Chakra UI's recipe variant props and Aria's progress bar props.
|
|
7
|
-
*
|
|
8
|
-
* This allows the component to accept both structural props from Root
|
|
9
|
-
* and styling variants from the recipe.
|
|
10
|
-
*/
|
|
11
|
-
type LoadingSpinnerVariantProps = LoadingSpinnerRootProps &
|
|
12
|
-
RecipeVariantProps<typeof loadingSpinnerRecipe> & {
|
|
13
|
-
[key: `data-${string}`]: string;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Main props interface for the LoadingSpinner component.
|
|
18
|
-
* Extends LoadingSpinnerVariantProps to include both root props and variant props,
|
|
19
|
-
* while adding support for React children.
|
|
20
|
-
*/
|
|
21
|
-
export type LoadingSpinnerProps = LoadingSpinnerVariantProps;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { ThemeProvider, useTheme, type ThemeProviderProps } from "next-themes";
|
|
3
|
-
|
|
4
|
-
export interface ColorModeProviderProps extends ThemeProviderProps {}
|
|
5
|
-
|
|
6
|
-
export function ColorModeProvider(props: ColorModeProviderProps) {
|
|
7
|
-
return (
|
|
8
|
-
<ThemeProvider attribute="class" disableTransitionOnChange {...props} />
|
|
9
|
-
);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function useColorMode() {
|
|
13
|
-
const { resolvedTheme, setTheme } = useTheme();
|
|
14
|
-
const toggleColorMode = () => {
|
|
15
|
-
setTheme(resolvedTheme === "light" ? "dark" : "light");
|
|
16
|
-
};
|
|
17
|
-
return {
|
|
18
|
-
colorMode: resolvedTheme,
|
|
19
|
-
setColorMode: setTheme,
|
|
20
|
-
toggleColorMode,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function useColorModeValue<T>(light: T, dark: T) {
|
|
25
|
-
const { colorMode } = useColorMode();
|
|
26
|
-
return colorMode === "light" ? light : dark;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function ColorModeLabel() {
|
|
30
|
-
const { colorMode } = useColorMode();
|
|
31
|
-
return colorMode === "light" ? "Light Theme" : "DarkTheme";
|
|
32
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: NimbusProvider
|
|
3
|
-
title: NimbusProvider
|
|
4
|
-
description: provides an environment for the rest of the components to work in
|
|
5
|
-
documentState: InitialDraft
|
|
6
|
-
order: 999
|
|
7
|
-
menu:
|
|
8
|
-
- Components
|
|
9
|
-
- Utilities
|
|
10
|
-
- NimbusProvider
|
|
11
|
-
tags:
|
|
12
|
-
- system
|
|
13
|
-
- required
|
|
14
|
-
- setup
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
# NimbusProvider
|
|
18
|
-
|
|
19
|
-
Provides the necesseary context for the rest of the components to work in.
|
|
20
|
-
|
|
21
|
-
<PropTable id="NimbusProvider" />
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ChakraProvider,
|
|
5
|
-
// defaultSystem as defaultSystemChakra,
|
|
6
|
-
} from "@chakra-ui/react";
|
|
7
|
-
import { ColorModeProvider, type ColorModeProviderProps } from "./color-mode";
|
|
8
|
-
import { system } from "../../theme";
|
|
9
|
-
import { useEffect, useState } from "react";
|
|
10
|
-
|
|
11
|
-
export function useColorScheme() {
|
|
12
|
-
const [colorScheme, setColorScheme] = useState(getCurrentColorScheme());
|
|
13
|
-
|
|
14
|
-
// Helper function to get the current color-scheme from the <html> tag
|
|
15
|
-
function getCurrentColorScheme() {
|
|
16
|
-
return (
|
|
17
|
-
document.documentElement.style.getPropertyValue("color-scheme") ||
|
|
18
|
-
localStorage.getItem("theme") ||
|
|
19
|
-
"light"
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
const htmlElement = document.documentElement;
|
|
25
|
-
|
|
26
|
-
const observer = new MutationObserver(() => {
|
|
27
|
-
const newColorScheme = getCurrentColorScheme();
|
|
28
|
-
setColorScheme(newColorScheme);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Observe changes to the 'style' attribute of the <html> element
|
|
32
|
-
observer.observe(htmlElement, {
|
|
33
|
-
attributes: true,
|
|
34
|
-
attributeFilter: ["style"],
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return () => observer.disconnect();
|
|
38
|
-
}, []);
|
|
39
|
-
|
|
40
|
-
return colorScheme;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export function NimbusProvider({ children, ...props }: ColorModeProviderProps) {
|
|
44
|
-
return (
|
|
45
|
-
<ChakraProvider value={system}>
|
|
46
|
-
<ColorModeProvider enableSystem={false} {...props}>
|
|
47
|
-
<>{children}</>
|
|
48
|
-
</ColorModeProvider>
|
|
49
|
-
</ChakraProvider>
|
|
50
|
-
);
|
|
51
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { useContext } from "react";
|
|
2
|
-
import { Close as CloseIcon } from "@commercetools/nimbus-icons";
|
|
3
|
-
import { IconButton } from "@/components";
|
|
4
|
-
import { SelectStateContext } from "react-aria-components";
|
|
5
|
-
|
|
6
|
-
export const SelectClearButton = () => {
|
|
7
|
-
const state = useContext(SelectStateContext);
|
|
8
|
-
|
|
9
|
-
if (!state?.selectedKey) {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const onPressRequest = () => {
|
|
14
|
-
state?.setSelectedKey(null);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<IconButton
|
|
19
|
-
pointerEvents="all"
|
|
20
|
-
size="2xs"
|
|
21
|
-
variant="ghost"
|
|
22
|
-
tone="primary"
|
|
23
|
-
aria-label="Clear Selection"
|
|
24
|
-
onPress={onPressRequest}
|
|
25
|
-
>
|
|
26
|
-
<CloseIcon />
|
|
27
|
-
</IconButton>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
SelectClearButton.displayName = "Select.ClearButton";
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { forwardRef, type ForwardedRef, type ReactNode } from "react";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
ListBoxSection as RaListBoxSection,
|
|
5
|
-
Header as RaHeader,
|
|
6
|
-
Collection,
|
|
7
|
-
} from "react-aria-components";
|
|
8
|
-
import { SelectOptionGroupSlot } from "./../select.slots";
|
|
9
|
-
import type { SelectOptionGroupProps } from "../select.types";
|
|
10
|
-
import { fixedForwardRef } from "@/utils/fixedForwardRef";
|
|
11
|
-
|
|
12
|
-
export const SelectOptionGroup = fixedForwardRef(
|
|
13
|
-
<T extends object>(
|
|
14
|
-
{ label, items, children, ...props }: SelectOptionGroupProps<T>,
|
|
15
|
-
forwardedRef: ForwardedRef<HTMLDivElement>
|
|
16
|
-
) => {
|
|
17
|
-
// Validate that children is a function when items is provided
|
|
18
|
-
if (items && typeof children !== "function") {
|
|
19
|
-
throw new Error(
|
|
20
|
-
'SelectOptionGroup: When "items" is provided, "children" must be a function'
|
|
21
|
-
);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<RaListBoxSection ref={forwardedRef} {...props}>
|
|
26
|
-
<SelectOptionGroupSlot asChild>
|
|
27
|
-
<RaHeader>{label}</RaHeader>
|
|
28
|
-
</SelectOptionGroupSlot>
|
|
29
|
-
|
|
30
|
-
{items ? (
|
|
31
|
-
<Collection items={items}>
|
|
32
|
-
{(item: T) => {
|
|
33
|
-
if (typeof children === "function") {
|
|
34
|
-
return children(item);
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}}
|
|
38
|
-
</Collection>
|
|
39
|
-
) : (
|
|
40
|
-
(children as ReactNode)
|
|
41
|
-
)}
|
|
42
|
-
</RaListBoxSection>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
// @ts-expect-error - doesn't work with this complex types
|
|
48
|
-
SelectOptionGroup.displayName = "Select.OptionGroup";
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ForwardedRef } from "react";
|
|
2
|
-
import { ListBoxItem as RaListBoxItem } from "react-aria-components";
|
|
3
|
-
import { SelectOptionSlot } from "./../select.slots";
|
|
4
|
-
import type { SelectOptionProps } from "../select.types";
|
|
5
|
-
import { fixedForwardRef } from "@/utils/fixedForwardRef";
|
|
6
|
-
|
|
7
|
-
export const SelectOption = fixedForwardRef(
|
|
8
|
-
<T extends object>(
|
|
9
|
-
props: SelectOptionProps<T>,
|
|
10
|
-
forwardedRef: ForwardedRef<HTMLDivElement>
|
|
11
|
-
) => {
|
|
12
|
-
return (
|
|
13
|
-
<SelectOptionSlot asChild ref={forwardedRef}>
|
|
14
|
-
<RaListBoxItem {...props} />
|
|
15
|
-
</SelectOptionSlot>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
// @ts-expect-error - doesn't work with this complex types
|
|
21
|
-
SelectOption.displayName = "Select.Option";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type ForwardedRef } from "react";
|
|
2
|
-
import { ListBox as RaListBox } from "react-aria-components";
|
|
3
|
-
import { SelectOptionsSlot } from "./../select.slots";
|
|
4
|
-
import type { SelectOptionsProps } from "../select.types";
|
|
5
|
-
import { extractStyleProps } from "@/utils/extractStyleProps";
|
|
6
|
-
import { fixedForwardRef } from "@/utils/fixedForwardRef";
|
|
7
|
-
|
|
8
|
-
export const SelectOptions = fixedForwardRef(
|
|
9
|
-
<T extends object>(
|
|
10
|
-
props: SelectOptionsProps<T>,
|
|
11
|
-
forwardedRef: ForwardedRef<HTMLDivElement>
|
|
12
|
-
) => {
|
|
13
|
-
const [styleProps, rest] = extractStyleProps(props);
|
|
14
|
-
return (
|
|
15
|
-
<SelectOptionsSlot asChild {...styleProps}>
|
|
16
|
-
<RaListBox ref={forwardedRef} {...rest} />
|
|
17
|
-
</SelectOptionsSlot>
|
|
18
|
-
);
|
|
19
|
-
}
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
// @ts-expect-error - doesn't work with this complex types
|
|
23
|
-
SelectOptions.displayName = "Select.Options";
|