@kaizen/components 0.0.0-canary-package-bundler-v2-20241113055116 → 0.0.0-canary-link-button-wip-canary-20241121010628

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.
Files changed (99) hide show
  1. package/codemods/README.md +16 -1
  2. package/codemods/upgradeIconV1/getNewIconPropsFromOldIconName.ts +9 -9
  3. package/dist/cjs/EmptyState/EmptyState.cjs +15 -17
  4. package/dist/cjs/EmptyState/EmptyState.module.css.cjs +20 -0
  5. package/dist/cjs/Filter/FilterBar/FilterBar.cjs +1 -3
  6. package/dist/cjs/Filter/FilterBar/FilterBar.module.css.cjs +0 -1
  7. package/dist/cjs/GuidanceBlock/GuidanceBlock.cjs +1 -1
  8. package/dist/cjs/GuidanceBlock/GuidanceBlock.module.css.cjs +28 -0
  9. package/dist/cjs/__actions__/Button/v3/Button.cjs +43 -8
  10. package/dist/cjs/__actions__/Button/v3/Button.module.css.cjs +21 -0
  11. package/dist/cjs/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.cjs +37 -0
  12. package/dist/cjs/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.module.css.cjs +9 -0
  13. package/dist/cjs/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.cjs +35 -0
  14. package/dist/cjs/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.module.css.cjs +8 -0
  15. package/dist/cjs/__overlays__/Tooltip/v3/Tooltip.cjs +2 -2
  16. package/dist/esm/Calendar/CalendarPopover/CalendarPopover.mjs +1 -1
  17. package/dist/esm/EmptyState/EmptyState.mjs +16 -18
  18. package/dist/esm/EmptyState/EmptyState.module.css.mjs +18 -0
  19. package/dist/esm/Filter/FilterBar/FilterBar.mjs +1 -3
  20. package/dist/esm/Filter/FilterBar/FilterBar.module.css.mjs +0 -1
  21. package/dist/esm/Filter/FilterMultiSelect/subcomponents/ListBox/ListBox.mjs +1 -1
  22. package/dist/esm/GuidanceBlock/GuidanceBlock.mjs +1 -1
  23. package/dist/esm/GuidanceBlock/GuidanceBlock.module.css.mjs +26 -0
  24. package/dist/esm/MultiSelect/subcomponents/Popover/Popover.mjs +1 -1
  25. package/dist/esm/RichTextEditor/RichTextEditor/RichTextEditor.mjs +1 -1
  26. package/dist/esm/RichTextEditor/RichTextEditor/schema.mjs +1 -1
  27. package/dist/esm/RichTextEditor/utils/schema/nodes.mjs +1 -1
  28. package/dist/esm/TimeField/TimeField.mjs +1 -1
  29. package/dist/esm/__actions__/Button/v3/Button.mjs +44 -9
  30. package/dist/esm/__actions__/Button/v3/Button.module.css.mjs +19 -0
  31. package/dist/esm/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.mjs +28 -0
  32. package/dist/esm/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.module.css.mjs +7 -0
  33. package/dist/esm/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.mjs +26 -0
  34. package/dist/esm/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.module.css.mjs +6 -0
  35. package/dist/esm/__overlays__/Tooltip/v1/Tooltip.mjs +1 -1
  36. package/dist/esm/__overlays__/Tooltip/v3/Tooltip.mjs +1 -1
  37. package/dist/styles.css +568 -488
  38. package/dist/types/EmptyState/EmptyState.d.ts +2 -1
  39. package/dist/types/__actions__/Button/v3/Button.d.ts +17 -4
  40. package/dist/types/__actions__/Button/v3/index.d.ts +1 -0
  41. package/dist/types/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.d.ts +11 -0
  42. package/dist/types/__actions__/Button/v3/subcomponents/ButtonContent/index.d.ts +1 -0
  43. package/dist/types/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.d.ts +5 -0
  44. package/dist/types/__actions__/Button/v3/subcomponents/PendingContent/index.d.ts +1 -0
  45. package/dist/types/__actions__/Button/v3/subcomponents/index.d.ts +2 -0
  46. package/dist/types/__actions__/Button/v3/types.d.ts +21 -0
  47. package/dist/types/__actions__/LinkButton/index.d.ts +1 -0
  48. package/dist/types/__actions__/LinkButton/v3/LinkButton.d.ts +11 -0
  49. package/dist/types/__actions__/LinkButton/v3/index.d.ts +1 -0
  50. package/package.json +8 -8
  51. package/src/EmptyState/EmptyState.module.css +114 -0
  52. package/src/EmptyState/EmptyState.tsx +18 -20
  53. package/src/EmptyState/_docs/EmptyState.stickersheet.stories.tsx +55 -39
  54. package/src/Filter/FilterBar/FilterBar.module.css +0 -4
  55. package/src/Filter/FilterBar/FilterBar.tsx +12 -14
  56. package/src/GuidanceBlock/{GuidanceBlock.module.scss → GuidanceBlock.module.css} +60 -114
  57. package/src/GuidanceBlock/GuidanceBlock.tsx +1 -1
  58. package/src/__actions__/Button/v3/Button.module.css +235 -0
  59. package/src/__actions__/Button/v3/Button.tsx +95 -29
  60. package/src/__actions__/Button/v3/_docs/Button--api-specification.mdx +151 -0
  61. package/src/__actions__/Button/v3/_docs/Button--usage-guidelines.mdx +30 -0
  62. package/src/__actions__/Button/v3/_docs/Button.docs.stories.tsx +112 -50
  63. package/src/__actions__/Button/v3/_docs/Button.spec.stories.tsx +80 -120
  64. package/src/__actions__/Button/v3/_docs/Button.stickersheet.stories.tsx +183 -81
  65. package/src/__actions__/Button/v3/index.ts +1 -0
  66. package/src/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.module.css +19 -0
  67. package/src/__actions__/Button/v3/subcomponents/ButtonContent/ButtonContent.tsx +40 -0
  68. package/src/__actions__/Button/v3/subcomponents/ButtonContent/index.ts +1 -0
  69. package/src/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.module.css +16 -0
  70. package/src/__actions__/Button/v3/subcomponents/PendingContent/PendingContent.tsx +28 -0
  71. package/src/__actions__/Button/v3/subcomponents/PendingContent/index.ts +1 -0
  72. package/src/__actions__/Button/v3/subcomponents/index.ts +2 -0
  73. package/src/__actions__/Button/v3/types.ts +25 -0
  74. package/src/__actions__/LinkButton/index.ts +1 -0
  75. package/src/__actions__/LinkButton/v3/LinkButton.module.css +4 -0
  76. package/src/__actions__/LinkButton/v3/LinkButton.tsx +71 -0
  77. package/src/__actions__/LinkButton/v3/_docs/LinkButton--api-specification.mdx +200 -0
  78. package/src/__actions__/LinkButton/v3/_docs/LinkButton.doc.stories.tsx +131 -0
  79. package/src/__actions__/LinkButton/v3/_docs/LinkButton.spec.stories.tsx +100 -0
  80. package/src/__actions__/LinkButton/v3/index.ts +1 -0
  81. package/src/__actions__/Menu/v3/_docs/Menu.docs.stories.tsx +54 -18
  82. package/src/__actions__/Menu/v3/_docs/Menu.spec.stories.tsx +30 -10
  83. package/src/__actions__/Menu/v3/_docs/Menu.stories.tsx +12 -4
  84. package/src/__future__/Icon/_docs/Icon.docs.stories.tsx +7 -7
  85. package/src/__overlays__/Tooltip/v3/Tooltip.tsx +1 -1
  86. package/src/__overlays__/Tooltip/v3/_docs/Tooltip.spec.stories.tsx +2 -0
  87. package/dist/cjs/EmptyState/EmptyState.module.scss.cjs +0 -23
  88. package/dist/cjs/GuidanceBlock/GuidanceBlock.module.scss.cjs +0 -33
  89. package/dist/cjs/__actions__/Button/v3/Button.module.scss.cjs +0 -9
  90. package/dist/esm/EmptyState/EmptyState.module.scss.mjs +0 -21
  91. package/dist/esm/GuidanceBlock/GuidanceBlock.module.scss.mjs +0 -31
  92. package/dist/esm/__actions__/Button/v3/Button.module.scss.mjs +0 -7
  93. package/src/EmptyState/EmptyState.module.scss +0 -177
  94. package/src/EmptyState/EmptyState.spec.tsx +0 -48
  95. package/src/EmptyState/_mixins.scss +0 -44
  96. package/src/__actions__/Button/v3/Button.module.scss +0 -104
  97. package/src/__actions__/Button/v3/_docs/ApiSpecification.mdx +0 -173
  98. package/src/__actions__/Button/v3/_docs/Button.mdx +0 -41
  99. package/src/__actions__/Button/v3/_docs/Button.stories.tsx +0 -98
