@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,72 +0,0 @@
|
|
|
1
|
-
import { defineRecipe } from "@chakra-ui/react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Recipe configuration for the Badge component.
|
|
5
|
-
* Defines the styling variants and base styles using Chakra UI's recipe system.
|
|
6
|
-
*/
|
|
7
|
-
export const badgeRecipe = defineRecipe({
|
|
8
|
-
className: "nimbus-badge",
|
|
9
|
-
|
|
10
|
-
// Base styles applied to all instances of the component
|
|
11
|
-
base: {
|
|
12
|
-
display: "inline-flex",
|
|
13
|
-
alignItems: "center",
|
|
14
|
-
borderRadius: "200",
|
|
15
|
-
justifyContent: "center",
|
|
16
|
-
whiteSpace: "nowrap",
|
|
17
|
-
verticalAlign: "middle",
|
|
18
|
-
py: "25",
|
|
19
|
-
fontWeight: "500",
|
|
20
|
-
backgroundColor: "colorPalette.3",
|
|
21
|
-
color: "colorPalette.11",
|
|
22
|
-
w: "auto",
|
|
23
|
-
userSelect: "none",
|
|
24
|
-
_icon: {
|
|
25
|
-
flexShrink: "0",
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
// Available variants for customizing the component's appearance
|
|
30
|
-
variants: {
|
|
31
|
-
size: {
|
|
32
|
-
"2xs": {
|
|
33
|
-
fontSize: "300",
|
|
34
|
-
gap: "100",
|
|
35
|
-
h: "600",
|
|
36
|
-
lineHeight: "350",
|
|
37
|
-
px: "200",
|
|
38
|
-
_icon: {
|
|
39
|
-
width: "400",
|
|
40
|
-
height: "400",
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
xs: {
|
|
44
|
-
fontSize: "350",
|
|
45
|
-
gap: "100",
|
|
46
|
-
h: "800",
|
|
47
|
-
lineHeight: "400",
|
|
48
|
-
px: "300",
|
|
49
|
-
_icon: {
|
|
50
|
-
width: "500",
|
|
51
|
-
height: "500",
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
md: {
|
|
55
|
-
fontSize: "400",
|
|
56
|
-
gap: "200",
|
|
57
|
-
h: "1000",
|
|
58
|
-
lineHeight: "500",
|
|
59
|
-
px: "400",
|
|
60
|
-
_icon: {
|
|
61
|
-
width: "600",
|
|
62
|
-
height: "600",
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
// Default variant values when not explicitly specified
|
|
69
|
-
defaultVariants: {
|
|
70
|
-
size: "md",
|
|
71
|
-
},
|
|
72
|
-
});
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRecipeContext } from "@chakra-ui/react";
|
|
2
|
-
|
|
3
|
-
import { badgeRecipe } from "./badge.recipe";
|
|
4
|
-
import type { BadgeRootProps } from "./badge.types";
|
|
5
|
-
|
|
6
|
-
const { withContext } = createRecipeContext({ recipe: badgeRecipe });
|
|
7
|
-
|
|
8
|
-
export const BadgeRoot = withContext<HTMLSpanElement, BadgeRootProps>("span");
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Badge } from "./badge";
|
|
3
|
-
import { Stack } from "./../stack";
|
|
4
|
-
import type { BadgeProps } from "./badge.types";
|
|
5
|
-
import { SentimentSatisfied as DemoIcon } from "@commercetools/nimbus-icons";
|
|
6
|
-
import { within, expect } from "@storybook/test";
|
|
7
|
-
|
|
8
|
-
const sizes: BadgeProps["size"][] = ["2xs", "xs", "md"];
|
|
9
|
-
const colors: Array<
|
|
10
|
-
"amber" | "blue" | "grass" | "slate" | "tomato" | "primary"
|
|
11
|
-
> = ["primary", "tomato", "grass", "amber", "blue", "slate"];
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Storybook metadata configuration
|
|
15
|
-
* - title: determines the location in the sidebar
|
|
16
|
-
* - component: references the component being documented
|
|
17
|
-
*/
|
|
18
|
-
const meta: Meta<typeof Badge> = {
|
|
19
|
-
title: "components/Badge",
|
|
20
|
-
component: Badge,
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export default meta;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Story type for TypeScript support
|
|
27
|
-
* StoryObj provides type checking for our story configurations
|
|
28
|
-
*/
|
|
29
|
-
type Story = StoryObj<typeof Badge>;
|
|
30
|
-
/**
|
|
31
|
-
* Base story
|
|
32
|
-
* Demonstrates the most basic implementation
|
|
33
|
-
* Uses the args pattern for dynamic control panel inputs
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
export const Base: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
children: "Demo Badge",
|
|
39
|
-
size: "md",
|
|
40
|
-
colorPalette: "grass",
|
|
41
|
-
["data-testid"]: "badge-test",
|
|
42
|
-
["aria-label"]: "badge",
|
|
43
|
-
},
|
|
44
|
-
play: async ({ canvasElement, step }) => {
|
|
45
|
-
const canvas = within(canvasElement);
|
|
46
|
-
const link = canvas.getByTestId("badge-test");
|
|
47
|
-
|
|
48
|
-
await step("Uses a <span> element by default", async () => {
|
|
49
|
-
await expect(link.tagName).toBe("SPAN");
|
|
50
|
-
});
|
|
51
|
-
await step("Forwards data- & aria-attributes", async () => {
|
|
52
|
-
await expect(link).toHaveAttribute("data-testid", "badge-test");
|
|
53
|
-
await expect(link).toHaveAttribute("aria-label", "badge");
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
await step("Renders children", async () => {
|
|
57
|
-
await expect(link).toHaveTextContent("Demo Badge");
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Showcase Sizes
|
|
64
|
-
*/
|
|
65
|
-
export const Sizes: Story = {
|
|
66
|
-
args: {},
|
|
67
|
-
render: (args) => {
|
|
68
|
-
return (
|
|
69
|
-
<Stack direction="row" gap="400" alignItems="center">
|
|
70
|
-
{sizes.map((size) => (
|
|
71
|
-
<Badge key={size as string} {...args} size={size}>
|
|
72
|
-
{String(size)}
|
|
73
|
-
</Badge>
|
|
74
|
-
))}
|
|
75
|
-
</Stack>
|
|
76
|
-
);
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Showcase Possible Colors
|
|
82
|
-
*/
|
|
83
|
-
export const Colors: Story = {
|
|
84
|
-
args: {
|
|
85
|
-
children: "Demo Badge",
|
|
86
|
-
size: "xs",
|
|
87
|
-
},
|
|
88
|
-
render: (args) => {
|
|
89
|
-
return (
|
|
90
|
-
<Stack direction="row" gap="400" alignItems="center">
|
|
91
|
-
{colors.map((color) => (
|
|
92
|
-
<Badge key={color as string} {...args} colorPalette={color} />
|
|
93
|
-
))}
|
|
94
|
-
</Stack>
|
|
95
|
-
);
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Showcase Icons
|
|
101
|
-
*/
|
|
102
|
-
export const WithIcons: Story = {
|
|
103
|
-
args: {
|
|
104
|
-
size: "md",
|
|
105
|
-
},
|
|
106
|
-
render: (args) => {
|
|
107
|
-
const demoText = "Demo Badge";
|
|
108
|
-
return (
|
|
109
|
-
<Stack direction="row" gap="400" alignItems="center">
|
|
110
|
-
<Badge {...args}>
|
|
111
|
-
{demoText} <DemoIcon />
|
|
112
|
-
</Badge>
|
|
113
|
-
|
|
114
|
-
<Badge {...args}>
|
|
115
|
-
<DemoIcon /> {demoText}
|
|
116
|
-
</Badge>
|
|
117
|
-
|
|
118
|
-
<Badge {...args}>
|
|
119
|
-
<DemoIcon /> {demoText} <DemoIcon />
|
|
120
|
-
</Badge>
|
|
121
|
-
</Stack>
|
|
122
|
-
);
|
|
123
|
-
},
|
|
124
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { forwardRef, useRef } from "react";
|
|
2
|
-
import { BadgeRoot } from "./badge.slots";
|
|
3
|
-
import type { BadgeProps } from "./badge.types";
|
|
4
|
-
import { mergeRefs } from "@chakra-ui/react";
|
|
5
|
-
import { useObjectRef, mergeProps } from "react-aria";
|
|
6
|
-
/**
|
|
7
|
-
* Badge
|
|
8
|
-
* ============================================================
|
|
9
|
-
* badge
|
|
10
|
-
*
|
|
11
|
-
* Features:
|
|
12
|
-
*
|
|
13
|
-
* - allows forwarding refs to the underlying DOM element
|
|
14
|
-
* - accepts all native html 'HTMLSpanElement' attributes (including aria- & data-attributes)
|
|
15
|
-
* - supports 'variants', 'sizes', etc. configured in the recipe
|
|
16
|
-
* - allows overriding styles by using style-props
|
|
17
|
-
* - supports 'asChild' and 'as' to modify the underlying html-element (polymorphic)
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
export const Badge = forwardRef<HTMLSpanElement, BadgeProps>(
|
|
21
|
-
(props, forwardedRef) => {
|
|
22
|
-
const { as, asChild, children, ...rest } = props;
|
|
23
|
-
|
|
24
|
-
const localRef = useRef<HTMLSpanElement>(null);
|
|
25
|
-
const ref = useObjectRef(mergeRefs(localRef, forwardedRef));
|
|
26
|
-
|
|
27
|
-
const elementType = as || "span";
|
|
28
|
-
|
|
29
|
-
return (
|
|
30
|
-
<BadgeRoot as={elementType} {...mergeProps(rest, { ref })}>
|
|
31
|
-
{children}
|
|
32
|
-
</BadgeRoot>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
RecipeProps,
|
|
3
|
-
UnstyledProp,
|
|
4
|
-
HTMLChakraProps,
|
|
5
|
-
RecipeVariantProps,
|
|
6
|
-
} from "@chakra-ui/react";
|
|
7
|
-
import { badgeRecipe } from "./badge.recipe";
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Base recipe props interface that combines Chakra UI's recipe props
|
|
11
|
-
* with the unstyled prop option for the span element.
|
|
12
|
-
*/
|
|
13
|
-
export interface BadgeRecipeProps extends RecipeProps<"span">, UnstyledProp {}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Root props interface that extends Chakra's HTML props with our recipe props.
|
|
17
|
-
* This creates a complete set of props for the root element, combining
|
|
18
|
-
* HTML attributes, Chakra's styling system, and our custom recipe props.
|
|
19
|
-
*/
|
|
20
|
-
export interface BadgeRootProps
|
|
21
|
-
extends HTMLChakraProps<"span", BadgeRecipeProps> {}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Combines the root props with Chakra UI's recipe variant props.
|
|
25
|
-
* This allows the component to accept both structural props from Root
|
|
26
|
-
* and styling variants from the recipe.
|
|
27
|
-
*/
|
|
28
|
-
type BadgeVariantProps = BadgeRootProps &
|
|
29
|
-
RecipeVariantProps<typeof badgeRecipe> & {
|
|
30
|
-
[key: `data-${string}`]: string;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Main props interface for the Badge component.
|
|
35
|
-
* Extends BadgeVariantProps to include both root props and variant props,
|
|
36
|
-
* while adding support for React children.
|
|
37
|
-
*/
|
|
38
|
-
export interface BadgeProps extends BadgeVariantProps {
|
|
39
|
-
children?: React.ReactNode;
|
|
40
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Bleed } from "@chakra-ui/react";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./bleed";
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: Components-Box
|
|
3
|
-
title: Box
|
|
4
|
-
description: A basic layout component that serves as a wrapper or container.
|
|
5
|
-
documentState: InitialDraft
|
|
6
|
-
order: 999
|
|
7
|
-
menu:
|
|
8
|
-
- Components
|
|
9
|
-
- Layout
|
|
10
|
-
- Box
|
|
11
|
-
tags:
|
|
12
|
-
- component
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
# Box
|
|
16
|
-
|
|
17
|
-
Box is a basic layout component that serves as a wrapper or container. It's
|
|
18
|
-
based on the
|
|
19
|
-
[Chakra UI Box component](https://chakra-ui.com/docs/components/box) and
|
|
20
|
-
supports all style props for rapid UI development.
|
|
21
|
-
|
|
22
|
-
## Import
|
|
23
|
-
|
|
24
|
-
```jsx
|
|
25
|
-
import { Box } from "@commercetools/nimbus";
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
### Basic Usage
|
|
31
|
-
|
|
32
|
-
```jsx-live
|
|
33
|
-
const App = () => (
|
|
34
|
-
<Box p="100" bg="primary.3">
|
|
35
|
-
Basic Box
|
|
36
|
-
</Box>
|
|
37
|
-
);
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
### As Flex Container
|
|
41
|
-
|
|
42
|
-
```jsx-live
|
|
43
|
-
const App = () => (
|
|
44
|
-
<Box display="flex" gap="100">
|
|
45
|
-
<Box p="100" bg="primary.3">
|
|
46
|
-
Item 1
|
|
47
|
-
</Box>
|
|
48
|
-
<Box p="100" bg="primary.3">
|
|
49
|
-
Item 2
|
|
50
|
-
</Box>
|
|
51
|
-
</Box>
|
|
52
|
-
);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### With Border
|
|
56
|
-
|
|
57
|
-
```jsx-live
|
|
58
|
-
const App = () => (
|
|
59
|
-
<Box p="100" border="solid-50" borderColor="primary.3">
|
|
60
|
-
Box with border
|
|
61
|
-
</Box>
|
|
62
|
-
);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### With Shadow
|
|
66
|
-
|
|
67
|
-
```jsx-live
|
|
68
|
-
const App = () => (
|
|
69
|
-
<Box p="100" boxShadow="6">
|
|
70
|
-
Box with shadow
|
|
71
|
-
</Box>
|
|
72
|
-
);
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### With asChild
|
|
76
|
-
|
|
77
|
-
Use the `asChild` prop to apply Box styles to any child element while
|
|
78
|
-
maintaining the child's functionality:
|
|
79
|
-
|
|
80
|
-
```jsx-live
|
|
81
|
-
const App = () => (
|
|
82
|
-
<Box p="100" bg="primary.3" asChild>
|
|
83
|
-
<button onClick={() => alert("Clicked!")}>
|
|
84
|
-
I am a button with Box styles
|
|
85
|
-
</button>
|
|
86
|
-
</Box>
|
|
87
|
-
);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Props
|
|
91
|
-
|
|
92
|
-
The Box component accepts all system props from Chakra UI, including:
|
|
93
|
-
|
|
94
|
-
- Space props (margin, padding)
|
|
95
|
-
- Color props (background, color)
|
|
96
|
-
- Typography props (fontSize, fontWeight)
|
|
97
|
-
- Layout props (width, height, display)
|
|
98
|
-
- Flexbox props
|
|
99
|
-
- Grid props
|
|
100
|
-
- Border props
|
|
101
|
-
- Position props
|
|
102
|
-
- Shadow props
|
|
103
|
-
|
|
104
|
-
## Accessibility
|
|
105
|
-
|
|
106
|
-
Box renders a `div` by default but can be changed to any other HTML element
|
|
107
|
-
using the `as` prop.
|
|
108
|
-
|
|
109
|
-
```jsx-live
|
|
110
|
-
const App = () => (
|
|
111
|
-
<Box as="section" p="100">
|
|
112
|
-
Section content
|
|
113
|
-
</Box>
|
|
114
|
-
);
|
|
115
|
-
```
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Box } from "./box";
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof Box> = {
|
|
5
|
-
title: "Components/Box",
|
|
6
|
-
component: Box,
|
|
7
|
-
tags: ["autodocs"],
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default meta;
|
|
11
|
-
|
|
12
|
-
type Story = StoryObj<typeof Box>;
|
|
13
|
-
|
|
14
|
-
export const Base: Story = {
|
|
15
|
-
args: {
|
|
16
|
-
p: "100",
|
|
17
|
-
bg: "primary.3",
|
|
18
|
-
children: "Basic Box",
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const WithBorder: Story = {
|
|
23
|
-
args: {
|
|
24
|
-
p: "100",
|
|
25
|
-
border: "solid-50",
|
|
26
|
-
borderColor: "primary.3",
|
|
27
|
-
children: "Box with border",
|
|
28
|
-
},
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const AsFlexContainer: Story = {
|
|
32
|
-
args: {
|
|
33
|
-
display: "grid",
|
|
34
|
-
children: (
|
|
35
|
-
<>
|
|
36
|
-
<Box p="100" bg="primary.3">
|
|
37
|
-
Item 1
|
|
38
|
-
</Box>
|
|
39
|
-
<Box p="100" bg="primary.3">
|
|
40
|
-
Item 2
|
|
41
|
-
</Box>
|
|
42
|
-
<Box p="100" bg="primary.3">
|
|
43
|
-
Item 3
|
|
44
|
-
</Box>
|
|
45
|
-
</>
|
|
46
|
-
),
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const WithShadow: Story = {
|
|
51
|
-
args: {
|
|
52
|
-
p: "100",
|
|
53
|
-
shadow: "6",
|
|
54
|
-
borderRadius: "100",
|
|
55
|
-
children: "Box with shadow",
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const AsChild: Story = {
|
|
60
|
-
args: {
|
|
61
|
-
p: "100",
|
|
62
|
-
bg: "primary.3",
|
|
63
|
-
color: "primary.11",
|
|
64
|
-
asChild: true,
|
|
65
|
-
children: (
|
|
66
|
-
<button onClick={() => alert("Clicked!")}>
|
|
67
|
-
Click me! I am a button with Box styles
|
|
68
|
-
</button>
|
|
69
|
-
),
|
|
70
|
-
},
|
|
71
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { forwardRef } from "react";
|
|
2
|
-
import { Box as ChakraBox, type HTMLChakraProps } from "@chakra-ui/react";
|
|
3
|
-
export interface BoxProps extends HTMLChakraProps<"div"> {
|
|
4
|
-
children?: React.ReactNode;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const Box = forwardRef<HTMLDivElement, BoxProps>((props, ref) => {
|
|
8
|
-
return <ChakraBox ref={ref} {...props} />;
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
Box.displayName = "Box";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { Box, type BoxProps } from "./box";
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: Forms-Button
|
|
3
|
-
title: Button
|
|
4
|
-
description: Displays a Button.
|
|
5
|
-
documentState: ReviewedInternal
|
|
6
|
-
documentAudiences: []
|
|
7
|
-
order: 999
|
|
8
|
-
menu:
|
|
9
|
-
- Components
|
|
10
|
-
- Inputs
|
|
11
|
-
- Button
|
|
12
|
-
tags:
|
|
13
|
-
- document
|
|
14
|
-
figmaLink: >-
|
|
15
|
-
https://www.figma.com/design/AvtPX6g7OGGCRvNlatGOIY/New-Design-System?node-id=58-132&m=dev
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
# Button
|
|
19
|
-
|
|
20
|
-
Displays a Button.
|
|
21
|
-
|
|
22
|
-
## Basic Usage
|
|
23
|
-
|
|
24
|
-
If unconfigured it will default to a neutral state. It is important to configure
|
|
25
|
-
the Button properly to ensure it displays as intended.
|
|
26
|
-
|
|
27
|
-
```jsx-live
|
|
28
|
-
const App = () => <Button>I am a Button</Button>
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Events
|
|
32
|
-
|
|
33
|
-
To handle the differences between mouse-, touch- and keyboard-interactions, the
|
|
34
|
-
`Button` supports `onPress*` events. The misc `onPress*` events (`onPress`,
|
|
35
|
-
`onPressStart`, `onPressEnd`, etc.) provide a more seamless and inclusive user
|
|
36
|
-
experience across different devices and input methods:
|
|
37
|
-
|
|
38
|
-
```jsx-live
|
|
39
|
-
const App = () => <Button tone="primary" variant="solid" onPress={()=>alert()}>I am accessible</Button>
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## Custom DOM-element
|
|
43
|
-
|
|
44
|
-
The Button component uses the native
|
|
45
|
-
[HTML button element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button)
|
|
46
|
-
by default, but supports rendering as a different tag to the DOM. Use the
|
|
47
|
-
`asChild` property and the tag you want to render as _only_ child.
|
|
48
|
-
|
|
49
|
-
```jsx-live
|
|
50
|
-
const App = () => (
|
|
51
|
-
<Button tone="primary" variant="solid" asChild>
|
|
52
|
-
<a href="http://www.commercetools.com" target="_blank">I am a button in disguise</a>
|
|
53
|
-
</Button>
|
|
54
|
-
)
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Aria- & Data-Attributes
|
|
58
|
-
|
|
59
|
-
The Button component supports forwarding `data-*` and `aria-*` attributes. This
|
|
60
|
-
can be useful for tracking tools & a11y.
|
|
61
|
-
|
|
62
|
-
```jsx-live
|
|
63
|
-
const App = () => <Button tone="primary" variant="solid" data-foo="bar">I can have data-attributes</Button>
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Customizing the look
|
|
67
|
-
|
|
68
|
-
### Sizes
|
|
69
|
-
|
|
70
|
-
Buttons come in different sizes, sizing a button is done by setting the `size`
|
|
71
|
-
prop. Setting the size has no effect on the variant or color of the Button.
|
|
72
|
-
|
|
73
|
-
```jsx-live
|
|
74
|
-
const App = () => {
|
|
75
|
-
|
|
76
|
-
const sizes = ['2xs', 'xs', 'md'].reverse();
|
|
77
|
-
|
|
78
|
-
return (
|
|
79
|
-
<Stack direction="horizontal" alignItems="center">
|
|
80
|
-
{sizes.map(size => (
|
|
81
|
-
<Button tone="primary" variant="solid" key={size} size={size}>'{size}' Button</Button>
|
|
82
|
-
))}
|
|
83
|
-
</Stack>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
### Variants
|
|
89
|
-
|
|
90
|
-
Look how the buttons change their appearance but not their size. It is important
|
|
91
|
-
that the variant has no effect on the size. Only then it can be guaranteed that
|
|
92
|
-
buttons with different variants can be used and displayed next to each other.
|
|
93
|
-
|
|
94
|
-
```jsx-live
|
|
95
|
-
const App = () => {
|
|
96
|
-
|
|
97
|
-
const variants = ['solid', 'outline', 'ghost', "link"]
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<Stack direction="horizontal">
|
|
101
|
-
{variants.map(variant => (
|
|
102
|
-
<Button tone="primary" key={variant} variant={variant}>'{variant}' Button</Button>
|
|
103
|
-
))}
|
|
104
|
-
</Stack>
|
|
105
|
-
)
|
|
106
|
-
}
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Tones / Colors
|
|
110
|
-
|
|
111
|
-
Since the different `variants` operate purely on contrast level differences
|
|
112
|
-
(think: dark & light elements), the `colorPalette` prop can be used to colorize
|
|
113
|
-
the Button.
|
|
114
|
-
|
|
115
|
-
```jsx-live
|
|
116
|
-
const App = () => {
|
|
117
|
-
const variants = ["solid", "outline", "ghost", "link"];
|
|
118
|
-
const colors = ["primary", "critical"];
|
|
119
|
-
|
|
120
|
-
return (
|
|
121
|
-
<Stack>
|
|
122
|
-
{colors.map((color) => (
|
|
123
|
-
<Stack key={color} direction="horizontal">
|
|
124
|
-
{variants.map((variant) => (
|
|
125
|
-
<Button tone={color} key={variant} variant={variant}>
|
|
126
|
-
'{variant}' Button
|
|
127
|
-
</Button>
|
|
128
|
-
))}
|
|
129
|
-
</Stack>
|
|
130
|
-
))}
|
|
131
|
-
</Stack>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Icons
|
|
137
|
-
|
|
138
|
-
Simply drop the desired icon into the `Button`:
|
|
139
|
-
|
|
140
|
-
```jsx-live
|
|
141
|
-
const App = () => {
|
|
142
|
-
const sizes = ["2xs", "xs", "md"].reverse();
|
|
143
|
-
|
|
144
|
-
return (
|
|
145
|
-
<Stack>
|
|
146
|
-
{sizes.map((size) => (
|
|
147
|
-
<Stack key={size} direction="horizontal">
|
|
148
|
-
<Button size={size} colorPalette="success" variant="solid" startIcon={<Icons.Check />}>
|
|
149
|
-
<Icons.Check />
|
|
150
|
-
Yes
|
|
151
|
-
</Button>
|
|
152
|
-
<Button size={size} colorPalette="error" variant="solid" startIcon={<Icons.X />}>
|
|
153
|
-
<Icons.Close />
|
|
154
|
-
No
|
|
155
|
-
</Button>
|
|
156
|
-
<Button size={size} colorPalette="neutral" variant="ghost" endIcon={<Box animation="spin" asChild><Icons.Loader/></Box>}>
|
|
157
|
-
Maybe
|
|
158
|
-
<Icons.HelpOutline />
|
|
159
|
-
</Button>
|
|
160
|
-
</Stack>
|
|
161
|
-
))}
|
|
162
|
-
</Stack>
|
|
163
|
-
);
|
|
164
|
-
};
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
## Properties / API
|
|
168
|
-
|
|
169
|
-
<PropTable id="Button" />
|