@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.
- package/dist/index.d.ts +1412 -0
- package/dist/index.js +22451 -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 +74 -40
- 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,175 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
-
import { Card } from "./card";
|
|
3
|
-
import { Stack } from "./../stack";
|
|
4
|
-
import type { CardProps } from "./card.types";
|
|
5
|
-
import { within, expect, userEvent } from "@storybook/test";
|
|
6
|
-
|
|
7
|
-
const cardPaddings: CardProps["cardPadding"][] = ["sm", "md", "lg"];
|
|
8
|
-
const elevations: CardProps["elevation"][] = ["none", "elevated"];
|
|
9
|
-
const borderStyles: CardProps["borderStyle"][] = ["none", "outlined"];
|
|
10
|
-
const backgroundStyles: CardProps["backgroundStyle"][] = ["default", "muted"];
|
|
11
|
-
|
|
12
|
-
const meta: Meta<typeof Card.Root> = {
|
|
13
|
-
title: "components/Card",
|
|
14
|
-
component: Card.Root,
|
|
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 Card.Root>;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Base story
|
|
27
|
-
* Demonstrates the most basic implementation
|
|
28
|
-
*/
|
|
29
|
-
export const Base: Story = {
|
|
30
|
-
args: {
|
|
31
|
-
children: "Demo Card",
|
|
32
|
-
"data-testid": "test-card",
|
|
33
|
-
cardPadding: "md",
|
|
34
|
-
backgroundStyle: "default",
|
|
35
|
-
borderStyle: "none",
|
|
36
|
-
elevation: "none",
|
|
37
|
-
},
|
|
38
|
-
play: async ({ canvasElement, args, step }) => {
|
|
39
|
-
const canvas = within(canvasElement);
|
|
40
|
-
const card = canvas.getByTestId("test-card");
|
|
41
|
-
|
|
42
|
-
await step("Renders a <div> by default", async () => {
|
|
43
|
-
await expect(card.tagName).toBe("DIV");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
await step("Displays correct content", async () => {
|
|
47
|
-
await expect(card).toHaveTextContent(args.children as string);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
await step("Can be focused with the keyboard", async () => {
|
|
51
|
-
await userEvent.keyboard("{tab}");
|
|
52
|
-
await expect(card).toHaveFocus();
|
|
53
|
-
});
|
|
54
|
-
},
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Card padding
|
|
59
|
-
*/
|
|
60
|
-
export const CardPaddings: Story = {
|
|
61
|
-
render: (args) => {
|
|
62
|
-
return (
|
|
63
|
-
<Stack>
|
|
64
|
-
{cardPaddings.map((cardPadding) => {
|
|
65
|
-
return (
|
|
66
|
-
<Stack direction="row" key={`stack-${cardPadding as string}`}>
|
|
67
|
-
<Card.Root
|
|
68
|
-
key={`${cardPadding as string}`}
|
|
69
|
-
{...args}
|
|
70
|
-
cardPadding={cardPadding}
|
|
71
|
-
borderStyle="outlined"
|
|
72
|
-
backgroundStyle="default"
|
|
73
|
-
elevation="none"
|
|
74
|
-
>
|
|
75
|
-
<Card.Header>
|
|
76
|
-
<b>Padding size: {cardPadding as string}</b>
|
|
77
|
-
</Card.Header>
|
|
78
|
-
<Card.Content>
|
|
79
|
-
<p>
|
|
80
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
81
|
-
</p>
|
|
82
|
-
</Card.Content>
|
|
83
|
-
</Card.Root>
|
|
84
|
-
</Stack>
|
|
85
|
-
);
|
|
86
|
-
})}
|
|
87
|
-
</Stack>
|
|
88
|
-
);
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
args: {},
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Showcase Configurations
|
|
96
|
-
*/
|
|
97
|
-
export const Configurations: Story = {
|
|
98
|
-
render: (args) => {
|
|
99
|
-
return (
|
|
100
|
-
<Stack>
|
|
101
|
-
{borderStyles.map((border) => {
|
|
102
|
-
return (
|
|
103
|
-
<Stack direction="row" key={`stack-${border as string}`}>
|
|
104
|
-
{elevations.map((shadow) => {
|
|
105
|
-
return backgroundStyles.map((background) => {
|
|
106
|
-
return (
|
|
107
|
-
<Card.Root
|
|
108
|
-
key={`${border as string}-${shadow as string}-${background as string}`}
|
|
109
|
-
{...args}
|
|
110
|
-
borderStyle={border}
|
|
111
|
-
elevation={shadow}
|
|
112
|
-
backgroundStyle={background}
|
|
113
|
-
cardPadding="md"
|
|
114
|
-
/>
|
|
115
|
-
);
|
|
116
|
-
});
|
|
117
|
-
})}
|
|
118
|
-
</Stack>
|
|
119
|
-
);
|
|
120
|
-
})}
|
|
121
|
-
</Stack>
|
|
122
|
-
);
|
|
123
|
-
},
|
|
124
|
-
|
|
125
|
-
args: {
|
|
126
|
-
children: (
|
|
127
|
-
<>
|
|
128
|
-
<Card.Header>
|
|
129
|
-
<b>Card title</b>
|
|
130
|
-
</Card.Header>
|
|
131
|
-
<Card.Content>
|
|
132
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
|
|
133
|
-
</Card.Content>
|
|
134
|
-
</>
|
|
135
|
-
),
|
|
136
|
-
},
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Without compound components used by the consumer
|
|
141
|
-
*/
|
|
142
|
-
export const WithoutCompound: Story = {
|
|
143
|
-
render: (args) => {
|
|
144
|
-
return (
|
|
145
|
-
<Stack>
|
|
146
|
-
{borderStyles.map((border) => {
|
|
147
|
-
return (
|
|
148
|
-
<Stack direction="row" key={`stack-${border as string}`}>
|
|
149
|
-
{elevations.map((shadow) => {
|
|
150
|
-
return (
|
|
151
|
-
<Card.Root
|
|
152
|
-
key={`${border as string}-${shadow as string}`}
|
|
153
|
-
{...args}
|
|
154
|
-
borderStyle={border}
|
|
155
|
-
elevation={shadow}
|
|
156
|
-
backgroundStyle="muted"
|
|
157
|
-
cardPadding="md"
|
|
158
|
-
/>
|
|
159
|
-
);
|
|
160
|
-
})}
|
|
161
|
-
</Stack>
|
|
162
|
-
);
|
|
163
|
-
})}
|
|
164
|
-
</Stack>
|
|
165
|
-
);
|
|
166
|
-
},
|
|
167
|
-
|
|
168
|
-
args: {
|
|
169
|
-
children: (
|
|
170
|
-
<div>
|
|
171
|
-
I'm some other flexible content, outside of the compound component
|
|
172
|
-
</div>
|
|
173
|
-
),
|
|
174
|
-
},
|
|
175
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { CardRootProps } from "./card.slots";
|
|
2
|
-
import type { RecipeVariantProps } from "@chakra-ui/react";
|
|
3
|
-
import { cardRecipe } from "./card.recipe";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Combines the root props with Chakra UI's recipe variant props.
|
|
7
|
-
* This allows the component to accept both structural props from Root
|
|
8
|
-
* and styling variants from the recipe.
|
|
9
|
-
*/
|
|
10
|
-
type CardVariantProps = CardRootProps &
|
|
11
|
-
RecipeVariantProps<typeof cardRecipe> & {
|
|
12
|
-
[key: `data-${string}`]: unknown;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Main props interface for the Card component.
|
|
17
|
-
* Extends CardVariantProps to include both root props and variant props,
|
|
18
|
-
* while adding support for React children.
|
|
19
|
-
*/
|
|
20
|
-
export interface CardProps extends CardVariantProps {
|
|
21
|
-
children?: React.ReactNode;
|
|
22
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
CardContent as CardContentSlot,
|
|
4
|
-
type CardContentProps,
|
|
5
|
-
} from "../card.slots";
|
|
6
|
-
import { CardContext } from "./card.root";
|
|
7
|
-
|
|
8
|
-
export const CardContent = ({ children, ...props }: CardContentProps) => {
|
|
9
|
-
const context = useContext(CardContext);
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (context) {
|
|
13
|
-
const slotElement = (
|
|
14
|
-
<CardContentSlot {...props}>{children}</CardContentSlot>
|
|
15
|
-
);
|
|
16
|
-
// Register it with the parent
|
|
17
|
-
context.setContent(slotElement);
|
|
18
|
-
|
|
19
|
-
// On unmount, remove it
|
|
20
|
-
return () => context.setContent(null);
|
|
21
|
-
}
|
|
22
|
-
}, [children, props]);
|
|
23
|
-
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
CardContent.displayName = "Card.Content";
|
|
28
|
-
|
|
29
|
-
export default CardContent;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
CardHeader as CardHeaderSlot,
|
|
4
|
-
type CardHeaderProps,
|
|
5
|
-
} from "../card.slots";
|
|
6
|
-
import { CardContext } from "./card.root";
|
|
7
|
-
|
|
8
|
-
const CardHeader = ({ children, ...props }: CardHeaderProps) => {
|
|
9
|
-
const context = useContext(CardContext);
|
|
10
|
-
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
if (context) {
|
|
13
|
-
const slotElement = (
|
|
14
|
-
<CardHeaderSlot {...props}>{children}</CardHeaderSlot>
|
|
15
|
-
);
|
|
16
|
-
// Register it with the parent
|
|
17
|
-
context.setHeader(slotElement);
|
|
18
|
-
|
|
19
|
-
// On unmount, remove it
|
|
20
|
-
return () => context.setHeader(null);
|
|
21
|
-
}
|
|
22
|
-
}, [children, props]);
|
|
23
|
-
|
|
24
|
-
return null;
|
|
25
|
-
};
|
|
26
|
-
CardHeader.displayName = "Card.Header";
|
|
27
|
-
|
|
28
|
-
export default CardHeader;
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
forwardRef,
|
|
4
|
-
useMemo,
|
|
5
|
-
useState,
|
|
6
|
-
type ReactNode,
|
|
7
|
-
} from "react";
|
|
8
|
-
import { CardRoot as CardRootSlot } from "../card.slots";
|
|
9
|
-
import type { CardProps } from "../card.types";
|
|
10
|
-
import { Stack } from "../../stack";
|
|
11
|
-
import { mergeProps, useFocusRing } from "react-aria";
|
|
12
|
-
|
|
13
|
-
type CardContextValue = {
|
|
14
|
-
setHeader: (header: React.ReactNode) => void;
|
|
15
|
-
setContent: (content: React.ReactNode) => void;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export const CardContext = createContext<CardContextValue | undefined>(
|
|
19
|
-
undefined
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
const CardRoot = forwardRef<HTMLDivElement, CardProps>(
|
|
23
|
-
({ children, ...props }, ref) => {
|
|
24
|
-
const { isFocused, isFocusVisible, focusProps } = useFocusRing();
|
|
25
|
-
const [headerNode, setHeader] = useState<ReactNode>(null);
|
|
26
|
-
const [contentNode, setContent] = useState<ReactNode>(null);
|
|
27
|
-
|
|
28
|
-
// Memoize the context value so we don't cause unnecessary re-renders
|
|
29
|
-
const contextValue = useMemo(
|
|
30
|
-
() => ({
|
|
31
|
-
setHeader,
|
|
32
|
-
setContent,
|
|
33
|
-
}),
|
|
34
|
-
[setHeader, setContent]
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<CardContext.Provider value={contextValue}>
|
|
39
|
-
<CardRootSlot
|
|
40
|
-
ref={ref}
|
|
41
|
-
{...mergeProps(props, focusProps)}
|
|
42
|
-
data-focus={isFocused || undefined}
|
|
43
|
-
data-focus-visible={isFocusVisible || undefined}
|
|
44
|
-
tabIndex={0}
|
|
45
|
-
>
|
|
46
|
-
{/* Always render them in this order/layout to protect consumers */}
|
|
47
|
-
<Stack direction="column" gap="200">
|
|
48
|
-
{headerNode}
|
|
49
|
-
{contentNode}
|
|
50
|
-
</Stack>
|
|
51
|
-
|
|
52
|
-
{/* Render all consumer sub-components, including our own */}
|
|
53
|
-
{children}
|
|
54
|
-
</CardRootSlot>
|
|
55
|
-
</CardContext.Provider>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
CardRoot.displayName = "Card.Root";
|
|
61
|
-
|
|
62
|
-
export default CardRoot;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
id: Components-Checkbox
|
|
3
|
-
title: Checkbox
|
|
4
|
-
description: displays a checkbox and an associated label
|
|
5
|
-
documentState: InitialDraft
|
|
6
|
-
order: 999
|
|
7
|
-
menu:
|
|
8
|
-
- Components
|
|
9
|
-
- Inputs
|
|
10
|
-
- Checkbox
|
|
11
|
-
tags:
|
|
12
|
-
- component
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
# Checkbox
|
|
16
|
-
|
|
17
|
-
displays a checkbox and an associated label
|
|
18
|
-
|
|
19
|
-
## With label
|
|
20
|
-
|
|
21
|
-
A checkbox with a visible label.
|
|
22
|
-
|
|
23
|
-
```jsx-live
|
|
24
|
-
const App = () => <Checkbox>I am a Checkbox</Checkbox>
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Without visible label
|
|
28
|
-
|
|
29
|
-
A checkbox without a visible label.
|
|
30
|
-
|
|
31
|
-
```jsx-live
|
|
32
|
-
const App = () => <Checkbox aria-label="I am a Checkbox"/>
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
## Controlled Checkbox
|
|
36
|
-
|
|
37
|
-
A checkbox that is controlled by a state.
|
|
38
|
-
|
|
39
|
-
```jsx-live
|
|
40
|
-
const App = () => {
|
|
41
|
-
|
|
42
|
-
const [isSelected, setIsSelected] = useState(true)
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<Checkbox isSelected={isSelected} onChange={(v)=>setIsSelected(v)}>
|
|
46
|
-
Controlled Checkbox
|
|
47
|
-
</Checkbox>
|
|
48
|
-
)
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Disabled Checkbox
|
|
53
|
-
|
|
54
|
-
A checkbox that is disabled.
|
|
55
|
-
|
|
56
|
-
```jsx-live
|
|
57
|
-
const App = () => <Checkbox isDisabled>Disabled Checkbox</Checkbox>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
## Invalid Checkbox
|
|
61
|
-
|
|
62
|
-
A checkbox that is marked as invalid.
|
|
63
|
-
|
|
64
|
-
```jsx-live
|
|
65
|
-
const App = () => <Checkbox isInvalid>Invalid Checkbox</Checkbox>
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Indeterminate Checkbox
|
|
69
|
-
|
|
70
|
-
A checkbox that is in an indeterminate state.
|
|
71
|
-
|
|
72
|
-
```jsx-live
|
|
73
|
-
const App = () => <Checkbox isIndeterminate>Indeterminate Checkbox</Checkbox>
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
## Props
|
|
77
|
-
|
|
78
|
-
<PropTable id="Checkbox" />
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { defineSlotRecipe } from "@chakra-ui/react";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Recipe configuration for the Checkbox component.
|
|
5
|
-
* Defines the styling variants and base styles using Chakra UI's recipe system.
|
|
6
|
-
*/
|
|
7
|
-
export const checkboxSlotRecipe = defineSlotRecipe({
|
|
8
|
-
slots: ["root", "label", "indicator"],
|
|
9
|
-
// Unique class name prefix for the component
|
|
10
|
-
className: "nimbus-checkbox",
|
|
11
|
-
|
|
12
|
-
base: {
|
|
13
|
-
root: {
|
|
14
|
-
colorPalette: "primary",
|
|
15
|
-
display: "inline-flex",
|
|
16
|
-
gap: "200",
|
|
17
|
-
alignItems: "center",
|
|
18
|
-
verticalAlign: "top",
|
|
19
|
-
minWidth: "600",
|
|
20
|
-
minHeight: "600",
|
|
21
|
-
|
|
22
|
-
["&[data-disabled='true']"]: {
|
|
23
|
-
layerStyle: "disabled",
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
label: {
|
|
27
|
-
flexShrink: 0,
|
|
28
|
-
userSelect: "none",
|
|
29
|
-
color: "neutral.11",
|
|
30
|
-
|
|
31
|
-
["&[data-invalid='true']"]: {
|
|
32
|
-
color: "error.11",
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
indicator: {
|
|
36
|
-
position: "relative",
|
|
37
|
-
display: "flex",
|
|
38
|
-
flexShrink: 0,
|
|
39
|
-
alignItems: "center",
|
|
40
|
-
justifyContent: "center",
|
|
41
|
-
border: "solid-50",
|
|
42
|
-
borderRadius: "50",
|
|
43
|
-
focusRing: "outside",
|
|
44
|
-
borderColor: "neutral.9",
|
|
45
|
-
bg: "transparent",
|
|
46
|
-
color: "neutral.11",
|
|
47
|
-
|
|
48
|
-
_icon: {
|
|
49
|
-
w: "350",
|
|
50
|
-
h: "350",
|
|
51
|
-
},
|
|
52
|
-
|
|
53
|
-
"&:hover": {
|
|
54
|
-
borderColor: "neutral.10",
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
["&[data-invalid='true']"]: {
|
|
58
|
-
bg: "transparent",
|
|
59
|
-
borderColor: "error.9",
|
|
60
|
-
color: "error.11",
|
|
61
|
-
|
|
62
|
-
"&:hover": {
|
|
63
|
-
borderColor: "error.10",
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
|
|
67
|
-
["&[data-selected='true'], &[data-indeterminate='true']"]: {
|
|
68
|
-
bg: "colorPalette.9",
|
|
69
|
-
borderColor: "colorPalette.9",
|
|
70
|
-
color: "colorPalette.contrast",
|
|
71
|
-
|
|
72
|
-
"&:hover": {
|
|
73
|
-
bg: "colorPalette.10",
|
|
74
|
-
borderColor: "colorPalette.10",
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
"&[data-invalid='true']": {
|
|
78
|
-
bg: "error.9",
|
|
79
|
-
borderColor: "error.9",
|
|
80
|
-
color: "error.contrast",
|
|
81
|
-
|
|
82
|
-
"&:hover": {
|
|
83
|
-
bg: "error.10",
|
|
84
|
-
borderColor: "error.10",
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
variants: {
|
|
91
|
-
size: {
|
|
92
|
-
md: {
|
|
93
|
-
label: {
|
|
94
|
-
fontSize: "350",
|
|
95
|
-
fontWeight: "400",
|
|
96
|
-
lineHeight: "400",
|
|
97
|
-
},
|
|
98
|
-
indicator: {
|
|
99
|
-
w: "400",
|
|
100
|
-
h: "400",
|
|
101
|
-
zIndex: 1,
|
|
102
|
-
_after: {
|
|
103
|
-
position: "absolute",
|
|
104
|
-
content: "''",
|
|
105
|
-
width: "600",
|
|
106
|
-
height: "600",
|
|
107
|
-
zIndex: 0,
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
defaultVariants: {
|
|
114
|
-
size: "md",
|
|
115
|
-
},
|
|
116
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-empty-object-type */
|
|
2
|
-
import {
|
|
3
|
-
createSlotRecipeContext,
|
|
4
|
-
type HTMLChakraProps,
|
|
5
|
-
type RecipeVariantProps,
|
|
6
|
-
} from "@chakra-ui/react";
|
|
7
|
-
import { checkboxSlotRecipe } from "./checkbox.recipe";
|
|
8
|
-
|
|
9
|
-
const { withProvider, withContext } = createSlotRecipeContext({
|
|
10
|
-
key: "checkbox",
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export interface CheckboxRootProps
|
|
14
|
-
extends HTMLChakraProps<
|
|
15
|
-
"label",
|
|
16
|
-
RecipeVariantProps<typeof checkboxSlotRecipe>
|
|
17
|
-
> {}
|
|
18
|
-
export const CheckboxRoot = withProvider<HTMLLabelElement, CheckboxRootProps>(
|
|
19
|
-
"label",
|
|
20
|
-
"root"
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
interface CheckboxLabelProps extends HTMLChakraProps<"span"> {}
|
|
24
|
-
export const CheckboxLabel = withContext<HTMLSpanElement, CheckboxLabelProps>(
|
|
25
|
-
"span",
|
|
26
|
-
"label"
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
interface ChekcboxIndicatorProps extends HTMLChakraProps<"span"> {}
|
|
30
|
-
export const CheckboxIndicator = withContext<
|
|
31
|
-
HTMLSpanElement,
|
|
32
|
-
ChekcboxIndicatorProps
|
|
33
|
-
>("span", "indicator");
|