@@ -1,44 +1,110 @@
1
- import React from "react"
1
+ import React, { forwardRef } from "react"
2
2
  import {
3
3
  Button as RACButton,
4
4
  ButtonProps as RACButtonProps,
5
5
  } from "react-aria-components"
6
6
  import { useReversedColors } from "~components/__utilities__/v3"
7
7
  import { mergeClassNames } from "~components/utils/mergeClassNames"
8
- import styles from "./Button.module.scss"
8
+ import { ButtonContent, PendingContent } from "./subcomponents"
9
+ import { ButtonSizes, ButtonVariants, PendingButtonProps } from "./types"
10
+ import styles from "./Button.module.css"
9
11
 
10
- export type ButtonVariants = "default"
11
-
12
- export type ButtonProps = RACButtonProps & {
12
+ export type ButtonBaseProps = {
13
+ /** Visually hides the Button's child content used as the label and the `pendingLabel`. Use for icon-only `Button`. @default "false" */
14
+ hasHiddenLabel?: boolean
13
15
  /** The visual style of the button.
14
16
  * @default "default" */
15
17
  variant?: ButtonVariants
16
18
  /** The visual size of the button. `medium` was formerly `regular`
17
19
  * @default "medium" */
18
- size?: "small" | "medium"
20
+ size?: ButtonSizes
21
+ /** Renders an icon at the `iconPosition` provided. To the size scales with the button, we recommend using the `Icon` component from `"@kaizen/components/future"` */
22
+ icon?: JSX.Element
23
+ /** Controls the position of the Icon passed in as props. @default "start" */
24
+ iconPosition?: "start" | "end"
25
+ /** Controls if the button inherits width from its parent. @default "false" */
26
+ isFullWidth?: boolean
19
27
  }
20
28
 
21
- export const Button = ({
22
- variant = "default",
23
- className,
24
- size = "medium",
25
- children,
26
- ...otherProps
27
- }: ButtonProps): JSX.Element => {
28
- const isReversed = useReversedColors()
29
+ export type ButtonProps = ButtonBaseProps &
30
+ PendingButtonProps &
31
+ Omit<RACButtonProps, "children"> & {
32
+ /** Used as the label for the button. */
33
+ children: RACButtonProps["children"]
34
+ }
29
35
 
30
- return (
31
- <RACButton
32
- className={mergeClassNames(
33
- styles.button,
34
- styles[variant],
35
- styles[size],
36
- isReversed && styles.reversed,
37
- className
38
- )}
39
- {...otherProps}
40
- >
41
- {children}
42
- </RACButton>
43
- )
44
- }
36
+ export const Button = forwardRef(
37
+ (
38
+ {
39
+ variant = "primary",
40
+ size = "medium",
41
+ className,
42
+ children,
43
+ isDisabled,
44
+ isFullWidth = false,
45
+ icon,
46
+ iconPosition,
47
+ hasHiddenLabel = false,
48
+ isPending,
49
+ hasHiddenPendingLabel: propsHasHiddenPendingLabel = false,
50
+ pendingLabel,
51
+ ...restProps
52
+ }: ButtonProps,
53
+ ref: React.ForwardedRef<HTMLButtonElement>
54
+ ) => {
55
+ const isReversed = useReversedColors()
56
+ const pendingProps: PendingButtonProps = isPending
57
+ ? {
58
+ isPending,
59
+ hasHiddenPendingLabel: hasHiddenLabel || propsHasHiddenPendingLabel,
60
+ pendingLabel,
61
+ }
62
+ : {}
63
+ const buttonContentClass = isPending
64
+ ? !hasHiddenLabel && propsHasHiddenPendingLabel
65
+ ? styles.retainContentWidth
66
+ : styles.hideContentWidth
67
+ : undefined
68
+
69
+ return (
70
+ <RACButton
71
+ ref={ref}
72
+ className={mergeClassNames(
73
+ styles.button,
74
+ styles[size],
75
+ hasHiddenLabel && styles[`${size}IconButton`],
76
+ isDisabled && styles.isDisabled,
77
+ isReversed ? styles[`${variant}Reversed`] : styles[variant],
78
+ isFullWidth && styles.fullWidth,
79
+ className
80
+ )}
81
+ isDisabled={isDisabled}
82
+ isPending={isPending}
83
+ {...restProps}
84
+ >
85
+ {racStateProps => {
86
+ const childIsFunction = typeof children === "function"
87
+
88
+ return (
89
+ <>
90
+ <ButtonContent
91
+ size={size}
92
+ icon={icon}
93
+ iconPosition={iconPosition}
94
+ hasHiddenLabel={hasHiddenLabel}
95
+ className={buttonContentClass}
96
+ >
97
+ {childIsFunction ? children(racStateProps) : children}
98
+ </ButtonContent>
99
+ <span aria-live="polite">
100
+ {pendingProps.isPending && (
101
+ <PendingContent {...pendingProps} size={size} />
102
+ )}
103
+ </span>
104
+ </>
105
+ )
106
+ }}
107
+ </RACButton>
108
+ )
109
+ }
110
+ )
@@ -0,0 +1,151 @@
1
+ import { Canvas, Meta, Controls, ArgTypes, DocsStory } from "@storybook/blocks"
2
+ import { ResourceLinks, KAIOInstallation } from "~storybook/components"
3
+ import { LinkTo } from "../../../../../../../docs/components/LinkTo"
4
+ import * as exampleStories from "./Button.docs.stories"
5
+ import * as specStories from "./Button.spec.stories"
6
+
7
+ <Meta title="Actions/Button/Button (v3)/API Specification" />
8
+
9
+ # Button API Specification (v3)
10
+
11
+ Updated Nov 19, 2024
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/branch/sPhYSlgPScLOAOYfAbkaI5/%F0%9F%92%9C-Heart-UI-Kit?node-id=1929-17364&node-type=canvas&m=dev"
16
+ designGuidelines="/?path=/docs/actions-button-button-v3-usage-guidelines--docs"
17
+ />
18
+
19
+ <KAIOInstallation exportNames={["Button" ]} family="actions" version="3" />
20
+
21
+ ## Overview
22
+
23
+ `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="actions-linkbutton-linkbutton-v3-api-specification--docs">LinkButton</LinkTo> instead.
24
+
25
+ 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).
26
+
27
+ <Canvas of={exampleStories.Playground} />
28
+
29
+ <Controls of={exampleStories.Playground} className="mb-64" include={["children", "hasHiddenLabel", "className", "size", "variant", "onPress", "icon", "iconPosition", "isFullWidth", "isDisabled", "isPending","pendingLabel", "hasHiddenPendingLabel" ]} />
30
+
31
+ ## Buttons and links
32
+
33
+ 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.
34
+
35
+ A separate [LinkButton](?path=/docs/actions-linkbutton-linkbutton-v3-api-specification--docs) component has been created to handle page navigation and client side routing.
36
+
37
+ ## API
38
+
39
+ This is built on top of [React Aria's Button component](https://react-spectrum.adobe.com/react-aria/Button.html#props) and seeks to provide a flexible API with convenient abstractions that handles variants, sizes, pending states and icons.
40
+
41
+ ### Variants
42
+
43
+ `Button` supports the following variants: `primary`, `secondary` and `tertiary`. If the `variant` prop is not specified, the default will be `primary`.
44
+
45
+ <Canvas of={exampleStories.ButtonVariants} />
46
+
47
+ Reversed variants are handled via the `ReversedColors` Provider.
48
+
49
+ <DocsStory of={exampleStories.ButtonVariantsReversed} expanded={false} />
50
+
51
+ To enable the reversed theme, you will need to wrap the component or application in the `ReversedColors` provider, ie:
52
+
53
+ ```tsx
54
+ import { Button } from "@kaizen/components/v3/actions"
55
+ import { ReversedColors } from "@kaizen/components/v3/utilities"
56
+ // application code
57
+
58
+ return (
59
+ <ReversedColors isReversed={true}>
60
+ <Button {...buttonProps} />
61
+ </ReversedColors>
62
+ )
63
+ ```
64
+
65
+ ### Sizes
66
+
67
+ Button supports the following sizes: `small`, `medium` and `large`. If the `size` prop is not specified, the default will be `medium`.
68
+
69
+ <Canvas of={exampleStories.ButtonSizes} />
70
+
71
+ ### `onPress` vs `onClick`
72
+
73
+ One key change to the `Button`&apos;s API is the shift from `onClick` to React Aria's implementation of `onPress`. This approach has been adopted as it 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).
74
+
75
+ Functionally this does not change the way we pass actions into `Button`. Consumers can safely replace `onClick` with `onPress` without any additional changes, ie:
76
+
77
+ ```tsx
78
+ <Button label="Submit" onClick={e => sumbit(e)}/>
79
+ ```
80
+
81
+ Can safely be replaced with the following:
82
+
83
+ ```tsx
84
+ <Button onPress={e => submit(e)}>
85
+ Submit
86
+ </Button>
87
+ ```
88
+
89
+ ### Button content and children
90
+
91
+ Labels and any button content can be passed into the `Button` as `children`. Content wrapped by the `Button` will be spaced evenly relative to the `size` prop.
92
+
93
+ ```tsx
94
+ <Button variant="secondary" onPress={e => submit(e)}>
95
+ Label
96
+ </Button>
97
+ ```
98
+
99
+ While in most cases, `children` will be a `ReactNode`, `Button` also accepts a render function with React Aria's `ButtonRenderProps`. This allows for more advanced styling and rendering options by hooking into React Aria's internal button state. You can read more about this [here](https://react-spectrum.adobe.com/react-aria/Button.html#styling).
100
+
101
+ ### Icons and positioning
102
+
103
+ The `icon` property abstracts the need to handle positioning and sizing logic for icons within the `Button`. When paired with the [Icon component](/docs/illustrations-icon-icon-future-api-specification--docs), this will scale the icon to the `Button`'s `size` prop.
104
+
105
+ <Canvas of={exampleStories.ButtonWithIconStart} />
106
+
107
+ Set the position of the icon using the `iconPosition` prop. This will ensure content is flipped in `RTL` layouts. Note that icons will need the [shouldMirrorInRTL](/docs/illustrations-icon-icon-future-api-specification--docs#mirror-in-rtl) prop set to `true` when mirroring is required.
108
+
109
+ <Canvas of={exampleStories.ButtonWithIconEnd} />
110
+
111
+
112
+ ### Icon-only `Button` and `hasHiddenLabel`
113
+
114
+ To achieve an icon-only `Button` (previously: `IconButton`) use the `icon` prop and set `hasHiddenLabel` to `true`. This will visually hide the button's `children` and `pendingLabel`, while still announcing the content to screen readers.
115
+
116
+ <Canvas of={exampleStories.IconButton} className="mb-32" />
117
+
118
+ This pattern ensures that the `Button`'s accessible name is determined by its children, which helps to announce relevant content to the screen readers, as with the [pending state](#pending-state). You can learn more about this [accessible pattern here](https://cultureamp.atlassian.net/wiki/spaces/PA/pages/3833331831/Accessible+button+and+link+labels).
119
+
120
+ ### Pending state
121
+
122
+ `isPending` and `pendingLabel` are used to indicate that an interaction is in progress. This will disable the `Button`'s press events while rendering a loading spinner and `pendingLabel`.
123
+
124
+ <Canvas of={specStories.PendingButton} />
125
+
126
+ This can be paired with the `hasHiddenPendingLabel` prop to visually hide the `pendingLabel` and maintain the content width. This is ideal for avoid layout shifts when space is a commodity.
127
+
128
+ The `pendingLabel` should be short and declarative as this will be announced to a screen reader regardless of its visibility.
129
+
130
+ <Canvas of={specStories.PendingButtonWithHiddenPendingLabel} />
131
+
132
+ As mentioned in the [previous section](#icon-only-button-and-hashiddenlabel), an icon-only `Button` uses `hasHiddenLabel` to visually hide both the `pendingLabel` and child content, so `hasHiddenPendingLabel` is not needed.
133
+
134
+ <Canvas of={specStories.PendingIconButton} />
135
+
136
+
137
+ ### Full width Buttons
138
+
139
+ If a button is statically the full width of a container you can use the `isFullWidth` property.
140
+
141
+ <Canvas of={exampleStories.ButtonFullWidth} />
142
+
143
+ For resizing on smaller screens, consider using the `className` prop to leverage CSS media or container queries, ie: `<Button className="w-full md:w-[initial]">Label</Button>`.
144
+
145
+ ## Additional API options
146
+
147
+ The following table is a collection of additional React Aria and native HTML props that are exposed from the React Aria API. These are not required for the implementation of `Button` but can be used to extend its functionality. Refer back to the [overview section](#overview) for the core props that enable most use cases.
148
+
149
+ You can learn more about React Aria's Button API and advance configuration options [here](https://react-spectrum.adobe.com/react-aria/Button.html#props).
150
+
151
+ <ArgTypes of={exampleStories.Playground} exclude={["children", "hasHiddenLabel", "className", "size", "variant", "onPress", "icon", "iconPosition", "isFullWidth", "isDisabled", "isPending", "pendingLabel", "hasHiddenPendingLabel" ]} />
@@ -0,0 +1,30 @@
1
+ import { Canvas, Meta, Controls } from "@storybook/blocks"
2
+ import { ResourceLinks, Installation } from "~storybook/components"
3
+ import * as Button from "./Button.docs.stories"
4
+
5
+ <Meta title="Actions/Button/Button (v3)/Usage Guidelines" />
6
+
7
+ # Button (v3)
8
+
9
+ Updated July 12, 2024
10
+
11
+ <ResourceLinks
12
+ sourceCode="https://github.com/cultureamp/kaizen-design-system/tree/main/packages/components/src/__actions__/Button/v3"
13
+ figma="https://www.figma.com/design/eZKEE5kXbEMY3lx84oz8iN/branch/sPhYSlgPScLOAOYfAbkaI5/%F0%9F%92%9C-Heart-UI-Kit?node-id=1929-17364&node-type=canvas&m=dev"
14
+ apiSpecification="/?path=/docs/actions-button-button-v3-api-specification--docs"
15
+ />
16
+
17
+ <Installation
18
+ installCommand="pnpm add @kaizen/components"
19
+ importStatement='import { Button } from "@kaizen/components/v3/actions"'
20
+ />
21
+
22
+ ## Overview
23
+
24
+ Buttons allow users to perform an action. They have multiple styles for various needs, and are ideal for calling attention to where a user needs to do something in order to move forward in a flow.
25
+
26
+ <Canvas of={Button.Playground} />
27
+
28
+ <Controls of={Button.Playground} include={["children", "variant", "size", "isDisabled", "icon", "iconPosition"]} className="mb-64" />
29
+
30
+
@@ -1,76 +1,138 @@
1
1
  import React from "react"
2
2
  import { action } from "@storybook/addon-actions"
3
3
  import { Meta, StoryObj } from "@storybook/react"
4
- import { ChevronDownIcon, ChevronUpIcon } from "~components/Icon"
4
+ import { Badge } from "~components/Badge"
5
+ import { Icon } from "~components/__future__"
6
+ import { ReversedColors } from "~components/__utilities__/v3"
5
7
  import { Button } from "../index"
6
8
 
7
9
  const meta = {
8
- title: "Actions/Button/Button (v3)/Doc Assets",
10
+ title: "Actions/Button/Button (v3)",
9
11
  component: Button,
10
12
  args: {
11
13
  children: "Label",
12
14
  onPress: action("Button onPress event"),
13
15
  },
16
+ argTypes: {
17
+ icon: {
18
+ options: ["delete", "arrow", "plus"],
19
+ mapping: {
20
+ delete: <Icon isPresentational name="delete" />,
21
+ arrow: <Icon isPresentational name="arrow_forward" />,
22
+ add: <Icon isPresentational name="add" />,
23
+ },
24
+ },
25
+ },
14
26
  } satisfies Meta<typeof Button>
15
27
 
16
28
  export default meta
17
29
 
18
30
  type Story = StoryObj<typeof meta>
19
31
 
20
- export const ButtonClassModifierWithRenderProps: Story = {
21
- render: ({ children, ...otherArgs }) => (
22
- <Button
23
- {...otherArgs}
24
- className={({ isPressed }) => (isPressed ? "!bg-gray-300" : "")}
25
- >
26
- {children}
27
- </Button>
32
+ export const Playground: Story = {}
33
+
34
+ export const ButtonVariants: Story = {
35
+ render: args => (
36
+ <>
37
+ <Button {...args} variant="primary" />
38
+ <Button {...args} variant="secondary" />
39
+ <Button {...args} variant="tertiary" />
40
+ </>
41
+ ),
42
+ decorators: [
43
+ Story => (
44
+ <div className="flex gap-8">
45
+ <Story />
46
+ </div>
47
+ ),
48
+ ],
49
+ }
50
+
51
+ export const ButtonVariantsReversed: Story = {
52
+ render: args => (
53
+ <ReversedColors isReversed={true}>
54
+ <Button {...args} variant="primary" />
55
+ <Button {...args} variant="secondary" />
56
+ <Button {...args} variant="tertiary" />
57
+ </ReversedColors>
28
58
  ),
29
59
  parameters: {
30
- docs: {
31
- source: {
32
- code: `
33
- <Button
34
- {...otherArgs}
35
- className={({ isPressed }) => (isPressed ? "!bg-gray-300" : "")}
36
- >
37
- {children}
38
- </Button>
39
- `,
40
- },
41
- },
60
+ reverseColors: true,
61
+ backgrounds: { default: "Purple 700" },
62
+ },
63
+ decorators: [
64
+ Story => (
65
+ <div className="flex gap-8">
66
+ <Story />
67
+ </div>
68
+ ),
69
+ ],
70
+ }
71
+
72
+ export const ButtonSizes: Story = {
73
+ render: args => (
74
+ <>
75
+ <Button {...args} size="small" />
76
+ <Button {...args} size="medium" />
77
+ <Button {...args} size="large" />
78
+ </>
79
+ ),
80
+ decorators: [
81
+ Story => (
82
+ <div className="flex gap-8 items-center">
83
+ <Story />
84
+ </div>
85
+ ),
86
+ ],
87
+ }
88
+
89
+ export const ButtonWithIconStart: Story = {
90
+ args: {
91
+ icon: <Icon isPresentational name="delete" />,
92
+ },
93
+ }
94
+
95
+ export const ButtonWithIconEnd: Story = {
96
+ args: {
97
+ icon: <Icon isPresentational name="arrow_forward" shouldMirrorInRTL />,
98
+ iconPosition: "end",
42
99
  },
43
100
  }
44
101
 
45
- export const ButtonContentWithRenderProps: Story = {
46
- render: ({ children, ...otherArgs }) => (
47
- <Button {...otherArgs}>
48
- {({ isPressed }) => (
49
- <>
50
- {children}
51
- {isPressed ? (
52
- <ChevronDownIcon role="presentation" />
53
- ) : (
54
- <ChevronUpIcon role="presentation" />
55
- )}
56
- </>
57
- )}
58
- </Button>
102
+ export const IconButton: Story = {
103
+ args: {
104
+ children: "Remove highlights from: May 8, 2024",
105
+ icon: <Icon isPresentational name="delete" />,
106
+ hasHiddenLabel: true,
107
+ },
108
+ }
109
+
110
+ export const ReversedButton: Story = {
111
+ render: args => (
112
+ <ReversedColors isReversed={true}>
113
+ <Button {...args} />
114
+ </ReversedColors>
59
115
  ),
60
116
  parameters: {
61
- docs: {
62
- source: {
63
- code: `
64
- <Button {...otherArgs}>
65
- {({isPressed}) => (
66
- <>
67
- {children}
68
- {isPressed ? <ChevronDownIcon role="presentation" /> : <ChevronUpIcon role="presentation" />}
69
- </>
70
- )}
71
- </Button>
72
- `,
73
- },
74
- },
117
+ backgrounds: { default: "Purple 700" },
118
+ },
119
+ }
120
+
121
+ export const ButtonFullWidth: Story = {
122
+ args: {
123
+ isFullWidth: true,
124
+ },
125
+ }
126
+
127
+ export const ButtonWithBadge: Story = {
128
+ args: {
129
+ children: (
130
+ <>
131
+ Label
132
+ <Badge classNameOverride="ms-8" size="small">
133
+ 3
134
+ </Badge>
135
+ </>
136
+ ),
75
137
  },
76
138
  }