@kaizen/components 1.69.1 → 1.70.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/codemods/migrateBrandMomentMoodToVariant/index.ts +5 -3
- package/codemods/migrateBrandMomentMoodToVariant/transformBrandMomentMoodToVariant.spec.ts +16 -5
- package/codemods/migrateCardVariantToColor/index.ts +5 -3
- package/codemods/migrateCardVariantToColor/transformCardVariantToColor.spec.ts +16 -5
- package/codemods/migrateConfirmationModalMoodsToVariant/index.ts +3 -1
- package/codemods/migrateConfirmationModalMoodsToVariant/transformConfirmationModalMoodsToVariant.spec.ts +27 -44
- package/codemods/migrateEmptyStateIllustrationTypeToVariant/index.ts +5 -3
- package/codemods/migrateEmptyStateIllustrationTypeToVariant/transformEmptyStateIllustrationTypeToVariant.spec.ts +16 -5
- package/codemods/migrateGlobalNotificationTypeToVariant/index.ts +5 -3
- package/codemods/migrateInformationTileMoodToVariant/index.ts +5 -3
- package/codemods/migrateInformationTileMoodToVariant/transformInformationTileMoodToVariant.spec.ts +16 -7
- package/codemods/migrateInlineNotificationTypeToVariant/index.ts +5 -3
- package/codemods/migrateMultiActionTileMoodToVariant/index.ts +5 -3
- package/codemods/migrateMultiActionTileMoodToVariant/transformMultiActionTileMoodToVariant.spec.ts +16 -7
- package/codemods/migrateNotificationTypeToVariant/migrateNotificationTypeToVariant.spec.ts +42 -43
- package/codemods/migrateProgressBarMoodToColor/index.ts +5 -3
- package/codemods/migrateProgressBarMoodToColor/transformProgressBarMoodToColor.spec.ts +16 -5
- package/codemods/migrateToastNotificationTypeToVariant/index.ts +6 -4
- package/codemods/migrateWellVariantToColor/index.ts +5 -3
- package/codemods/migrateWellVariantToColor/transformWellVariantToColor.spec.ts +26 -68
- package/codemods/migrateWellVariantToColor/transformWellVariantToColor.ts +10 -4
- package/codemods/removeInputEditModalMood/index.ts +3 -1
- package/codemods/removeInputEditModalMood/removeInputEditModalMood.spec.ts +23 -20
- package/codemods/removePopoverVariant/index.ts +1 -1
- package/codemods/removePopoverVariant/removePopoverVariant.spec.ts +23 -25
- package/codemods/upgradeIconV1/index.ts +2 -17
- package/codemods/upgradeIconV1/upgradeIconV1.spec.ts +18 -120
- package/codemods/upgradeIconV1/upgradeIconV1.ts +21 -28
- package/codemods/utils/__snapshots__/transformSource.spec.ts.snap +0 -10
- package/codemods/utils/getKaioTagName.spec.ts +167 -23
- package/codemods/utils/getKaioTagName.ts +71 -35
- package/codemods/utils/migrateStringProp.spec.ts +16 -5
- package/codemods/utils/migrateStringProp.ts +10 -3
- package/codemods/utils/removeProps.spec.ts +26 -25
- package/codemods/utils/removeProps.ts +10 -3
- package/codemods/utils/transformComponentsInDir.ts +40 -13
- package/codemods/utils/transformSource.spec.ts +1 -27
- package/codemods/utils/transformSource.ts +0 -26
- package/codemods/utils/updateKaioImports.ts +2 -0
- package/dist/cjs/LinkButton/LinkButton.cjs +59 -0
- package/dist/cjs/LinkButton/LinkButton.module.css.cjs +6 -0
- package/dist/cjs/__rc__/Button/Button.module.css.cjs +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/esm/LinkButton/LinkButton.mjs +53 -0
- package/dist/esm/LinkButton/LinkButton.module.css.mjs +4 -0
- package/dist/esm/__rc__/Button/Button.module.css.mjs +1 -1
- package/dist/esm/index.mjs +1 -0
- package/dist/styles.css +3259 -3229
- package/dist/types/LinkButton/LinkButton.d.ts +11 -0
- package/dist/types/LinkButton/index.d.ts +1 -0
- package/dist/types/__rc__/Button/Button.d.ts +6 -5
- package/dist/types/index.d.ts +1 -2
- package/package.json +1 -1
- package/src/LinkButton/LinkButton.module.css +4 -0
- package/src/LinkButton/LinkButton.tsx +71 -0
- package/src/LinkButton/_docs/LinkButton--api-specification.mdx +281 -0
- package/src/LinkButton/_docs/LinkButton--usage-guidelines.mdx +29 -0
- package/src/LinkButton/_docs/LinkButton.doc.stories.tsx +136 -0
- package/src/LinkButton/_docs/LinkButton.spec.stories.tsx +80 -0
- package/src/LinkButton/_docs/LinkButton.stickersheet.stories.tsx +130 -0
- package/src/LinkButton/index.ts +1 -0
- package/src/__rc__/Button/Button.module.css +44 -19
- package/src/__rc__/Button/Button.tsx +8 -4
- package/src/__rc__/Button/_docs/Button--api-specification.mdx +5 -5
- package/src/__rc__/Button/_docs/Button--usage-guidelines.mdx +2 -5
- package/src/index.ts +1 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { type Meta } from '@storybook/react'
|
|
3
|
+
import { within } from '@storybook/test'
|
|
4
|
+
import { Icon } from '~components/__rc__/Icon'
|
|
5
|
+
import { StickerSheet, type StickerSheetStory } from '~storybook/components/StickerSheet'
|
|
6
|
+
import { LinkButton, type LinkButtonProps } from '../index'
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Components/LinkButton',
|
|
10
|
+
parameters: {
|
|
11
|
+
chromatic: { disable: false },
|
|
12
|
+
controls: { disable: true },
|
|
13
|
+
},
|
|
14
|
+
} satisfies Meta
|
|
15
|
+
|
|
16
|
+
const variants = ['primary', 'secondary', 'tertiary'] satisfies LinkButtonProps['variant'][]
|
|
17
|
+
const sizes = ['small', 'medium', 'large'] satisfies LinkButtonProps['size'][]
|
|
18
|
+
|
|
19
|
+
const StickerSheetTemplate: StickerSheetStory = {
|
|
20
|
+
render: ({ isReversed }) => (
|
|
21
|
+
<>
|
|
22
|
+
<StickerSheet
|
|
23
|
+
title="Button"
|
|
24
|
+
headers={['Base', 'Icon start', 'Icon end', 'hasHiddenLabel', 'isDisabled']}
|
|
25
|
+
isReversed={isReversed}
|
|
26
|
+
>
|
|
27
|
+
{variants.map((variant) =>
|
|
28
|
+
sizes.map((size) => (
|
|
29
|
+
<StickerSheet.Row
|
|
30
|
+
key={size + variant}
|
|
31
|
+
isReversed={isReversed}
|
|
32
|
+
header={`${variant} (${size})`}
|
|
33
|
+
>
|
|
34
|
+
<LinkButton variant={variant} size={size}>
|
|
35
|
+
Label
|
|
36
|
+
</LinkButton>
|
|
37
|
+
<LinkButton icon={<Icon name="add" isPresentational />} variant={variant} size={size}>
|
|
38
|
+
Label
|
|
39
|
+
</LinkButton>
|
|
40
|
+
<LinkButton
|
|
41
|
+
icon={<Icon name="arrow_forward" shouldMirrorInRTL isPresentational />}
|
|
42
|
+
iconPosition="end"
|
|
43
|
+
variant={variant}
|
|
44
|
+
size={size}
|
|
45
|
+
>
|
|
46
|
+
Label
|
|
47
|
+
</LinkButton>
|
|
48
|
+
<LinkButton
|
|
49
|
+
icon={<Icon name="delete" isPresentational />}
|
|
50
|
+
variant={variant}
|
|
51
|
+
hasHiddenLabel
|
|
52
|
+
size={size}
|
|
53
|
+
>
|
|
54
|
+
Label
|
|
55
|
+
</LinkButton>
|
|
56
|
+
<LinkButton
|
|
57
|
+
icon={<Icon name="arrow_forward" shouldMirrorInRTL isPresentational />}
|
|
58
|
+
iconPosition="end"
|
|
59
|
+
variant={variant}
|
|
60
|
+
size={size}
|
|
61
|
+
isDisabled
|
|
62
|
+
>
|
|
63
|
+
Label
|
|
64
|
+
</LinkButton>
|
|
65
|
+
</StickerSheet.Row>
|
|
66
|
+
)),
|
|
67
|
+
)}
|
|
68
|
+
</StickerSheet>
|
|
69
|
+
<StickerSheet
|
|
70
|
+
title="Pseudo states"
|
|
71
|
+
headers={['isHovered', 'isFocusVisible', 'isPressed']}
|
|
72
|
+
isReversed={isReversed}
|
|
73
|
+
>
|
|
74
|
+
{variants.map((variant) => (
|
|
75
|
+
<StickerSheet.Row key={variant} isReversed={isReversed} header={variant}>
|
|
76
|
+
<LinkButton data-testid="testid__button-hover" variant={variant}>
|
|
77
|
+
Label
|
|
78
|
+
</LinkButton>
|
|
79
|
+
<LinkButton data-testid="testid__button-focus" variant={variant}>
|
|
80
|
+
Label
|
|
81
|
+
</LinkButton>
|
|
82
|
+
<LinkButton data-testid="testid__button-pressed" variant={variant}>
|
|
83
|
+
Label
|
|
84
|
+
</LinkButton>
|
|
85
|
+
</StickerSheet.Row>
|
|
86
|
+
))}
|
|
87
|
+
</StickerSheet>
|
|
88
|
+
</>
|
|
89
|
+
),
|
|
90
|
+
play: ({ canvasElement }) => {
|
|
91
|
+
const canvas = within(canvasElement)
|
|
92
|
+
const focusButtons = canvas.getAllByTestId('testid__button-focus')
|
|
93
|
+
const hoverButtons = canvas.getAllByTestId('testid__button-hover')
|
|
94
|
+
const pressedButton = canvas.getAllByTestId('testid__button-pressed')
|
|
95
|
+
|
|
96
|
+
focusButtons.forEach((button) => {
|
|
97
|
+
button.setAttribute('data-focus-visible', 'true')
|
|
98
|
+
})
|
|
99
|
+
hoverButtons.forEach((button) => {
|
|
100
|
+
button.setAttribute('data-hovered', 'true')
|
|
101
|
+
})
|
|
102
|
+
pressedButton.forEach((button) => {
|
|
103
|
+
button.setAttribute('data-pressed', 'true')
|
|
104
|
+
})
|
|
105
|
+
},
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export const StickerSheetDefault: StickerSheetStory = {
|
|
109
|
+
...StickerSheetTemplate,
|
|
110
|
+
name: 'Sticker Sheet (Default)',
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export const StickerSheetRTL: StickerSheetStory = {
|
|
114
|
+
...StickerSheetTemplate,
|
|
115
|
+
name: 'Sticker Sheet (RTL)',
|
|
116
|
+
parameters: {
|
|
117
|
+
textDirection: 'rtl',
|
|
118
|
+
},
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export const StickerSheetReversed: StickerSheetStory = {
|
|
122
|
+
...StickerSheetTemplate,
|
|
123
|
+
name: 'Sticker Sheet (Reversed)',
|
|
124
|
+
parameters: {
|
|
125
|
+
reverseColors: true,
|
|
126
|
+
},
|
|
127
|
+
args: {
|
|
128
|
+
isReversed: true,
|
|
129
|
+
},
|
|
130
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './LinkButton'
|
|
@@ -114,6 +114,12 @@
|
|
|
114
114
|
--button-bg-color: var(--color-gray-300);
|
|
115
115
|
--button-border-color: var(--color-black);
|
|
116
116
|
}
|
|
117
|
+
|
|
118
|
+
&.isDisabled {
|
|
119
|
+
--button-bg-color: var(--color-white);
|
|
120
|
+
--button-border-color: var(--color-gray-400);
|
|
121
|
+
--button-text-color: var(--color-gray-400);
|
|
122
|
+
}
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
.tertiary {
|
|
@@ -121,19 +127,31 @@
|
|
|
121
127
|
--button-border-color: transparent;
|
|
122
128
|
--button-text-color: var(--color-purple-800);
|
|
123
129
|
|
|
130
|
+
&[data-hovered],
|
|
131
|
+
&[data-pressed],
|
|
132
|
+
&[data-pending] {
|
|
133
|
+
--button-text-color: var(--color-blue-500);
|
|
134
|
+
}
|
|
135
|
+
|
|
124
136
|
&[data-hovered] {
|
|
125
|
-
--button-bg-color: var(--color-
|
|
126
|
-
--button-border-color: var(--color-
|
|
137
|
+
--button-bg-color: var(--color-blue-200);
|
|
138
|
+
--button-border-color: var(--color-blue-200);
|
|
127
139
|
}
|
|
128
140
|
|
|
129
141
|
&[data-pressed] {
|
|
130
|
-
--button-bg-color: var(--color-
|
|
131
|
-
--button-border-color: var(--color-
|
|
142
|
+
--button-bg-color: var(--color-blue-100);
|
|
143
|
+
--button-border-color: var(--color-blue-100);
|
|
132
144
|
}
|
|
133
145
|
|
|
134
146
|
&[data-pending] {
|
|
135
|
-
--button-bg-color: var(--color-
|
|
136
|
-
--button-border-color: var(--color-
|
|
147
|
+
--button-bg-color: var(--color-blue-100);
|
|
148
|
+
--button-border-color: var(--color-blue-100);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
&.isDisabled {
|
|
152
|
+
--button-bg-color: transparent;
|
|
153
|
+
--button-border-color: transparent;
|
|
154
|
+
--button-text-color: var(--color-gray-400);
|
|
137
155
|
}
|
|
138
156
|
}
|
|
139
157
|
|
|
@@ -151,19 +169,25 @@
|
|
|
151
169
|
--button-text-color: var(--color-purple-800);
|
|
152
170
|
|
|
153
171
|
&[data-hovered] {
|
|
154
|
-
--button-bg-color: var(--color-
|
|
155
|
-
--button-border-color: var(--color-
|
|
172
|
+
--button-bg-color: var(--color-gray-200);
|
|
173
|
+
--button-border-color: var(--color-gray-200);
|
|
156
174
|
}
|
|
157
175
|
|
|
158
176
|
&[data-pressed] {
|
|
159
|
-
--button-bg-color: var(--color-
|
|
160
|
-
--button-border-color: var(--color-
|
|
177
|
+
--button-bg-color: var(--color-gray-300);
|
|
178
|
+
--button-border-color: var(--color-gray-300);
|
|
161
179
|
}
|
|
162
180
|
|
|
163
181
|
&[data-pending] {
|
|
164
182
|
--button-bg-color: var(--color-white);
|
|
165
183
|
--button-border-color: var(--color-white);
|
|
166
184
|
}
|
|
185
|
+
|
|
186
|
+
&.isDisabled {
|
|
187
|
+
--button-bg-color: rgba(var(--color-white-rgb), 0.2);
|
|
188
|
+
--button-border-color: transparent;
|
|
189
|
+
--button-text-color: rgba(var(--color-purple-800-rgb), 0.7);
|
|
190
|
+
}
|
|
167
191
|
}
|
|
168
192
|
|
|
169
193
|
.secondaryReversed {
|
|
@@ -185,6 +209,12 @@
|
|
|
185
209
|
--button-bg-color: rgba(var(--color-white-rgb), 0.1);
|
|
186
210
|
--button-border-color: var(--color-white);
|
|
187
211
|
}
|
|
212
|
+
|
|
213
|
+
&.isDisabled {
|
|
214
|
+
--button-bg-color: transparent;
|
|
215
|
+
--button-border-color: rgba(var(--color-white), 0.2);
|
|
216
|
+
--button-text-color: rgba(var(--color-white-rgb), 0.2);
|
|
217
|
+
}
|
|
188
218
|
}
|
|
189
219
|
|
|
190
220
|
.tertiaryReversed {
|
|
@@ -206,16 +236,11 @@
|
|
|
206
236
|
--button-bg-color: rgba(var(--color-white-rgb), 0.1);
|
|
207
237
|
--button-border-color: transparent;
|
|
208
238
|
}
|
|
209
|
-
}
|
|
210
239
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
&[data-hovered] {
|
|
217
|
-
--button-bg-color: var(--color-gray-400);
|
|
218
|
-
--button-border-color: var(--color-gray-400);
|
|
240
|
+
&.isDisabled {
|
|
241
|
+
--button-bg-color: transparent;
|
|
242
|
+
--button-border-color: transparent;
|
|
243
|
+
--button-text-color: rgba(var(--color-white-rgb), 0.2);
|
|
219
244
|
}
|
|
220
245
|
}
|
|
221
246
|
|
|
@@ -6,9 +6,8 @@ import { ButtonContent, PendingContent } from './subcomponents'
|
|
|
6
6
|
import { type ButtonSizes, type ButtonVariants, type PendingButtonProps } from './types'
|
|
7
7
|
import styles from './Button.module.css'
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
children: RACButtonProps['children']
|
|
9
|
+
/** Shared UI props between Button and LinkButton */
|
|
10
|
+
export type ButtonUIProps = {
|
|
12
11
|
/** Visually hides the Button's child content used as the label and the `pendingLabel`. Use for icon-only `Button`. @default "false" */
|
|
13
12
|
hasHiddenLabel?: boolean
|
|
14
13
|
/** The visual style of the button.
|
|
@@ -30,7 +29,12 @@ type ButtonBaseProps = Omit<RACButtonProps, 'children'> & {
|
|
|
30
29
|
isReversed?: boolean
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
export type ButtonProps =
|
|
32
|
+
export type ButtonProps = ButtonUIProps &
|
|
33
|
+
PendingButtonProps &
|
|
34
|
+
Omit<RACButtonProps, 'children'> & {
|
|
35
|
+
/** Used as the label for the button. */
|
|
36
|
+
children: RACButtonProps['children']
|
|
37
|
+
}
|
|
34
38
|
|
|
35
39
|
export const Button = forwardRef(
|
|
36
40
|
(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Canvas, Meta, Controls, ArgTypes, DocsStory } from '@storybook/blocks'
|
|
2
|
-
import { ResourceLinks, KAIOInstallation } from '~storybook/components'
|
|
2
|
+
import { ResourceLinks, KAIOInstallation, LinkTo } from '~storybook/components'
|
|
3
3
|
import * as exampleStories from './Button.docs.stories'
|
|
4
4
|
import * as specStories from './Button.spec.stories'
|
|
5
5
|
|
|
@@ -15,11 +15,11 @@ Updated Nov 19, 2024
|
|
|
15
15
|
designGuidelines="/?path=/docs/actions-button-button-v3-usage-guidelines--docs"
|
|
16
16
|
/>
|
|
17
17
|
|
|
18
|
-
<KAIOInstallation exportNames={
|
|
18
|
+
<KAIOInstallation exportNames={'Button'} family="actions" version="3" />
|
|
19
19
|
|
|
20
20
|
## Overview
|
|
21
21
|
|
|
22
|
-
`Button` allows users to perform an action. If the component needs to navigate somewhere and can be opened in a new tab, use a
|
|
22
|
+
`Button` allows users to perform an action. If the component needs to navigate somewhere and can be opened in a new tab, use a <LinkTo pageId="components-linkbutton-api-specification--docs">LinkButton</LinkTo> instead.
|
|
23
23
|
|
|
24
24
|
The following example and table showcases the essential props that enable the core functionality of `Button`. For the remaining suite of API options refer to [this section](#additional-api-options).
|
|
25
25
|
|
|
@@ -50,7 +50,7 @@ The following example and table showcases the essential props that enable the co
|
|
|
50
50
|
|
|
51
51
|
The `Button` component does not support the `href` property or have any inbuilt routing support. This component is intended as a semantic button and should only be used to perform actions on a page. We advise against passing in an `anchor` tag as a child of the `Button` as this can lead to accessibility issues.
|
|
52
52
|
|
|
53
|
-
A
|
|
53
|
+
A separate <LinkTo pageId="components-linkbutton-api-specification--docs">LinkButton</LinkTo> component has been created to handle page navigation and client side routing.
|
|
54
54
|
|
|
55
55
|
## API
|
|
56
56
|
|
|
@@ -93,7 +93,7 @@ One key change to the `Button`'s API is the shift from `onClick` to React A
|
|
|
93
93
|
Functionally this does not change the way we pass actions into `Button`. Consumers can safely replace `onClick` with `onPress` without any additional changes, ie:
|
|
94
94
|
|
|
95
95
|
```tsx
|
|
96
|
-
<Button label="Submit" onClick={(e) =>
|
|
96
|
+
<Button label="Submit" onClick={(e) => submit(e)} />
|
|
97
97
|
```
|
|
98
98
|
|
|
99
99
|
Can safely be replaced with the following:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Canvas, Meta, Controls } from '@storybook/blocks'
|
|
2
|
-
import { ResourceLinks,
|
|
2
|
+
import { ResourceLinks, KAIOInstallation } from '~storybook/components'
|
|
3
3
|
import * as Button from './Button.docs.stories'
|
|
4
4
|
|
|
5
5
|
<Meta title="Components/Button/Button (v3)/Usage Guidelines" />
|
|
@@ -14,10 +14,7 @@ Updated July 12, 2024
|
|
|
14
14
|
apiSpecification="/?path=/docs/actions-button-button-v3-api-specification--docs"
|
|
15
15
|
/>
|
|
16
16
|
|
|
17
|
-
<
|
|
18
|
-
installCommand="pnpm add @kaizen/components"
|
|
19
|
-
importStatement='import { Button } from "@kaizen/components/v3/actions"'
|
|
20
|
-
/>
|
|
17
|
+
<KAIOInstallation exportNames={['Button']} family="actions" version="3" />
|
|
21
18
|
|
|
22
19
|
## Overview
|
|
23
20
|
|
package/src/index.ts
CHANGED
|
@@ -30,6 +30,7 @@ export * from './KaizenProvider'
|
|
|
30
30
|
export * from './Label'
|
|
31
31
|
export * from './LabelledMessage'
|
|
32
32
|
export * from './LikertScaleLegacy'
|
|
33
|
+
export * from './LinkButton'
|
|
33
34
|
export * from './Loading'
|
|
34
35
|
export * from './Menu'
|
|
35
36
|
export * from './Modal'
|
|
@@ -61,5 +62,3 @@ export * from './utils'
|
|
|
61
62
|
export * from './VisuallyHidden'
|
|
62
63
|
export * from './Well'
|
|
63
64
|
export * from './Workflow'
|
|
64
|
-
export * from './Menu'
|
|
65
|
-
export * from './Button'
|