@kaizen/components 1.69.2 → 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/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/index.mjs +1 -0
- package/dist/styles.css +4935 -4930
- 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.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'
|
|
@@ -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'
|