@kaizen/components 1.67.22 → 1.68.0
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/cjs/__actions__/Button/v3/Button.cjs +43 -8
- package/dist/cjs/__actions__/Button/v3/Button.module.css.cjs +21 -0
- package/dist/cjs/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.cjs +37 -0
- package/dist/cjs/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.module.css.cjs +9 -0
- package/dist/cjs/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.cjs +35 -0
- package/dist/cjs/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.module.css.cjs +8 -0
- package/dist/cjs/__overlays__/Tooltip/v3/Tooltip.cjs +2 -2
- package/dist/esm/__actions__/Button/v3/Button.mjs +44 -9
- package/dist/esm/__actions__/Button/v3/Button.module.css.mjs +19 -0
- package/dist/esm/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.mjs +28 -0
- package/dist/esm/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.module.css.mjs +7 -0
- package/dist/esm/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.mjs +26 -0
- package/dist/esm/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.module.css.mjs +6 -0
- package/dist/esm/__overlays__/Tooltip/v3/Tooltip.mjs +1 -1
- package/dist/styles.css +276 -91
- package/dist/types/__actions__/Button/v3/Button.d.ts +17 -4
- package/dist/types/__actions__/Button/v3/index.d.ts +1 -0
- package/dist/types/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.d.ts +11 -0
- package/dist/types/__actions__/Button/v3/subcomponents/ButtonContent/index.d.ts +1 -0
- package/dist/types/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.d.ts +5 -0
- package/dist/types/__actions__/Button/v3/subcomponents/PendingContent/index.d.ts +1 -0
- package/dist/types/__actions__/Button/v3/subcomponents/index.d.ts +2 -0
- package/dist/types/__actions__/Button/v3/types.d.ts +21 -0
- package/package.json +1 -1
- package/src/__actions__/Button/v3/Button.module.css +235 -0
- package/src/__actions__/Button/v3/Button.tsx +92 -29
- package/src/__actions__/Button/v3/_docs/Button--api-specification.mdx +150 -0
- package/src/__actions__/Button/v3/_docs/Button--usage-guidelines.mdx +30 -0
- package/src/__actions__/Button/v3/_docs/Button.docs.stories.tsx +112 -50
- package/src/__actions__/Button/v3/_docs/Button.spec.stories.tsx +80 -120
- package/src/__actions__/Button/v3/_docs/Button.stickersheet.stories.tsx +183 -81
- package/src/__actions__/Button/v3/index.ts +1 -0
- package/src/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.module.css +19 -0
- package/src/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.tsx +40 -0
- package/src/__actions__/Button/v3/subcomponents/ButtonContent/index.ts +1 -0
- package/src/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.module.css +16 -0
- package/src/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.tsx +28 -0
- package/src/__actions__/Button/v3/subcomponents/PendingContent/index.ts +1 -0
- package/src/__actions__/Button/v3/subcomponents/index.ts +2 -0
- package/src/__actions__/Button/v3/types.ts +25 -0
- package/src/__actions__/Menu/v3/_docs/Menu.docs.stories.tsx +54 -18
- package/src/__actions__/Menu/v3/_docs/Menu.spec.stories.tsx +30 -10
- package/src/__actions__/Menu/v3/_docs/Menu.stories.tsx +12 -4
- package/src/__future__/Icon/_docs/Icon.docs.stories.tsx +7 -7
- package/src/__overlays__/Tooltip/v3/Tooltip.tsx +1 -1
- package/src/__overlays__/Tooltip/v3/_docs/Tooltip.spec.stories.tsx +2 -0
- package/dist/cjs/__actions__/Button/v3/Button.module.scss.cjs +0 -9
- package/dist/esm/__actions__/Button/v3/Button.module.scss.mjs +0 -7
- package/src/__actions__/Button/v3/Button.module.scss +0 -104
- package/src/__actions__/Button/v3/_docs/ApiSpecification.mdx +0 -173
- package/src/__actions__/Button/v3/_docs/Button.mdx +0 -41
- package/src/__actions__/Button/v3/_docs/Button.stories.tsx +0 -98
|
@@ -25,8 +25,12 @@ type Story = StoryObj<typeof meta>
|
|
|
25
25
|
export const Playground: Story = {
|
|
26
26
|
render: ({ defaultOpen: _, ...args }) => (
|
|
27
27
|
<MenuTrigger {...args}>
|
|
28
|
-
<Button
|
|
29
|
-
|
|
28
|
+
<Button
|
|
29
|
+
size="large"
|
|
30
|
+
icon={<Icon name="more_horiz" isPresentational />}
|
|
31
|
+
hasHiddenLabel
|
|
32
|
+
>
|
|
33
|
+
Additional actions
|
|
30
34
|
</Button>
|
|
31
35
|
<Popover>
|
|
32
36
|
<Menu>
|
|
@@ -68,8 +72,12 @@ export const Controlled: Story = {
|
|
|
68
72
|
export const RichContent: Story = {
|
|
69
73
|
render: ({ defaultOpen: _, ...args }) => (
|
|
70
74
|
<MenuTrigger {...args}>
|
|
71
|
-
<Button
|
|
72
|
-
|
|
75
|
+
<Button
|
|
76
|
+
size="large"
|
|
77
|
+
icon={<Icon name="more_horiz" isPresentational />}
|
|
78
|
+
hasHiddenLabel
|
|
79
|
+
>
|
|
80
|
+
Additional actions
|
|
73
81
|
</Button>
|
|
74
82
|
<Popover>
|
|
75
83
|
<Menu>
|
|
@@ -124,20 +124,20 @@ export const Size: Story = {
|
|
|
124
124
|
|
|
125
125
|
export const MeaningfulIcon: Story = {
|
|
126
126
|
render: args => (
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
</
|
|
127
|
+
<Tag color="blue" icon={<Icon {...args} />}>
|
|
128
|
+
Meaningful icons can be helpful
|
|
129
|
+
</Tag>
|
|
130
130
|
),
|
|
131
|
-
args: { isPresentational: false, alt: "
|
|
131
|
+
args: { isPresentational: false, alt: "Info:", name: "info", isFilled: true },
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
export const PresentationalIcon: Story = {
|
|
135
135
|
render: args => (
|
|
136
|
-
<Button>
|
|
137
|
-
|
|
136
|
+
<Button icon={<Icon {...args} />} hasHiddenLabel>
|
|
137
|
+
Label
|
|
138
138
|
</Button>
|
|
139
139
|
),
|
|
140
|
-
args: { isPresentational: true },
|
|
140
|
+
args: { isPresentational: true, name: "add" },
|
|
141
141
|
}
|
|
142
142
|
|
|
143
143
|
const IconSetButton = ({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { forwardRef, useContext, useLayoutEffect, useState } from "react"
|
|
2
|
-
import { VisuallyHidden } from "react-aria"
|
|
3
2
|
import {
|
|
4
3
|
Tooltip as RACTooltip,
|
|
5
4
|
TooltipContext,
|
|
@@ -7,6 +6,7 @@ import {
|
|
|
7
6
|
TooltipTriggerStateContext,
|
|
8
7
|
useContextProps,
|
|
9
8
|
} from "react-aria-components"
|
|
9
|
+
import { VisuallyHidden } from "~components/VisuallyHidden"
|
|
10
10
|
import { useReversedColors } from "~components/__utilities__/v3"
|
|
11
11
|
import { mergeClassNames } from "~components/utils/mergeClassNames"
|
|
12
12
|
import { OverlayArrow } from "./OverlayArrow"
|
|
@@ -33,6 +33,8 @@ export default meta
|
|
|
33
33
|
|
|
34
34
|
type Story = StoryObj<typeof meta>
|
|
35
35
|
|
|
36
|
+
// TODO: update this to use the new button component v3
|
|
37
|
+
|
|
36
38
|
export const OnButton: Story = {
|
|
37
39
|
render: ({ defaultOpen, isOpen, ...args }) => (
|
|
38
40
|
<TooltipTrigger defaultOpen={defaultOpen} isOpen={isOpen}>
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
.button {
|
|
2
|
-
--button-min-height-width: var(--spacing-48);
|
|
3
|
-
--button-padding-x: calc(
|
|
4
|
-
#{var(--spacing-12)} - #{var(--border-solid-border-width)}
|
|
5
|
-
);
|
|
6
|
-
--button-padding-y: calc(
|
|
7
|
-
#{var(--spacing-8)} - #{var(--border-solid-border-width)}
|
|
8
|
-
);
|
|
9
|
-
--button-icon-size: var(--spacing-24);
|
|
10
|
-
|
|
11
|
-
// RESET
|
|
12
|
-
appearance: none;
|
|
13
|
-
background: transparent;
|
|
14
|
-
color: inherit;
|
|
15
|
-
font: inherit;
|
|
16
|
-
margin: 0;
|
|
17
|
-
border: none;
|
|
18
|
-
// RESET
|
|
19
|
-
border: var(--border-solid-border-width) var(--border-solid-border-style);
|
|
20
|
-
border-radius: var(--border-solid-border-radius);
|
|
21
|
-
box-sizing: border-box;
|
|
22
|
-
display: inline-flex;
|
|
23
|
-
align-items: center;
|
|
24
|
-
justify-content: center;
|
|
25
|
-
text-align: left;
|
|
26
|
-
gap: var(--spacing-8);
|
|
27
|
-
font-family: var(--typography-button-primary-font-family);
|
|
28
|
-
font-weight: var(--typography-button-primary-font-weight);
|
|
29
|
-
font-size: var(--typography-button-primary-font-size);
|
|
30
|
-
line-height: var(--typography-button-primary-line-height);
|
|
31
|
-
min-height: var(--button-min-height-width);
|
|
32
|
-
min-width: var(--button-min-height-width);
|
|
33
|
-
outline: none;
|
|
34
|
-
position: relative;
|
|
35
|
-
padding: var(--button-padding-y) var(--button-padding-x);
|
|
36
|
-
-webkit-font-smoothing: antialiased;
|
|
37
|
-
-moz-osx-font-smoothing: grayscale;
|
|
38
|
-
|
|
39
|
-
&[data-focus-visible]::after {
|
|
40
|
-
content: "";
|
|
41
|
-
position: absolute;
|
|
42
|
-
background: transparent;
|
|
43
|
-
border-color: var(--color-blue-500);
|
|
44
|
-
border-radius: var(--border-focus-ring-border-radius);
|
|
45
|
-
border-width: var(--border-focus-ring-border-width);
|
|
46
|
-
border-style: var(--border-focus-ring-border-style);
|
|
47
|
-
inset: calc(-1 * ((#{var(--border-focus-ring-border-width)} * 2) + 1px));
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
svg {
|
|
51
|
-
height: var(--button-icon-size);
|
|
52
|
-
width: var(--button-icon-size);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
.default {
|
|
57
|
-
border-color: var(--color-gray-500);
|
|
58
|
-
color: var(--color-purple-800);
|
|
59
|
-
|
|
60
|
-
&[data-hovered],
|
|
61
|
-
&[data-focus-visible],
|
|
62
|
-
&[data-pressed] {
|
|
63
|
-
background-color: var(--color-gray-200);
|
|
64
|
-
border-color: var(--color-purple-800);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
&[data-disabled] {
|
|
68
|
-
opacity: 0.3;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
&.reversed {
|
|
72
|
-
background-color: transparent;
|
|
73
|
-
border-color: rgba(var(--color-white-rgb), 0.65);
|
|
74
|
-
color: var(--color-white);
|
|
75
|
-
|
|
76
|
-
&[data-hovered],
|
|
77
|
-
&[data-focus-visible] {
|
|
78
|
-
background-color: rgba(var(--color-white-rgb), 0.1);
|
|
79
|
-
border-color: var(--color-white);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
&[data-focus-visible]::after {
|
|
83
|
-
border-color: var(--color-blue-300);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
&[data-disabled]::after {
|
|
87
|
-
border-color: var(--color-gray-400);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
.small {
|
|
93
|
-
// spacing-40 does not currently exist. Holding on adding this until the button rfc has been signed off
|
|
94
|
-
--button-min-height-width: 2.5rem;
|
|
95
|
-
--button-padding-x: calc(
|
|
96
|
-
#{var(--spacing-8)} - #{var(--border-solid-border-width)}
|
|
97
|
-
);
|
|
98
|
-
--button-padding-y: calc(
|
|
99
|
-
#{var(--spacing-8)} - #{var(--border-solid-border-width)}
|
|
100
|
-
);
|
|
101
|
-
--button-icon-size: var(--spacing-16);
|
|
102
|
-
|
|
103
|
-
gap: var(--spacing-8);
|
|
104
|
-
}
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { Canvas, Meta, Controls } from "@storybook/blocks"
|
|
2
|
-
import { ResourceLinks, SbContent, KAIOInstallation } from "~storybook/components"
|
|
3
|
-
import * as docsStories from "./Button.docs.stories"
|
|
4
|
-
import * as exampleStories from "./Button.stories"
|
|
5
|
-
|
|
6
|
-
<Meta title="Actions/Button/Button (v3)/API Specification" />
|
|
7
|
-
|
|
8
|
-
<SbContent>
|
|
9
|
-
# Button API Specification (v3)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
Updated July 15, 2024
|
|
13
|
-
</SbContent>
|
|
14
|
-
|
|
15
|
-
<ResourceLinks
|
|
16
|
-
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/__actions__/Button/v3"
|
|
17
|
-
figma="https://www.figma.com/design/eZKEE5kXbEMY3lx84oz8iN/%F0%9F%92%9C-Heart-UI-Kit?m=auto&t=a6VcoKBJx6snn0ut-1"
|
|
18
|
-
ariaComponentPage="https://react-spectrum.adobe.com/react-aria/Button.html"
|
|
19
|
-
designGuidelines="/?path=/docs/actions-button-v3-usage-guidelines--docs"
|
|
20
|
-
/>
|
|
21
|
-
|
|
22
|
-
<SbContent className="mb-24">
|
|
23
|
-
<div className="bg-yellow-100 border-default border-yellow-400 rounded px-24">
|
|
24
|
-
### Disclaimer
|
|
25
|
-
|
|
26
|
-
The `v3` of `Button` is a partial rebuild to support [Menu v3](/docs/actions-menu-v3-api-specification--docs). As the changes to the API between `v1/v2` to `v3` is significant, our recommendation is to hold on adopting this outside of `Menu` `v3` as it will have a limited set of options.
|
|
27
|
-
</div>
|
|
28
|
-
</SbContent>
|
|
29
|
-
|
|
30
|
-
<SbContent>
|
|
31
|
-
<KAIOInstallation exportNames={["Tooltip", "TooltipTrigger" ]} family="actions" version="3" />
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
## Overview
|
|
35
|
-
|
|
36
|
-
</SbContent>
|
|
37
|
-
|
|
38
|
-
<Canvas of={exampleStories.Playground} />
|
|
39
|
-
|
|
40
|
-
<SbContent className="mb-64">
|
|
41
|
-
### React Aria
|
|
42
|
-
|
|
43
|
-
This component is built using the react-aria-components library and extends the [Button](https://react-spectrum.adobe.com/react-aria/Button.html) component.
|
|
44
|
-
|
|
45
|
-
As this shares the same core [anatomy](https://react-spectrum.adobe.com/react-aria/Button.html#anatomy), [props types](https://react-spectrum.adobe.com/react-aria/Button.html#anatomy) and [event handlers](https://react-spectrum.adobe.com/react-aria/Button.html#events), the guidance below is tailored to our implementation and should cover most known use cases of the Button.
|
|
46
|
-
|
|
47
|
-
For more scenarios that may not be present below, we recommend checkout out React Aria's documentation on the [Button's available hooks](https://react-spectrum.adobe.com/react-aria/Button.html#hooks) or [advanced customization](https://react-spectrum.adobe.com/react-aria/Button.html#advanced-customization) options.
|
|
48
|
-
</SbContent>
|
|
49
|
-
|
|
50
|
-
<SbContent>
|
|
51
|
-
## API
|
|
52
|
-
</SbContent>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
<Controls of={exampleStories.Playground} className="mb-64" />
|
|
56
|
-
|
|
57
|
-
<SbContent className="mb-64">
|
|
58
|
-
### onPress vs onClick
|
|
59
|
-
|
|
60
|
-
One key change to the `Button`'s API is the shift from `onClick` to `onPress`. This will not require a change to the implementation of `onClick` logic, ie:
|
|
61
|
-
```
|
|
62
|
-
<Button label="Submit" onClick={(e) => sumbit(e)}/>
|
|
63
|
-
// can safely be migrated to:
|
|
64
|
-
<Button onPress={(e) => submit(e)}>
|
|
65
|
-
Submit
|
|
66
|
-
</Button>
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
React Aria's implementation of `onPress` provides better support for consistent touch events across device types, such mobile, desktop and tablet. You can read more about the development and reason behind this pattern [here](https://react-spectrum.adobe.com/blog/building-a-button-part-1.html#touch-interactions).
|
|
70
|
-
</SbContent>
|
|
71
|
-
|
|
72
|
-
<SbContent>
|
|
73
|
-
|
|
74
|
-
### Interactive states and styling pseudo-classes
|
|
75
|
-
|
|
76
|
-
Psuedo classes, such as `hover`, `focus` or `focus-visible`, are now targeted and styled with HTML data attributes that reflect the internal state of the React Aria Button (ie: `isHovered`, `isFocusVisible`).
|
|
77
|
-
|
|
78
|
-
When styling in CSS, it is recommended to use [data attributes](https://react-spectrum.adobe.com/react-aria/Button.html#styling), such as `:[data-hovered]` or `:[data-focus-visible]`, instead of using pseudo selectors like `:hover` or `:focus-visible`.
|
|
79
|
-
|
|
80
|
-
```css
|
|
81
|
-
.button {
|
|
82
|
-
background-color: $color-white;
|
|
83
|
-
&:hover {
|
|
84
|
-
background-color: $color-gray-200;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
// becomes
|
|
88
|
-
.button {
|
|
89
|
-
background-color: $color-white;
|
|
90
|
-
&:[data-hovered] {
|
|
91
|
-
background-color: $color-gray-200;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
#### Dynamic styles with ButtonRenderProps
|
|
97
|
-
|
|
98
|
-
As `Button` extends React Aria's functionality, `className` can now accept either a `string` or function that receives the `Button`'s state for styling, such as `isPressed` or `isHovered`. This useful for add dynamic styling tweaks with Tailwind or other CSS-in-JS libraries.
|
|
99
|
-
</SbContent>
|
|
100
|
-
|
|
101
|
-
<Canvas of={docsStories.ButtonClassModifierWithRenderProps} sourceState="shown" />
|
|
102
|
-
|
|
103
|
-
<SbContent className="mb-64">
|
|
104
|
-
This can also be styled in directly with Tailwind targeting the data attributes, ie:
|
|
105
|
-
|
|
106
|
-
```tsx
|
|
107
|
-
<Button className="[&[data-focused='true']]:bg-blue-300">Label</Button>
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
React Aria also offers a [Tailwind plugin](https://react-spectrum.adobe.com/react-aria/styling.html#plugin) that exposes the styling states of React Aria Components into Tailwind. This can make classes and allows you to leverage intellisense when working with React Aria components, ie:
|
|
111
|
-
|
|
112
|
-
```tsx
|
|
113
|
-
<Button className="pressed:bg-blue-300">Label</Button>
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
For more on styling with React Aria and other ways to extend the `Button`'s styles, we recommend checking out the [docs here](https://react-spectrum.adobe.com/react-aria/Button.html#styling).
|
|
118
|
-
</SbContent>
|
|
119
|
-
|
|
120
|
-
<SbContent>
|
|
121
|
-
### Icons, labels and content as children
|
|
122
|
-
|
|
123
|
-
In `v3`, labels, icons and their positions are controlled by the consumer as `children`. The immediate children of `Button` are spaced using `flex-gap` to ensure `RTL` can be supported out of the box for most cases.
|
|
124
|
-
</ SbContent>
|
|
125
|
-
|
|
126
|
-
<Canvas of={exampleStories.ButtonWithIcon} />
|
|
127
|
-
|
|
128
|
-
<SbContent>
|
|
129
|
-
While the expected default is that `children` will be a `ReactNode`, it also accepts a render function that takes `ButtonRenderProps`. Similar to the className, this exposes the internal state (`isPressed`, `isHovered`, etc) of the button and can be used for conditional rendering.
|
|
130
|
-
|
|
131
|
-
```tsx
|
|
132
|
-
<Button>
|
|
133
|
-
{({isPressed}) => (
|
|
134
|
-
<>
|
|
135
|
-
{isPressed && <PressHighlight />}
|
|
136
|
-
Press me
|
|
137
|
-
</>
|
|
138
|
-
)}
|
|
139
|
-
</Button>
|
|
140
|
-
```
|
|
141
|
-
</ SbContent>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
<SbContent>
|
|
145
|
-
### Icon only buttons
|
|
146
|
-
|
|
147
|
-
To achieve the `IconButton` pattern in `v3`, we recommend passing an icon in as a the sole child. The label should be added to the icon's `aria-label` prop in the SVG Icon.
|
|
148
|
-
</ SbContent>
|
|
149
|
-
|
|
150
|
-
<Canvas of={exampleStories.IconButton} className="mb-32" />
|
|
151
|
-
|
|
152
|
-
<SbContent className="mb-64">
|
|
153
|
-
We recommend against setting the `aria-label` on the `Button` itself, and letting the accessible label be [determined by the children](https://cultureamp.atlassian.net/wiki/spaces/PA/pages/3833331831/Accessible+button+and+link+labels). You can achieve this by using visually hidden elements as children, which will create an accessible label based off the contents of the button.
|
|
154
|
-
</SbContent>
|
|
155
|
-
|
|
156
|
-
<SbContent className="mb-64">
|
|
157
|
-
### Reversed Colors
|
|
158
|
-
|
|
159
|
-
The `Button` uses the `useReversedColors` hook and `ReversedColors` provider to control the dark and light theme.
|
|
160
|
-
|
|
161
|
-
<Canvas className="bg-purple-600 mb-24" of={exampleStories.OnReversed} />
|
|
162
|
-
|
|
163
|
-
To enable the reversed theme, you will need to the component or application in the ReversedColors provider.
|
|
164
|
-
</ SbContent>
|
|
165
|
-
|
|
166
|
-
<SbContent>
|
|
167
|
-
### Buttons and links
|
|
168
|
-
|
|
169
|
-
`v3` of the `Button` component does not support the `href` prop. While a `Link` component will be coming to Kaizen, we recommend using the `v2` of button if a `anchor` or routing link is needed.
|
|
170
|
-
|
|
171
|
-
We do not advise passing in an `anchor` tag as a child of the `Button` as this can lead to accessibility issues.
|
|
172
|
-
</ SbContent>
|
|
173
|
-
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Canvas, Meta, Controls } from "@storybook/blocks"
|
|
2
|
-
import { ResourceLinks, SbContent, Installation } from "~storybook/components"
|
|
3
|
-
import * as Button from "./Button.stories"
|
|
4
|
-
|
|
5
|
-
<Meta title="Actions/Button/Button (v3)/Usage Guidelines" />
|
|
6
|
-
|
|
7
|
-
<SbContent>
|
|
8
|
-
# Button (v3)
|
|
9
|
-
|
|
10
|
-
Updated July 12, 2024
|
|
11
|
-
</SbContent>
|
|
12
|
-
|
|
13
|
-
<ResourceLinks
|
|
14
|
-
sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/__actions__/Button/v3"
|
|
15
|
-
figma="https://www.figma.com/design/eZKEE5kXbEMY3lx84oz8iN/%F0%9F%92%9C-Heart-UI-Kit?m=auto&t=a6VcoKBJx6snn0ut-1"
|
|
16
|
-
ariaComponentPage="https://react-spectrum.adobe.com/react-aria/Menu.html"
|
|
17
|
-
apiSpecification="/?path=/docs/actions-button-v3-api-specification--docs"
|
|
18
|
-
/>
|
|
19
|
-
|
|
20
|
-
<SbContent className="mb-24">
|
|
21
|
-
<div className="bg-yellow-100 border-default border-yellow-400 rounded px-24">
|
|
22
|
-
### Disclaimer
|
|
23
|
-
|
|
24
|
-
The `v3` of `Button` is a partial rebuild to support [Menu v3](/docs/actions-menu-v3-api-specification--docs). As the changes to the API between `v1/v2` to `v3` is significant, our recommendation is to hold on adopting this outside of `Menu` `v3` as it will have a limited set of options.
|
|
25
|
-
</div>
|
|
26
|
-
</SbContent>
|
|
27
|
-
|
|
28
|
-
<SbContent>
|
|
29
|
-
<Installation
|
|
30
|
-
installCommand="pnpm add @kaizen/components"
|
|
31
|
-
importStatement='import { Button } from "@kaizen/components/v3/actions"'
|
|
32
|
-
/>
|
|
33
|
-
|
|
34
|
-
## Overview
|
|
35
|
-
|
|
36
|
-
This is the rebuild of the Button component - the main changes present in `v3` will relate to an updated API. More guidance will be provided following the completion of the Button RFC.
|
|
37
|
-
</SbContent>
|
|
38
|
-
|
|
39
|
-
<Canvas of={Button.Playground} />
|
|
40
|
-
<Controls of={Button.Playground} include={["children", "variant", "isDisabled"]} className="mb-64" />
|
|
41
|
-
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import { action } from "@storybook/addon-actions"
|
|
3
|
-
import { Meta, StoryObj } from "@storybook/react"
|
|
4
|
-
import { AddIcon, TrashIcon, ChevronUpIcon } from "~components/Icon"
|
|
5
|
-
import { VisuallyHidden } from "~components/VisuallyHidden"
|
|
6
|
-
import { Button } from "../index"
|
|
7
|
-
|
|
8
|
-
const meta = {
|
|
9
|
-
title: "Actions/Button/Button (v3)",
|
|
10
|
-
component: Button,
|
|
11
|
-
args: {
|
|
12
|
-
children: "Label",
|
|
13
|
-
onPress: action("Button onPress event"),
|
|
14
|
-
},
|
|
15
|
-
} satisfies Meta<typeof Button>
|
|
16
|
-
|
|
17
|
-
export default meta
|
|
18
|
-
|
|
19
|
-
type Story = StoryObj<typeof meta>
|
|
20
|
-
|
|
21
|
-
export const Playground: Story = {
|
|
22
|
-
render: ({ children, ...otherArgs }) => (
|
|
23
|
-
<Button {...otherArgs}>{children}</Button>
|
|
24
|
-
),
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const ButtonWithIcon: Story = {
|
|
28
|
-
render: ({ children, ...otherArgs }) => (
|
|
29
|
-
<Button {...otherArgs}>{children}</Button>
|
|
30
|
-
),
|
|
31
|
-
args: {
|
|
32
|
-
children: (
|
|
33
|
-
<>
|
|
34
|
-
Label
|
|
35
|
-
<AddIcon role="presentation" />
|
|
36
|
-
</>
|
|
37
|
-
),
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export const ButtonWithIconStart: Story = {
|
|
42
|
-
render: ({ children, ...otherArgs }) => (
|
|
43
|
-
<Button {...otherArgs}>{children}</Button>
|
|
44
|
-
),
|
|
45
|
-
args: {
|
|
46
|
-
children: (
|
|
47
|
-
<>
|
|
48
|
-
<TrashIcon role="presentation" />
|
|
49
|
-
Label
|
|
50
|
-
</>
|
|
51
|
-
),
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const IconButton: Story = {
|
|
56
|
-
render: ({ children, ...otherArgs }) => (
|
|
57
|
-
<Button {...otherArgs}>{children}</Button>
|
|
58
|
-
),
|
|
59
|
-
args: {
|
|
60
|
-
children: (
|
|
61
|
-
<>
|
|
62
|
-
<TrashIcon role="img" aria-label="Remove" />
|
|
63
|
-
<VisuallyHidden> Highlights: May 8, 2024</VisuallyHidden>
|
|
64
|
-
</>
|
|
65
|
-
),
|
|
66
|
-
},
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export const OnReversed: Story = {
|
|
70
|
-
render: ({ children, ...otherArgs }) => (
|
|
71
|
-
<Button {...otherArgs}>{children}</Button>
|
|
72
|
-
),
|
|
73
|
-
args: {
|
|
74
|
-
children: (
|
|
75
|
-
<>
|
|
76
|
-
Label
|
|
77
|
-
<ChevronUpIcon role="presentation" />
|
|
78
|
-
</>
|
|
79
|
-
),
|
|
80
|
-
},
|
|
81
|
-
parameters: {
|
|
82
|
-
reverseColors: true,
|
|
83
|
-
docs: {
|
|
84
|
-
source: {
|
|
85
|
-
code: `
|
|
86
|
-
<ReversedColors isReversed={true}>
|
|
87
|
-
<Button {...otherArgs}>
|
|
88
|
-
<>
|
|
89
|
-
Label
|
|
90
|
-
<ChevronUpIcon role="presentation" />
|
|
91
|
-
</>
|
|
92
|
-
</Button>
|
|
93
|
-
</ReversedColors>
|
|
94
|
-
`,
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
}
|