@commercetools/nimbus 0.0.1
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/.storybook/apca-check/index.ts +150 -0
- package/.storybook/main.ts +64 -0
- package/.storybook/preview.tsx +92 -0
- package/.storybook/vitest.setup.ts +13 -0
- package/README.md +13 -0
- package/docs/architecture-decisions/adr-0001-consumer-component-apis.md +177 -0
- package/docs/architecture-decisions/adr-0002-compound-component-extraction.md +82 -0
- package/package.json +64 -0
- package/src/components/accordion/accordion-context.tsx +17 -0
- package/src/components/accordion/accordion.mdx +172 -0
- package/src/components/accordion/accordion.recipe.tsx +98 -0
- package/src/components/accordion/accordion.slots.tsx +39 -0
- package/src/components/accordion/accordion.stories.tsx +188 -0
- package/src/components/accordion/accordion.tsx +16 -0
- package/src/components/accordion/accordion.types.tsx +54 -0
- package/src/components/accordion/components/accordion-content.tsx +28 -0
- package/src/components/accordion/components/accordion-group.tsx +27 -0
- package/src/components/accordion/components/accordion-header.tsx +63 -0
- package/src/components/accordion/components/accordion-item.tsx +87 -0
- package/src/components/accordion/index.ts +2 -0
- package/src/components/alert/alert.mdx +92 -0
- package/src/components/alert/alert.recipe.tsx +65 -0
- package/src/components/alert/alert.slots.tsx +46 -0
- package/src/components/alert/alert.stories.tsx +308 -0
- package/src/components/alert/alert.tsx +18 -0
- package/src/components/alert/alert.types.tsx +70 -0
- package/src/components/alert/components/alert.actions.tsx +27 -0
- package/src/components/alert/components/alert.description.tsx +27 -0
- package/src/components/alert/components/alert.dismiss-button.tsx +41 -0
- package/src/components/alert/components/alert.root.tsx +92 -0
- package/src/components/alert/components/alert.title.tsx +29 -0
- package/src/components/alert/index.ts +2 -0
- package/src/components/avatar/avatar.mdx +80 -0
- package/src/components/avatar/avatar.recipe.tsx +36 -0
- package/src/components/avatar/avatar.slots.tsx +16 -0
- package/src/components/avatar/avatar.stories.tsx +136 -0
- package/src/components/avatar/avatar.tsx +34 -0
- package/src/components/avatar/avatar.types.ts +33 -0
- package/src/components/avatar/index.ts +2 -0
- package/src/components/badge/badge.mdx +91 -0
- package/src/components/badge/badge.recipe.tsx +72 -0
- package/src/components/badge/badge.slots.tsx +8 -0
- package/src/components/badge/badge.stories.tsx +124 -0
- package/src/components/badge/badge.tsx +35 -0
- package/src/components/badge/badge.types.tsx +40 -0
- package/src/components/badge/index.ts +2 -0
- package/src/components/bleed/bleed.tsx +1 -0
- package/src/components/bleed/index.ts +1 -0
- package/src/components/box/box.mdx +115 -0
- package/src/components/box/box.stories.tsx +71 -0
- package/src/components/box/box.tsx +11 -0
- package/src/components/box/index.ts +1 -0
- package/src/components/button/button.mdx +169 -0
- package/src/components/button/button.recipe.ts +185 -0
- package/src/components/button/button.slots.tsx +45 -0
- package/src/components/button/button.stories.tsx +369 -0
- package/src/components/button/button.tsx +37 -0
- package/src/components/button/button.types.ts +14 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/card/card.mdx +92 -0
- package/src/components/card/card.recipe.tsx +71 -0
- package/src/components/card/card.slots.tsx +50 -0
- package/src/components/card/card.stories.tsx +175 -0
- package/src/components/card/card.tsx +9 -0
- package/src/components/card/card.types.ts +22 -0
- package/src/components/card/components/card.content.tsx +29 -0
- package/src/components/card/components/card.header.tsx +28 -0
- package/src/components/card/components/card.root.tsx +62 -0
- package/src/components/card/index.ts +2 -0
- package/src/components/checkbox/checkbox.mdx +78 -0
- package/src/components/checkbox/checkbox.recipe.tsx +116 -0
- package/src/components/checkbox/checkbox.slots.tsx +33 -0
- package/src/components/checkbox/checkbox.stories.tsx +200 -0
- package/src/components/checkbox/checkbox.tsx +77 -0
- package/src/components/checkbox/checkbox.types.tsx +22 -0
- package/src/components/checkbox/index.ts +2 -0
- package/src/components/code/code.mdx +17 -0
- package/src/components/code/code.recipe.ts +63 -0
- package/src/components/code/code.tsx +1 -0
- package/src/components/code/index.ts +1 -0
- package/src/components/dialog/dialog.mdx +20 -0
- package/src/components/dialog/dialog.recipe.ts +254 -0
- package/src/components/dialog/dialog.tsx +61 -0
- package/src/components/dialog/index.ts +1 -0
- package/src/components/em/em.mdx +17 -0
- package/src/components/em/em.tsx +1 -0
- package/src/components/em/index.ts +1 -0
- package/src/components/flex/flex.mdx +41 -0
- package/src/components/flex/flex.tsx +1 -0
- package/src/components/flex/index.ts +1 -0
- package/src/components/grid/grid.mdx +156 -0
- package/src/components/grid/grid.stories.tsx +151 -0
- package/src/components/grid/grid.tsx +29 -0
- package/src/components/grid/index.ts +1 -0
- package/src/components/heading/heading.mdx +23 -0
- package/src/components/heading/heading.recipe.ts +49 -0
- package/src/components/heading/heading.tsx +1 -0
- package/src/components/heading/index.ts +1 -0
- package/src/components/highlight/highlight.mdx +18 -0
- package/src/components/highlight/highlight.tsx +1 -0
- package/src/components/highlight/index.ts +1 -0
- package/src/components/icon-button/icon-button.mdx +98 -0
- package/src/components/icon-button/icon-button.stories.tsx +188 -0
- package/src/components/icon-button/icon-button.tsx +21 -0
- package/src/components/icon-button/icon-button.types.tsx +10 -0
- package/src/components/icon-button/index.ts +2 -0
- package/src/components/index.ts +33 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input/input.mdx +20 -0
- package/src/components/input/input.recipe.ts +95 -0
- package/src/components/input/input.tsx +1 -0
- package/src/components/input-group/index.ts +1 -0
- package/src/components/input-group/input-group.mdx +20 -0
- package/src/components/input-group/input-group.tsx +44 -0
- package/src/components/kbd/index.ts +1 -0
- package/src/components/kbd/kbd.mdx +18 -0
- package/src/components/kbd/kbd.recipe.ts +57 -0
- package/src/components/kbd/kbd.tsx +1 -0
- package/src/components/link/index.ts +2 -0
- package/src/components/link/link.mdx +77 -0
- package/src/components/link/link.recipe.ts +52 -0
- package/src/components/link/link.slots.tsx +29 -0
- package/src/components/link/link.stories.tsx +204 -0
- package/src/components/link/link.tsx +38 -0
- package/src/components/link/link.types.tsx +26 -0
- package/src/components/list/index.ts +1 -0
- package/src/components/list/list.mdx +18 -0
- package/src/components/list/list.recipe.ts +68 -0
- package/src/components/list/list.tsx +9 -0
- package/src/components/loading-spinner/index.ts +2 -0
- package/src/components/loading-spinner/loading-spinner.mdx +92 -0
- package/src/components/loading-spinner/loading-spinner.recipe.tsx +70 -0
- package/src/components/loading-spinner/loading-spinner.slots.tsx +38 -0
- package/src/components/loading-spinner/loading-spinner.stories.tsx +97 -0
- package/src/components/loading-spinner/loading-spinner.tsx +50 -0
- package/src/components/loading-spinner/loading-spinner.types.tsx +21 -0
- package/src/components/nimbus-provider/color-mode.tsx +32 -0
- package/src/components/nimbus-provider/index.ts +2 -0
- package/src/components/nimbus-provider/nimbus-provider.mdx +21 -0
- package/src/components/nimbus-provider/nimbus-provider.tsx +51 -0
- package/src/components/select/components/select.clear-button.tsx +31 -0
- package/src/components/select/components/select.option-group.tsx +48 -0
- package/src/components/select/components/select.option.tsx +21 -0
- package/src/components/select/components/select.options.tsx +23 -0
- package/src/components/select/components/select.root.tsx +81 -0
- package/src/components/select/index.ts +2 -0
- package/src/components/select/select.mdx +170 -0
- package/src/components/select/select.recipe.tsx +216 -0
- package/src/components/select/select.slots.tsx +58 -0
- package/src/components/select/select.stories.tsx +841 -0
- package/src/components/select/select.tsx +18 -0
- package/src/components/select/select.types.tsx +37 -0
- package/src/components/simple-grid/index.ts +1 -0
- package/src/components/simple-grid/simple-grid.mdx +133 -0
- package/src/components/simple-grid/simple-grid.stories.tsx +143 -0
- package/src/components/simple-grid/simple-grid.tsx +31 -0
- package/src/components/stack/index.ts +1 -0
- package/src/components/stack/stack.mdx +88 -0
- package/src/components/stack/stack.stories.tsx +82 -0
- package/src/components/stack/stack.tsx +15 -0
- package/src/components/table/index.ts +1 -0
- package/src/components/table/table.mdx +23 -0
- package/src/components/table/table.recipe.ts +170 -0
- package/src/components/table/table.tsx +43 -0
- package/src/components/text/index.ts +1 -0
- package/src/components/text/text.mdx +244 -0
- package/src/components/text/text.tsx +23 -0
- package/src/components/text-input/index.ts +2 -0
- package/src/components/text-input/text-input.mdx +118 -0
- package/src/components/text-input/text-input.recipe.tsx +68 -0
- package/src/components/text-input/text-input.slots.tsx +24 -0
- package/src/components/text-input/text-input.stories.tsx +282 -0
- package/src/components/text-input/text-input.tsx +39 -0
- package/src/components/text-input/text-input.types.ts +7 -0
- package/src/components/toggle-button-group/components/toggle-button-group.button.tsx +14 -0
- package/src/components/toggle-button-group/components/toggle-button-group.root.tsx +15 -0
- package/src/components/toggle-button-group/index.ts +2 -0
- package/src/components/toggle-button-group/toggle-button-group.mdx +94 -0
- package/src/components/toggle-button-group/toggle-button-group.recipe.tsx +64 -0
- package/src/components/toggle-button-group/toggle-button-group.slots.tsx +26 -0
- package/src/components/toggle-button-group/toggle-button-group.stories.tsx +311 -0
- package/src/components/toggle-button-group/toggle-button-group.tsx +12 -0
- package/src/components/toggle-button-group/toggle-button-group.types.tsx +62 -0
- package/src/components/tooltip/index.ts +4 -0
- package/src/components/tooltip/make-element-focusable.stories.tsx +56 -0
- package/src/components/tooltip/make-element-focusable.tsx +57 -0
- package/src/components/tooltip/tooltip-trigger.stories.tsx +157 -0
- package/src/components/tooltip/tooltip-trigger.tsx +15 -0
- package/src/components/tooltip/tooltip.mdx +48 -0
- package/src/components/tooltip/tooltip.recipe.ts +26 -0
- package/src/components/tooltip/tooltip.slots.ts +35 -0
- package/src/components/tooltip/tooltip.stories.tsx +139 -0
- package/src/components/tooltip/tooltip.tsx +31 -0
- package/src/components/tooltip/tooltip.types.ts +44 -0
- package/src/components/visually-hidden/index.ts +1 -0
- package/src/components/visually-hidden/visually-hidden.mdx +61 -0
- package/src/components/visually-hidden/visually-hidden.stories.tsx +124 -0
- package/src/components/visually-hidden/visually-hidden.tsx +18 -0
- package/src/docs/accessibility.mdx +21 -0
- package/src/docs/background.mdx +154 -0
- package/src/docs/border.mdx +226 -0
- package/src/docs/changelog.mdx +17 -0
- package/src/docs/components-layout.mdx +22 -0
- package/src/docs/components.mdx +17 -0
- package/src/docs/data-display.mdx +23 -0
- package/src/docs/display.mdx +55 -0
- package/src/docs/effects.mdx +73 -0
- package/src/docs/feedback.mdx +22 -0
- package/src/docs/filters.mdx +268 -0
- package/src/docs/flex-and-grid.mdx +445 -0
- package/src/docs/forms.mdx +22 -0
- package/src/docs/generated/index.mdx +16 -0
- package/src/docs/getting-started.mdx +17 -0
- package/src/docs/home.mdx +56 -0
- package/src/docs/hooks.mdx +16 -0
- package/src/docs/inputs.mdx +21 -0
- package/src/docs/installation.mdx +60 -0
- package/src/docs/interactivity.mdx +278 -0
- package/src/docs/known-issues.mdx +19 -0
- package/src/docs/layout.mdx +301 -0
- package/src/docs/list.mdx +82 -0
- package/src/docs/markdown.mdx +234 -0
- package/src/docs/media.mdx +22 -0
- package/src/docs/naivgation.mdx +22 -0
- package/src/docs/playground.mdx +16 -0
- package/src/docs/rfcs-component-structure-rfcs.mdx +17 -0
- package/src/docs/rfcs-component-structure.mdx +74 -0
- package/src/docs/rfcs-hook-structure.mdx +59 -0
- package/src/docs/sizing.mdx +210 -0
- package/src/docs/spacing.mdx +193 -0
- package/src/docs/style-props-typography.mdx +373 -0
- package/src/docs/style-props.mdx +15 -0
- package/src/docs/svg.mdx +58 -0
- package/src/docs/tables.mdx +95 -0
- package/src/docs/toc.mdx +39 -0
- package/src/docs/tokens/animations.mdx +68 -0
- package/src/docs/tokens/aspect-ratios.mdx +21 -0
- package/src/docs/tokens/blurs.mdx +20 -0
- package/src/docs/tokens/borders.mdx +25 -0
- package/src/docs/tokens/breakpoints.mdx +35 -0
- package/src/docs/tokens/colors.mdx +86 -0
- package/src/docs/tokens/cursors.mdx +21 -0
- package/src/docs/tokens/radii.mdx +23 -0
- package/src/docs/tokens/shadows.mdx +21 -0
- package/src/docs/tokens/sizes.mdx +54 -0
- package/src/docs/tokens/spacing.mdx +35 -0
- package/src/docs/tokens/typography.mdx +61 -0
- package/src/docs/tokens/z-indices.mdx +23 -0
- package/src/docs/tokens-other.mdx +17 -0
- package/src/docs/tokens.mdx +16 -0
- package/src/docs/transforms.mdx +150 -0
- package/src/docs/transitions.mdx +164 -0
- package/src/docs/typography.mdx +17 -0
- package/src/docs/utilities.mdx +17 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-copy-to-clipboard/use-copy-to-clipboard.mdx +54 -0
- package/src/hooks/use-copy-to-clipboard/use-copy-to-clipboard.ts +1 -0
- package/src/hooks/use-hotkeys/use-hotkeys.mdx +48 -0
- package/src/hooks/use-hotkeys/use-hotkeys.stories.tsx +69 -0
- package/src/hooks/use-hotkeys/use-hotkeys.ts +1 -0
- package/src/index.ts +3 -0
- package/src/test/utils.tsx +20 -0
- package/src/theme/animation-styles.ts +52 -0
- package/src/theme/breakpoints.ts +32 -0
- package/src/theme/global-css.ts +53 -0
- package/src/theme/index.ts +35 -0
- package/src/theme/keyframes.ts +192 -0
- package/src/theme/layer-styles.ts +12 -0
- package/src/theme/recipes/index.ts +21 -0
- package/src/theme/semantic-tokens/colors.ts +55 -0
- package/src/theme/semantic-tokens/index.ts +9 -0
- package/src/theme/semantic-tokens/radii.ts +3 -0
- package/src/theme/semantic-tokens/shadows.ts +4 -0
- package/src/theme/slot-recipes/index.ts +15 -0
- package/src/theme/text-styles.ts +8 -0
- package/src/theme/tokens/animations.ts +4 -0
- package/src/theme/tokens/aspect-ratios.ts +5 -0
- package/src/theme/tokens/blurs.ts +5 -0
- package/src/theme/tokens/borders.ts +4 -0
- package/src/theme/tokens/colors.ts +8 -0
- package/src/theme/tokens/cursor.ts +4 -0
- package/src/theme/tokens/durations.ts +4 -0
- package/src/theme/tokens/easings.ts +4 -0
- package/src/theme/tokens/font-sizes.ts +4 -0
- package/src/theme/tokens/font-weights.ts +4 -0
- package/src/theme/tokens/fonts.ts +4 -0
- package/src/theme/tokens/index.ts +57 -0
- package/src/theme/tokens/letter-spacings.ts +24 -0
- package/src/theme/tokens/line-heights.ts +4 -0
- package/src/theme/tokens/radii.ts +4 -0
- package/src/theme/tokens/sizes.ts +120 -0
- package/src/theme/tokens/spacing.ts +4 -0
- package/src/theme/tokens/z-index.ts +4 -0
- package/src/utils/extractStyleProps.ts +26 -0
- package/src/utils/fixedForwardRef.ts +17 -0
- package/tsconfig.json +38 -0
- package/vite.config.ts +54 -0
- package/vitest.config.ts +50 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { SelectRoot as _SelectRoot } from "./components/select.root";
|
|
2
|
+
import { SelectOptions as _SelectOptions } from "./components/select.options";
|
|
3
|
+
import { SelectOption as _SelectOption } from "./components/select.option";
|
|
4
|
+
import { SelectOptionGroup as _SelectOptionGroup } from "./components/select.option-group";
|
|
5
|
+
|
|
6
|
+
export const Select = {
|
|
7
|
+
Root: _SelectRoot,
|
|
8
|
+
Options: _SelectOptions,
|
|
9
|
+
Option: _SelectOption,
|
|
10
|
+
OptionGroup: _SelectOptionGroup,
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* todo: get rid of this, this is needed for the react-docgen-typescript script
|
|
15
|
+
* that is parsing the typescript types for our documentation. The _ underscores
|
|
16
|
+
* serve as a reminder that this exports are awkward and should not be used.
|
|
17
|
+
*/
|
|
18
|
+
export { _SelectRoot, _SelectOptions, _SelectOption, _SelectOptionGroup };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type {
|
|
3
|
+
SelectOptionsSlotProps,
|
|
4
|
+
SelectOptionSlotProps,
|
|
5
|
+
SelectRootSlotProps,
|
|
6
|
+
SelectOptionGroupSlotProps,
|
|
7
|
+
} from "./select.slots";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
type SelectProps as RaSelectProps,
|
|
11
|
+
type ListBoxProps as RaListBoxProps,
|
|
12
|
+
type ListBoxItemProps as RaListBoxItemProps,
|
|
13
|
+
type ListBoxSectionProps as RaListBoxSectionProps,
|
|
14
|
+
} from "react-aria-components";
|
|
15
|
+
|
|
16
|
+
export interface SelectRootProps extends SelectRootSlotProps, RaSelectProps {
|
|
17
|
+
/** set to true if Select is currently busy with something */
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
/** Children must be ReactNode, no render props/functions allowed */
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Fix the incompatible event handler types by using a more specific type
|
|
24
|
+
export interface SelectOptionsProps<T>
|
|
25
|
+
extends RaListBoxProps<T>,
|
|
26
|
+
Omit<SelectOptionsSlotProps, keyof RaListBoxProps<T>> {}
|
|
27
|
+
|
|
28
|
+
export interface SelectOptionProps<T>
|
|
29
|
+
extends Omit<RaListBoxItemProps<T>, keyof SelectOptionSlotProps>,
|
|
30
|
+
SelectOptionSlotProps {}
|
|
31
|
+
|
|
32
|
+
export interface SelectOptionGroupProps<T>
|
|
33
|
+
extends RaListBoxSectionProps<T>,
|
|
34
|
+
Omit<SelectOptionGroupSlotProps, keyof RaListBoxSectionProps<T>> {
|
|
35
|
+
/** the label for the section */
|
|
36
|
+
label: string;
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./simple-grid";
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: SimpleGrid
|
|
3
|
+
title: SimpleGrid
|
|
4
|
+
description: displays a simple grid / matrix
|
|
5
|
+
documentState: InitialDraft
|
|
6
|
+
order: 999
|
|
7
|
+
menu:
|
|
8
|
+
- Components
|
|
9
|
+
- Layout
|
|
10
|
+
- SimpleGrid
|
|
11
|
+
tags:
|
|
12
|
+
- grid
|
|
13
|
+
- simple
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# SimpleGrid
|
|
17
|
+
|
|
18
|
+
SimpleGrid offers an intuitive way to easily create responsive grid layouts.
|
|
19
|
+
|
|
20
|
+
## Basic Usage
|
|
21
|
+
|
|
22
|
+
Use SimpleGrid → When you need a quick, responsive, equal-sized grid (e.g.,
|
|
23
|
+
product listings, image galleries).
|
|
24
|
+
|
|
25
|
+
```jsx
|
|
26
|
+
import { Grid } from "@commercetools/nimbus";
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```jsx-live
|
|
30
|
+
const App = () => (
|
|
31
|
+
<SimpleGrid gap="100">
|
|
32
|
+
<Box key="1" p="400" bg="neutral.7">
|
|
33
|
+
Item 1
|
|
34
|
+
</Box>
|
|
35
|
+
<Box key="2" p="400" bg="neutral.7">
|
|
36
|
+
Item 2
|
|
37
|
+
</Box>
|
|
38
|
+
</SimpleGrid>
|
|
39
|
+
)
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## With Columns
|
|
43
|
+
|
|
44
|
+
Use the columns prop to define the number of columns in the grid layout.
|
|
45
|
+
|
|
46
|
+
```jsx-live
|
|
47
|
+
const App = () => (
|
|
48
|
+
<SimpleGrid gap="100" columns={2}>
|
|
49
|
+
<Box key="1" p="400" bg="neutral.7">
|
|
50
|
+
Item 1
|
|
51
|
+
</Box>
|
|
52
|
+
<Box key="2" p="400" bg="neutral.7">
|
|
53
|
+
Item 2
|
|
54
|
+
</Box>
|
|
55
|
+
<Box key="3" p="400" bg="neutral.7">
|
|
56
|
+
Item 3
|
|
57
|
+
</Box>
|
|
58
|
+
<Box key="4" p="400" bg="neutral.7">
|
|
59
|
+
Item 4
|
|
60
|
+
</Box>
|
|
61
|
+
</SimpleGrid>
|
|
62
|
+
)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Auto Responsive layout
|
|
66
|
+
|
|
67
|
+
An Auto-Responsive Grid dynamically adjusts the number of columns and item sizes
|
|
68
|
+
based on the viewport width, ensuring an adaptive and fluid layout. adjust
|
|
69
|
+
viewport to see layout rearrangements.
|
|
70
|
+
|
|
71
|
+
```jsx-live
|
|
72
|
+
const App = () => (
|
|
73
|
+
<SimpleGrid gap="100" minChildWidth="sm">
|
|
74
|
+
<Box key="1" p="400" bg="neutral.7">
|
|
75
|
+
Item 1
|
|
76
|
+
</Box>
|
|
77
|
+
<Box key="2" p="400" bg="neutral.7">
|
|
78
|
+
Item 2
|
|
79
|
+
</Box>
|
|
80
|
+
<Box key="3" p="400" bg="neutral.7">
|
|
81
|
+
Item 3
|
|
82
|
+
</Box>
|
|
83
|
+
<Box key="4" p="400" bg="neutral.7">
|
|
84
|
+
Item 4
|
|
85
|
+
</Box>
|
|
86
|
+
</SimpleGrid>
|
|
87
|
+
)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Simple Grid With ColSpan
|
|
91
|
+
|
|
92
|
+
```jsx-live
|
|
93
|
+
const App = () => (
|
|
94
|
+
<SimpleGrid
|
|
95
|
+
columns={{ base: 2, md: 4 }}
|
|
96
|
+
gap={{ base: "600", md: "1000" }}
|
|
97
|
+
>
|
|
98
|
+
<SimpleGrid.Item colSpan={{ base: 1, md: 3 }}>
|
|
99
|
+
<Box height="20" p="400" bg="neutral.7">
|
|
100
|
+
Column 1
|
|
101
|
+
</Box>
|
|
102
|
+
</SimpleGrid.Item>
|
|
103
|
+
<SimpleGrid.Item colSpan={{ base: 1, md: 1 }}>
|
|
104
|
+
<Box height="20" p="400" bg="neutral.7">
|
|
105
|
+
Column 2
|
|
106
|
+
</Box>
|
|
107
|
+
</SimpleGrid.Item>
|
|
108
|
+
</SimpleGrid>
|
|
109
|
+
)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## With Row And Column Gap
|
|
113
|
+
|
|
114
|
+
```jsx-live
|
|
115
|
+
const App = () => (
|
|
116
|
+
<SimpleGrid rowGap="400" columnGap="200" columns={2}>
|
|
117
|
+
<Box key="1" p="400" bg="neutral.7">
|
|
118
|
+
Item 1
|
|
119
|
+
</Box>
|
|
120
|
+
<Box key="2" p="400" bg="neutral.7">
|
|
121
|
+
Item 2
|
|
122
|
+
</Box>
|
|
123
|
+
<Box key="3" p="400" bg="neutral.7">
|
|
124
|
+
Item 3
|
|
125
|
+
</Box>
|
|
126
|
+
<Box key="4" p="400" bg="neutral.7">
|
|
127
|
+
Item 4
|
|
128
|
+
</Box>
|
|
129
|
+
</SimpleGrid>
|
|
130
|
+
)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
<PropTable id="SimpleGrid" />
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Box } from "../box";
|
|
3
|
+
import { SimpleGrid } from "./simple-grid";
|
|
4
|
+
import { within, expect } from "@storybook/test";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Storybook metadata configuration
|
|
8
|
+
* - title: determines the location in the sidebar
|
|
9
|
+
* - component: references the component being documented
|
|
10
|
+
*/
|
|
11
|
+
const meta: Meta<typeof SimpleGrid> = {
|
|
12
|
+
title: "components/SimpleGrid",
|
|
13
|
+
component: SimpleGrid,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default meta;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Story type for TypeScript support
|
|
20
|
+
* StoryObj provides type checking for our story configurations
|
|
21
|
+
*/
|
|
22
|
+
type Story = StoryObj<typeof SimpleGrid>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Base story
|
|
26
|
+
* Demonstrates the most basic implementation
|
|
27
|
+
* Uses the args pattern for dynamic control panel inputs
|
|
28
|
+
*/
|
|
29
|
+
export const Base: Story = {
|
|
30
|
+
args: {
|
|
31
|
+
gap: "100",
|
|
32
|
+
["aria-label"]: "test-layout",
|
|
33
|
+
// @ts-expect-error - data-testid is not a valid prop
|
|
34
|
+
["data-testid"]: "test",
|
|
35
|
+
|
|
36
|
+
children: [
|
|
37
|
+
<Box key="1" p="400" bg="neutral.7">
|
|
38
|
+
Item 1
|
|
39
|
+
</Box>,
|
|
40
|
+
<Box key="2" p="400" bg="neutral.7">
|
|
41
|
+
Item 2
|
|
42
|
+
</Box>,
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
play: async ({ canvasElement, step }) => {
|
|
46
|
+
const canvas = within(canvasElement);
|
|
47
|
+
const layout = canvas.getByTestId("test");
|
|
48
|
+
|
|
49
|
+
await step("Forwards data- & aria-attributes", async () => {
|
|
50
|
+
await expect(layout).toHaveAttribute("data-testid", "test");
|
|
51
|
+
await expect(layout).toHaveAttribute("aria-label", "test-layout");
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export const WithColumns: Story = {
|
|
57
|
+
args: {
|
|
58
|
+
gap: "100",
|
|
59
|
+
columns: 2,
|
|
60
|
+
children: [
|
|
61
|
+
<Box key="1" p="400" bg="neutral.7">
|
|
62
|
+
Item 1
|
|
63
|
+
</Box>,
|
|
64
|
+
<Box key="2" p="400" bg="neutral.7">
|
|
65
|
+
Item 2
|
|
66
|
+
</Box>,
|
|
67
|
+
<Box key="3" p="400" bg="neutral.7">
|
|
68
|
+
Item 3
|
|
69
|
+
</Box>,
|
|
70
|
+
<Box key="4" p="400" bg="neutral.7">
|
|
71
|
+
Item 4
|
|
72
|
+
</Box>,
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Adjust the viewport to see variations in the layout
|
|
79
|
+
*/
|
|
80
|
+
export const AutoResponsive: Story = {
|
|
81
|
+
args: {
|
|
82
|
+
gap: "100",
|
|
83
|
+
minChildWidth: "sm",
|
|
84
|
+
children: [
|
|
85
|
+
<Box key="1" p="400" bg="neutral.7">
|
|
86
|
+
Item 1
|
|
87
|
+
</Box>,
|
|
88
|
+
<Box key="2" p="400" bg="neutral.7">
|
|
89
|
+
Item 2
|
|
90
|
+
</Box>,
|
|
91
|
+
<Box key="3" p="400" bg="neutral.7">
|
|
92
|
+
Item 3
|
|
93
|
+
</Box>,
|
|
94
|
+
<Box key="4" p="400" bg="neutral.7">
|
|
95
|
+
Item 4
|
|
96
|
+
</Box>,
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const SimpleGridWithColSpan: Story = {
|
|
102
|
+
render: () => {
|
|
103
|
+
return (
|
|
104
|
+
<SimpleGrid
|
|
105
|
+
columns={{ base: 2, md: 4 }}
|
|
106
|
+
gap={{ base: "600", md: "1000" }}
|
|
107
|
+
>
|
|
108
|
+
<SimpleGrid.Item colSpan={{ base: 1, md: 3 }}>
|
|
109
|
+
<Box height="20" p="400" bg="neutral.7">
|
|
110
|
+
Column 1
|
|
111
|
+
</Box>
|
|
112
|
+
</SimpleGrid.Item>
|
|
113
|
+
<SimpleGrid.Item colSpan={{ base: 1, md: 1 }}>
|
|
114
|
+
<Box height="20" p="400" bg="neutral.7">
|
|
115
|
+
Column 2
|
|
116
|
+
</Box>
|
|
117
|
+
</SimpleGrid.Item>
|
|
118
|
+
</SimpleGrid>
|
|
119
|
+
);
|
|
120
|
+
},
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export const RowAndColumnGap: Story = {
|
|
124
|
+
args: {
|
|
125
|
+
columns: 2,
|
|
126
|
+
columnGap: "200",
|
|
127
|
+
rowGap: "400",
|
|
128
|
+
children: [
|
|
129
|
+
<Box key="1" p="400" bg="neutral.7">
|
|
130
|
+
Item 1
|
|
131
|
+
</Box>,
|
|
132
|
+
<Box key="2" p="400" bg="neutral.7">
|
|
133
|
+
Item 2
|
|
134
|
+
</Box>,
|
|
135
|
+
<Box key="3" p="400" bg="neutral.7">
|
|
136
|
+
Item 3
|
|
137
|
+
</Box>,
|
|
138
|
+
<Box key="4" p="400" bg="neutral.7">
|
|
139
|
+
Item 4
|
|
140
|
+
</Box>,
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
SimpleGrid as ChakraSimpleGrid,
|
|
4
|
+
GridItem,
|
|
5
|
+
type SimpleGridProps as ChakraSimpleGridProps,
|
|
6
|
+
} from "@chakra-ui/react";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SimpleGrid
|
|
10
|
+
* ============================================================
|
|
11
|
+
* The SimpleGrid Layout Component provides a flexible and responsive way to structure content.
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
*
|
|
15
|
+
* - allows forwarding refs to the underlying DOM element
|
|
16
|
+
*/
|
|
17
|
+
export interface SimpleGridProps extends ChakraSimpleGridProps {
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const GridComponent = forwardRef<HTMLDivElement, SimpleGridProps>(
|
|
22
|
+
(props, ref) => {
|
|
23
|
+
return <ChakraSimpleGrid ref={ref} {...props} />;
|
|
24
|
+
}
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
GridComponent.displayName = "SimpleGrid";
|
|
28
|
+
|
|
29
|
+
export const SimpleGrid = Object.assign(GridComponent, {
|
|
30
|
+
Item: GridItem,
|
|
31
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Stack, type StackProps } from "./stack";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Components-Stack
|
|
3
|
+
title: Stack
|
|
4
|
+
description:
|
|
5
|
+
An easily customizable Stack component, re-exported from Chakra UI, that
|
|
6
|
+
provides a consistent layout structure across different products.
|
|
7
|
+
documentState: InitialDraft
|
|
8
|
+
order: 999
|
|
9
|
+
menu:
|
|
10
|
+
- Components
|
|
11
|
+
- Layout
|
|
12
|
+
- Stack
|
|
13
|
+
tags:
|
|
14
|
+
- component
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# Stack
|
|
18
|
+
|
|
19
|
+
An easily customizable Stack component, re-exported from
|
|
20
|
+
[Chakra UI stack component](https://www.chakra-ui.com/docs/components/stack) ,
|
|
21
|
+
that provides a consistent and responsive layout structure across different
|
|
22
|
+
products.
|
|
23
|
+
|
|
24
|
+
Stacks allow you to effortlessly build flexible layouts with automatic
|
|
25
|
+
distribution. You can arrange elements horizontally or vertically, adding
|
|
26
|
+
spacing and/or separators between each item.
|
|
27
|
+
|
|
28
|
+
## Basic Usage
|
|
29
|
+
|
|
30
|
+
```jsx
|
|
31
|
+
import { Stack } from "@commercetools/nimbus";
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```jsx-live
|
|
35
|
+
const App = () => (
|
|
36
|
+
<Stack>
|
|
37
|
+
{" "}
|
|
38
|
+
<Box key="1" p="400" bg="primary.7">
|
|
39
|
+
Item 1
|
|
40
|
+
</Box>
|
|
41
|
+
<Box key="1" p="400" bg="primary.7">
|
|
42
|
+
Item 2
|
|
43
|
+
</Box>
|
|
44
|
+
</Stack>
|
|
45
|
+
);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### With Direction
|
|
49
|
+
|
|
50
|
+
Use the direction prop to change the layout direction. The default direction is
|
|
51
|
+
"column" (vertical). Set it to "row" for horizontal stacking.
|
|
52
|
+
|
|
53
|
+
```jsx-live
|
|
54
|
+
const App = () => (
|
|
55
|
+
<Stack direction="row">
|
|
56
|
+
<Box key="1" p="400" bg="primary.7">Item 1</Box>
|
|
57
|
+
<Box key="1" p="400" bg="primary.7">Item 2</Box>
|
|
58
|
+
<Box key="1" p="400" bg="primary.7">Item 3</Box>
|
|
59
|
+
</Stack>
|
|
60
|
+
)
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### With Spacing
|
|
64
|
+
|
|
65
|
+
```jsx-live
|
|
66
|
+
const App = () => (
|
|
67
|
+
<Stack gap="100">
|
|
68
|
+
<Box key="1" p="400" bg="primary.7">Spaced Item 1</Box>
|
|
69
|
+
<Box key="1" p="400" bg="primary.7">Spaced Item 2</Box>
|
|
70
|
+
<Box key="1" p="400" bg="primary.7">Spaced Item 3</Box>
|
|
71
|
+
</Stack>
|
|
72
|
+
)
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### With Separator
|
|
76
|
+
|
|
77
|
+
Add a visual separator between stacked items using the separator prop. You can
|
|
78
|
+
also use custom separators like icons or styled elements.
|
|
79
|
+
|
|
80
|
+
```jsx-live
|
|
81
|
+
const App = () => (
|
|
82
|
+
<Stack separator={<hr />}>
|
|
83
|
+
<Box key="1" p="400" bg="primary.7">Spaced Item with separator 1</Box>
|
|
84
|
+
<Box key="1" p="400" bg="primary.7">Spaced Item with separator 2</Box>
|
|
85
|
+
<Box key="1" p="400" bg="primary.7">Spaced Item with separator 3</Box>
|
|
86
|
+
</Stack>
|
|
87
|
+
)
|
|
88
|
+
```
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { Box } from "../box";
|
|
3
|
+
import { Stack } from "./stack";
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Stack> = {
|
|
6
|
+
title: "Components/Stack",
|
|
7
|
+
component: Stack,
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default meta;
|
|
12
|
+
type Story = StoryObj<typeof Stack>;
|
|
13
|
+
|
|
14
|
+
export const Base: Story = {
|
|
15
|
+
args: {
|
|
16
|
+
children: [
|
|
17
|
+
<Box key="1" p="400" bg="primary.7">
|
|
18
|
+
Item 1
|
|
19
|
+
</Box>,
|
|
20
|
+
<Box key="2" p="400" bg="primary.7">
|
|
21
|
+
Item 2
|
|
22
|
+
</Box>,
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const WithDirection: Story = {
|
|
28
|
+
args: {
|
|
29
|
+
direction: "row",
|
|
30
|
+
children: [
|
|
31
|
+
<Box key="1" p="400" bg="primary.7">
|
|
32
|
+
Item 1
|
|
33
|
+
</Box>,
|
|
34
|
+
<Box key="2" p="400" bg="primary.7">
|
|
35
|
+
Item 2
|
|
36
|
+
</Box>,
|
|
37
|
+
<Box key="3" p="400" bg="primary.7">
|
|
38
|
+
Item 3
|
|
39
|
+
</Box>,
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
argTypes: {
|
|
43
|
+
direction: {
|
|
44
|
+
options: ["row", "column", "row-reverse", "column-reverse"],
|
|
45
|
+
control: { type: "radio" },
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const WithSpacing: Story = {
|
|
51
|
+
args: {
|
|
52
|
+
gap: "100",
|
|
53
|
+
children: [
|
|
54
|
+
<Box key="1" p="400" bg="primary.7">
|
|
55
|
+
Spaced Item 1
|
|
56
|
+
</Box>,
|
|
57
|
+
<Box key="2" p="400" bg="primary.7">
|
|
58
|
+
Spaced Item 2
|
|
59
|
+
</Box>,
|
|
60
|
+
<Box key="3" p="400" bg="primary.7">
|
|
61
|
+
Spaced Item 3
|
|
62
|
+
</Box>,
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export const WithSeparator: Story = {
|
|
68
|
+
args: {
|
|
69
|
+
separator: <hr />,
|
|
70
|
+
children: [
|
|
71
|
+
<Box key="1" p="400" bg="primary.7">
|
|
72
|
+
Spaced Item with separator 1
|
|
73
|
+
</Box>,
|
|
74
|
+
<Box key="2" p="400" bg="primary.7">
|
|
75
|
+
Spaced Item with separator 2
|
|
76
|
+
</Box>,
|
|
77
|
+
<Box key="3" p="400" bg="primary.7">
|
|
78
|
+
Spaced Item with separator 3
|
|
79
|
+
</Box>,
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Stack as ChakraStack,
|
|
4
|
+
type StackProps as ChakraStackProps,
|
|
5
|
+
} from "@chakra-ui/react";
|
|
6
|
+
|
|
7
|
+
export interface StackProps extends ChakraStackProps {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const Stack = forwardRef<HTMLDivElement, StackProps>((props, ref) => {
|
|
12
|
+
return <ChakraStack ref={ref} {...props} />;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
Stack.displayName = "Stack";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./table.tsx";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Table
|
|
3
|
+
title: Table
|
|
4
|
+
description: displays a table
|
|
5
|
+
documentState: InitialDraft
|
|
6
|
+
order: 999
|
|
7
|
+
menu:
|
|
8
|
+
- Components
|
|
9
|
+
- Data Display
|
|
10
|
+
- Table
|
|
11
|
+
tags:
|
|
12
|
+
- table
|
|
13
|
+
- tabular data
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Table
|
|
17
|
+
|
|
18
|
+
## Props
|
|
19
|
+
|
|
20
|
+
Render the PropTable with a `<PropTable id="TableRoot"/>` tag or - if multiple
|
|
21
|
+
components - `<PropTables id="TableRoot, TableHeader"/>`.
|
|
22
|
+
|
|
23
|
+
<PropTables ids="TableRoot, TableHeader, TableColumnHeader, TableRow, TableBody, TableCell, TableFooter" />
|