@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,29 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Grid as ChakraGrid,
|
|
4
|
+
GridItem,
|
|
5
|
+
type GridProps as ChakraGridProps,
|
|
6
|
+
} from "@chakra-ui/react";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Grid
|
|
10
|
+
* ============================================================
|
|
11
|
+
* The Grid Layout Component provides a flexible and responsive way to structure content using a two-dimensional grid system. It allows elements to be arranged in rows and columns, enabling dynamic and efficient layouts for different screen sizes.
|
|
12
|
+
*
|
|
13
|
+
* Features:
|
|
14
|
+
*
|
|
15
|
+
* - allows forwarding refs to the underlying DOM element
|
|
16
|
+
*/
|
|
17
|
+
export interface GridProps extends ChakraGridProps {
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const GridComponent = forwardRef<HTMLDivElement, GridProps>((props, ref) => {
|
|
22
|
+
return <ChakraGrid ref={ref} {...props} />;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
GridComponent.displayName = "Grid";
|
|
26
|
+
|
|
27
|
+
export const Grid = Object.assign(GridComponent, {
|
|
28
|
+
Item: GridItem,
|
|
29
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Grid, type GridProps } from "./grid";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Heading
|
|
3
|
+
title: Heading
|
|
4
|
+
description: renders a heading
|
|
5
|
+
documentState: InitialDraft
|
|
6
|
+
order: 2
|
|
7
|
+
menu:
|
|
8
|
+
- Components
|
|
9
|
+
- Typography
|
|
10
|
+
- Heading
|
|
11
|
+
tags:
|
|
12
|
+
- heading
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
# Heading
|
|
16
|
+
|
|
17
|
+
Like Text, but with predefined styles for a heading/title look and semantic
|
|
18
|
+
meaning, which makes source code easier to scan by clearly highlighting the
|
|
19
|
+
content's hierarchy and purpose.
|
|
20
|
+
|
|
21
|
+
> [!NOTE]
|
|
22
|
+
> Checkout the [Text component](/components/typography/text) for configuration
|
|
23
|
+
> options.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineRecipe } from "@chakra-ui/react";
|
|
2
|
+
|
|
3
|
+
export const headingRecipe = defineRecipe({
|
|
4
|
+
className: "nimbus-heading",
|
|
5
|
+
base: {
|
|
6
|
+
fontFamily: "heading",
|
|
7
|
+
fontWeight: "600",
|
|
8
|
+
},
|
|
9
|
+
variants: {
|
|
10
|
+
size: {
|
|
11
|
+
xs: {
|
|
12
|
+
textStyle: "xs",
|
|
13
|
+
},
|
|
14
|
+
sm: {
|
|
15
|
+
textStyle: "sm",
|
|
16
|
+
},
|
|
17
|
+
md: {
|
|
18
|
+
textStyle: "md",
|
|
19
|
+
},
|
|
20
|
+
lg: {
|
|
21
|
+
textStyle: "lg",
|
|
22
|
+
},
|
|
23
|
+
xl: {
|
|
24
|
+
textStyle: "xl",
|
|
25
|
+
},
|
|
26
|
+
"2xl": {
|
|
27
|
+
textStyle: "2xl",
|
|
28
|
+
},
|
|
29
|
+
"3xl": {
|
|
30
|
+
textStyle: "3xl",
|
|
31
|
+
},
|
|
32
|
+
"4xl": {
|
|
33
|
+
textStyle: "4xl",
|
|
34
|
+
},
|
|
35
|
+
"5xl": {
|
|
36
|
+
textStyle: "5xl",
|
|
37
|
+
},
|
|
38
|
+
"6xl": {
|
|
39
|
+
textStyle: "6xl",
|
|
40
|
+
},
|
|
41
|
+
"7xl": {
|
|
42
|
+
textStyle: "7xl",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
defaultVariants: {
|
|
47
|
+
size: "xl",
|
|
48
|
+
},
|
|
49
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Heading } from "@chakra-ui/react";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./heading.tsx";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Highlight
|
|
3
|
+
title: Highlight
|
|
4
|
+
description: highlights a substring in a string
|
|
5
|
+
documentState: InitialDraft
|
|
6
|
+
order: 999
|
|
7
|
+
menu:
|
|
8
|
+
- Components
|
|
9
|
+
- Typography
|
|
10
|
+
- Highlight
|
|
11
|
+
tags:
|
|
12
|
+
- highlight
|
|
13
|
+
- mark
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Highlight
|
|
17
|
+
|
|
18
|
+
Add description later.rr
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Highlight } from "@chakra-ui/react";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./highlight.tsx";
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Components-IconButton
|
|
3
|
+
title: IconButton
|
|
4
|
+
description: displays a button with an icon only as child
|
|
5
|
+
documentState: InitialDraft
|
|
6
|
+
order: 999
|
|
7
|
+
menu:
|
|
8
|
+
- Components
|
|
9
|
+
- Inputs
|
|
10
|
+
- IconButton
|
|
11
|
+
tags:
|
|
12
|
+
- component
|
|
13
|
+
figmaLink: >-
|
|
14
|
+
https://www.figma.com/design/AvtPX6g7OGGCRvNlatGOIY/New-Design-System?node-id=58-132&m=dev
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
# IconButton
|
|
18
|
+
|
|
19
|
+
displays a button with an icon only as child.
|
|
20
|
+
|
|
21
|
+
## Basic Usage
|
|
22
|
+
|
|
23
|
+
If unconfigured `IconButton` will default to a neutral state. It is important to
|
|
24
|
+
configure `IconButton` properly to ensure it displays as intended.
|
|
25
|
+
|
|
26
|
+
```jsx-live
|
|
27
|
+
const App = () => <IconButton><Icons.ArrowForward/></IconButton>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Sizes
|
|
31
|
+
|
|
32
|
+
Available sizes.
|
|
33
|
+
|
|
34
|
+
```jsx-live
|
|
35
|
+
const App = () => {
|
|
36
|
+
const sizes = ['md', 'xs', '2xs'];
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<Stack direction="horizontal" alignItems="center">
|
|
40
|
+
{sizes.map(size => (
|
|
41
|
+
<IconButton tone="primary" variant="solid" key={size} size={size}>
|
|
42
|
+
<Icons.AutoFixHigh/>
|
|
43
|
+
</IconButton>
|
|
44
|
+
))}
|
|
45
|
+
</Stack>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Variants
|
|
51
|
+
|
|
52
|
+
Available variants.
|
|
53
|
+
|
|
54
|
+
```jsx-live
|
|
55
|
+
const App = () => {
|
|
56
|
+
|
|
57
|
+
const variants = ['solid', 'outline', 'ghost', 'link'];
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Stack direction="horizontal">
|
|
61
|
+
{variants.map(variant => (
|
|
62
|
+
<IconButton tone="primary" key={variant} variant={variant}>
|
|
63
|
+
<Icons.AutoFixHigh/>
|
|
64
|
+
</IconButton>
|
|
65
|
+
))}
|
|
66
|
+
</Stack>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Tones
|
|
72
|
+
|
|
73
|
+
Available tones.
|
|
74
|
+
|
|
75
|
+
```jsx-live
|
|
76
|
+
const App = () => {
|
|
77
|
+
const variants = ["solid", "outline", "ghost", "link"];
|
|
78
|
+
const colors = ["primary", "error"];
|
|
79
|
+
|
|
80
|
+
return (
|
|
81
|
+
<Stack>
|
|
82
|
+
{colors.map((color) => (
|
|
83
|
+
<Stack key={color} direction="horizontal">
|
|
84
|
+
{variants.map((variant) => (
|
|
85
|
+
<IconButton colorPalette={color} key={variant} variant={variant}>
|
|
86
|
+
<Icons.AutoFixHigh/>
|
|
87
|
+
</IconButton>
|
|
88
|
+
))}
|
|
89
|
+
</Stack>
|
|
90
|
+
))}
|
|
91
|
+
</Stack>
|
|
92
|
+
);
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Props
|
|
97
|
+
|
|
98
|
+
<PropTable id="IconButton" />
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
2
|
+
import { IconButton } from "./icon-button";
|
|
3
|
+
import { Stack } from "./../stack";
|
|
4
|
+
import { Apps as DemoIcon } from "@commercetools/nimbus-icons";
|
|
5
|
+
import type { IconButtonProps } from "./icon-button.types";
|
|
6
|
+
import { createRef } from "react";
|
|
7
|
+
import { expect, fn, within, userEvent } from "@storybook/test";
|
|
8
|
+
|
|
9
|
+
const meta: Meta<typeof IconButton> = {
|
|
10
|
+
title: "components/IconButton",
|
|
11
|
+
component: IconButton,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default meta;
|
|
15
|
+
|
|
16
|
+
const sizes: IconButtonProps["size"][] = [
|
|
17
|
+
//"2xl",
|
|
18
|
+
//"xl",
|
|
19
|
+
//"lg",
|
|
20
|
+
"md",
|
|
21
|
+
//"sm",
|
|
22
|
+
"xs",
|
|
23
|
+
"2xs",
|
|
24
|
+
];
|
|
25
|
+
|
|
26
|
+
const variants: IconButtonProps["variant"][] = [
|
|
27
|
+
"solid",
|
|
28
|
+
"subtle",
|
|
29
|
+
"outline",
|
|
30
|
+
"ghost",
|
|
31
|
+
"link",
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
const tones: IconButtonProps["tone"][] = ["primary", "neutral", "critical"];
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Story type for TypeScript support
|
|
38
|
+
* StoryObj provides type checking for our story configurations
|
|
39
|
+
*/
|
|
40
|
+
type Story = StoryObj<typeof IconButton>;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Base story
|
|
44
|
+
* Demonstrates the most basic implementation
|
|
45
|
+
* Uses the args pattern for dynamic control panel inputs
|
|
46
|
+
*/
|
|
47
|
+
export const Base: Story = {
|
|
48
|
+
args: {
|
|
49
|
+
children: <DemoIcon />,
|
|
50
|
+
onPress: fn(),
|
|
51
|
+
["data-testid"]: "test",
|
|
52
|
+
["aria-label"]: "test-button",
|
|
53
|
+
},
|
|
54
|
+
play: async ({ canvasElement, args, step }) => {
|
|
55
|
+
const canvas = within(canvasElement);
|
|
56
|
+
const button = canvas.getByTestId("test");
|
|
57
|
+
const onPress = args.onPress;
|
|
58
|
+
|
|
59
|
+
await step("Uses a <button> element by default", async () => {
|
|
60
|
+
await expect(button.tagName).toBe("BUTTON");
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
await step("Forwards data- & aria-attributes", async () => {
|
|
64
|
+
await expect(button).toHaveAttribute("data-testid", "test");
|
|
65
|
+
await expect(button).toHaveAttribute("aria-label", "test-button");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// ATTENTION: react-aria does some complicated science,
|
|
69
|
+
// if there is a **KEYSTROKE** before the click (like a tab-key aiming to focus the button),
|
|
70
|
+
// the first click is not counted as a valid click
|
|
71
|
+
await step("Is clickable", async () => {
|
|
72
|
+
button.click();
|
|
73
|
+
await expect(onPress).toHaveBeenCalledTimes(1);
|
|
74
|
+
button.blur();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
await step("Is focusable with <tab> key", async () => {
|
|
78
|
+
await userEvent.tab();
|
|
79
|
+
await expect(button).toHaveFocus();
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await step("Can be triggered with enter", async () => {
|
|
83
|
+
await userEvent.keyboard("{enter}");
|
|
84
|
+
await expect(onPress).toHaveBeenCalledTimes(2);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
await step("Can be triggered with space-bar", async () => {
|
|
88
|
+
await expect(button).toHaveFocus();
|
|
89
|
+
await userEvent.keyboard(" ");
|
|
90
|
+
await expect(onPress).toHaveBeenCalledTimes(3);
|
|
91
|
+
});
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Showcase Sizes
|
|
97
|
+
*/
|
|
98
|
+
export const Sizes: Story = {
|
|
99
|
+
args: {
|
|
100
|
+
children: <DemoIcon />,
|
|
101
|
+
["aria-label"]: "test-button",
|
|
102
|
+
},
|
|
103
|
+
render: (args) => {
|
|
104
|
+
return (
|
|
105
|
+
<Stack direction="row" gap="400" alignItems="center">
|
|
106
|
+
{sizes.map((size) => (
|
|
107
|
+
<IconButton key={size as string} size={size} {...args} />
|
|
108
|
+
))}
|
|
109
|
+
</Stack>
|
|
110
|
+
);
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Showcase Variants
|
|
116
|
+
*/
|
|
117
|
+
export const Variants: Story = {
|
|
118
|
+
args: {
|
|
119
|
+
children: <DemoIcon />,
|
|
120
|
+
["aria-label"]: "test-button",
|
|
121
|
+
},
|
|
122
|
+
render: (args) => {
|
|
123
|
+
return (
|
|
124
|
+
<Stack direction="row" gap="400" alignItems="center">
|
|
125
|
+
{variants.map((variant) => (
|
|
126
|
+
<IconButton key={variant as string} {...args} variant={variant} />
|
|
127
|
+
))}
|
|
128
|
+
</Stack>
|
|
129
|
+
);
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Showcase Tones
|
|
135
|
+
*/
|
|
136
|
+
export const Tones: Story = {
|
|
137
|
+
args: {
|
|
138
|
+
children: <DemoIcon />,
|
|
139
|
+
["aria-label"]: "test-button",
|
|
140
|
+
},
|
|
141
|
+
render: (args) => {
|
|
142
|
+
return (
|
|
143
|
+
<Stack>
|
|
144
|
+
{tones.map((tone) => (
|
|
145
|
+
<Stack
|
|
146
|
+
key={tone as string}
|
|
147
|
+
direction="row"
|
|
148
|
+
gap="400"
|
|
149
|
+
alignItems="center"
|
|
150
|
+
>
|
|
151
|
+
{variants.map((variant) => (
|
|
152
|
+
<IconButton
|
|
153
|
+
key={variant as string}
|
|
154
|
+
{...args}
|
|
155
|
+
variant={variant}
|
|
156
|
+
tone={tone}
|
|
157
|
+
/>
|
|
158
|
+
))}
|
|
159
|
+
</Stack>
|
|
160
|
+
))}
|
|
161
|
+
</Stack>
|
|
162
|
+
);
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
const buttonRef = createRef<HTMLButtonElement>();
|
|
167
|
+
|
|
168
|
+
export const WithRef: Story = {
|
|
169
|
+
args: {
|
|
170
|
+
children: <DemoIcon />,
|
|
171
|
+
["aria-label"]: "test-button",
|
|
172
|
+
},
|
|
173
|
+
render: (args) => {
|
|
174
|
+
return (
|
|
175
|
+
<IconButton ref={buttonRef} {...args}>
|
|
176
|
+
{args.children}
|
|
177
|
+
</IconButton>
|
|
178
|
+
);
|
|
179
|
+
},
|
|
180
|
+
play: async ({ canvasElement, step }) => {
|
|
181
|
+
const canvas = within(canvasElement);
|
|
182
|
+
const button = canvas.getByRole("button");
|
|
183
|
+
|
|
184
|
+
await step("Does accept ref's", async () => {
|
|
185
|
+
await expect(buttonRef.current).toBe(button);
|
|
186
|
+
});
|
|
187
|
+
},
|
|
188
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import type { IconButtonProps } from "./icon-button.types";
|
|
3
|
+
import { Button } from "@/components";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* IconButton
|
|
7
|
+
* ============================================================
|
|
8
|
+
* displays a button with only an icon as child. It is based
|
|
9
|
+
* on the regular `Button` component, but with a few adjustments.
|
|
10
|
+
*/
|
|
11
|
+
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>(
|
|
12
|
+
({ children, ...props }, ref) => {
|
|
13
|
+
return (
|
|
14
|
+
<Button px={0} py={0} ref={ref} {...props}>
|
|
15
|
+
{children}
|
|
16
|
+
</Button>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
IconButton.displayName = "IconButton";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ButtonProps } from "@/components";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Main props interface for the IconButton component.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export interface IconButtonProps extends ButtonProps {
|
|
8
|
+
/** explains the intended action, required for accessibility */
|
|
9
|
+
"aria-label": string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export * from "./avatar";
|
|
2
|
+
export * from "./box";
|
|
3
|
+
export * from "./bleed";
|
|
4
|
+
export * from "./button";
|
|
5
|
+
export * from "./code";
|
|
6
|
+
export * from "./dialog";
|
|
7
|
+
export * from "./em";
|
|
8
|
+
export * from "./flex";
|
|
9
|
+
export * from "./heading";
|
|
10
|
+
export * from "./highlight";
|
|
11
|
+
export * from "./icon-button";
|
|
12
|
+
export * from "./input";
|
|
13
|
+
export * from "./input-group";
|
|
14
|
+
export * from "./kbd";
|
|
15
|
+
export * from "./link";
|
|
16
|
+
export * from "./list";
|
|
17
|
+
export * from "./simple-grid";
|
|
18
|
+
export * from "./table";
|
|
19
|
+
export * from "./text";
|
|
20
|
+
export * from "./tooltip";
|
|
21
|
+
export * from "./nimbus-provider";
|
|
22
|
+
export * from "./checkbox";
|
|
23
|
+
export * from "./stack";
|
|
24
|
+
export * from "./visually-hidden";
|
|
25
|
+
export * from "./text-input";
|
|
26
|
+
export * from "./grid";
|
|
27
|
+
export * from "./select";
|
|
28
|
+
export * from "./accordion";
|
|
29
|
+
export * from "./loading-spinner";
|
|
30
|
+
export * from "./card";
|
|
31
|
+
export * from "./badge";
|
|
32
|
+
export * from "./alert";
|
|
33
|
+
export * from "./toggle-button-group";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./input.tsx";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: Input
|
|
3
|
+
title: Input
|
|
4
|
+
description: displays a Input field
|
|
5
|
+
documentState: InitialDraft
|
|
6
|
+
order: 999
|
|
7
|
+
menu:
|
|
8
|
+
- Components
|
|
9
|
+
- Inputs
|
|
10
|
+
- Input
|
|
11
|
+
tags:
|
|
12
|
+
- text
|
|
13
|
+
- input
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Input
|
|
17
|
+
|
|
18
|
+
add description here.
|
|
19
|
+
|
|
20
|
+
<PropTable id="Input" />
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { defineRecipe } from "@chakra-ui/react";
|
|
2
|
+
|
|
3
|
+
export const inputRecipe = defineRecipe({
|
|
4
|
+
className: "nimbus-input",
|
|
5
|
+
base: {
|
|
6
|
+
width: "full",
|
|
7
|
+
minWidth: "0",
|
|
8
|
+
outline: "0",
|
|
9
|
+
position: "relative",
|
|
10
|
+
appearance: "none",
|
|
11
|
+
textAlign: "start",
|
|
12
|
+
_disabled: {
|
|
13
|
+
layerStyle: "disabled",
|
|
14
|
+
},
|
|
15
|
+
height: "var(--input-height)",
|
|
16
|
+
minW: "var(--input-height)",
|
|
17
|
+
"--focus-color": "colors.colorPalette.focusRing",
|
|
18
|
+
"--error-color": "colors.border.error",
|
|
19
|
+
"&::placeholder": {
|
|
20
|
+
color: "colorPalette.11",
|
|
21
|
+
opacity: 3 / 4,
|
|
22
|
+
},
|
|
23
|
+
_invalid: {
|
|
24
|
+
focusRingColor: "var(--error-color)",
|
|
25
|
+
borderColor: "var(--error-color)",
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
variants: {
|
|
29
|
+
size: {
|
|
30
|
+
"2xs": {
|
|
31
|
+
textStyle: "xs",
|
|
32
|
+
px: "200",
|
|
33
|
+
"--input-height": "sizes.700",
|
|
34
|
+
},
|
|
35
|
+
xs: {
|
|
36
|
+
textStyle: "xs",
|
|
37
|
+
px: "200",
|
|
38
|
+
"--input-height": "sizes.800",
|
|
39
|
+
},
|
|
40
|
+
sm: {
|
|
41
|
+
textStyle: "sm",
|
|
42
|
+
px: "250",
|
|
43
|
+
"--input-height": "sizes.900",
|
|
44
|
+
},
|
|
45
|
+
md: {
|
|
46
|
+
textStyle: "sm",
|
|
47
|
+
px: "300",
|
|
48
|
+
"--input-height": "sizes.1000",
|
|
49
|
+
},
|
|
50
|
+
lg: {
|
|
51
|
+
textStyle: "md",
|
|
52
|
+
px: "400",
|
|
53
|
+
"--input-height": "sizes.1100",
|
|
54
|
+
},
|
|
55
|
+
xl: {
|
|
56
|
+
textStyle: "md",
|
|
57
|
+
px: "450",
|
|
58
|
+
"--input-height": "sizes.1200",
|
|
59
|
+
},
|
|
60
|
+
"2xl": {
|
|
61
|
+
textStyle: "lg",
|
|
62
|
+
px: "500",
|
|
63
|
+
"--input-height": "sizes.1600",
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
variant: {
|
|
67
|
+
outline: {
|
|
68
|
+
bg: "transparent",
|
|
69
|
+
borderWidth: "1px",
|
|
70
|
+
borderColor: "border",
|
|
71
|
+
focusVisibleRing: "inside",
|
|
72
|
+
},
|
|
73
|
+
subtle: {
|
|
74
|
+
borderWidth: "1px",
|
|
75
|
+
borderColor: "transparent",
|
|
76
|
+
bg: "bg.muted",
|
|
77
|
+
focusVisibleRing: "inside",
|
|
78
|
+
},
|
|
79
|
+
flushed: {
|
|
80
|
+
bg: "transparent",
|
|
81
|
+
borderBottomWidth: "1px",
|
|
82
|
+
borderBottomColor: "border",
|
|
83
|
+
px: "0",
|
|
84
|
+
_focusVisible: {
|
|
85
|
+
borderColor: "var(--focus-color)",
|
|
86
|
+
boxShadow: "0px 1px 0px 0px var(--focus-color)",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
defaultVariants: {
|
|
92
|
+
size: "md",
|
|
93
|
+
variant: "outline",
|
|
94
|
+
},
|
|
95
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Input } from "@chakra-ui/react";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./input-group.tsx";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: InputGroup
|
|
3
|
+
title: InputGroup
|
|
4
|
+
description: displays an InputGroup
|
|
5
|
+
documentState: InitialDraft
|
|
6
|
+
order: 999
|
|
7
|
+
menu:
|
|
8
|
+
- Components
|
|
9
|
+
- Inputs
|
|
10
|
+
- InputGroup
|
|
11
|
+
tags:
|
|
12
|
+
- input
|
|
13
|
+
- grouping
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# InputGroup
|
|
17
|
+
|
|
18
|
+
add description here.
|
|
19
|
+
|
|
20
|
+
<PropTable id="InputGroup" />
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { BoxProps, InputElementProps } from "@chakra-ui/react";
|
|
2
|
+
import { Group, InputElement } from "@chakra-ui/react";
|
|
3
|
+
import { cloneElement, forwardRef } from "react";
|
|
4
|
+
|
|
5
|
+
export interface InputGroupProps extends BoxProps {
|
|
6
|
+
startElementProps?: InputElementProps;
|
|
7
|
+
endElementProps?: InputElementProps;
|
|
8
|
+
startElement?: React.ReactNode;
|
|
9
|
+
endElement?: React.ReactNode;
|
|
10
|
+
children: React.ReactElement;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const InputGroup = forwardRef<HTMLDivElement, InputGroupProps>(
|
|
14
|
+
function InputGroup(props, ref) {
|
|
15
|
+
const {
|
|
16
|
+
startElement,
|
|
17
|
+
startElementProps,
|
|
18
|
+
endElement,
|
|
19
|
+
endElementProps,
|
|
20
|
+
children,
|
|
21
|
+
...rest
|
|
22
|
+
} = props;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Group ref={ref} {...rest}>
|
|
26
|
+
{startElement && (
|
|
27
|
+
<InputElement pointerEvents="none" {...startElementProps}>
|
|
28
|
+
{startElement}
|
|
29
|
+
</InputElement>
|
|
30
|
+
)}
|
|
31
|
+
{cloneElement(children, {
|
|
32
|
+
...(startElement && { ps: "calc(var(--input-height) - 6px)" }),
|
|
33
|
+
...(endElement && { pe: "calc(var(--input-height) - 6px)" }),
|
|
34
|
+
...children.props,
|
|
35
|
+
})}
|
|
36
|
+
{endElement && (
|
|
37
|
+
<InputElement placement="end" {...endElementProps}>
|
|
38
|
+
{endElement}
|
|
39
|
+
</InputElement>
|
|
40
|
+
)}
|
|
41
|
+
</Group>
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./kbd.tsx";
|