Skip to content

Commit

Permalink
add deprecated isReversed props to Button
Browse files Browse the repository at this point in the history
  • Loading branch information
mcwinter07 committed Nov 28, 2024
1 parent d00335c commit 4ae4a0f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 8 additions & 0 deletions .changeset/hot-deers-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@kaizen/components": patch
---

Add a deprecated isReversed prop to Button v3 to allow for safe migration path to the ReversedColors Provider.

* `isReversed` to allow users to toggle the reversed variants with a `boolean`.
* Adds `@deprecated` flag to prompt user to use the `ReverseColors` Provider instead.
10 changes: 8 additions & 2 deletions packages/components/src/__actions__/Button/v3/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ type ButtonBaseProps = Omit<RACButtonProps, "children"> & {
iconPosition?: "start" | "end"
/** Controls if the button inherits width from its parent. @default "false" */
isFullWidth?: boolean
/**
* Controls the reversed style of Button @default false
* @deprecated Use the ReversedColors Provider instead. This is here to support gradual migration to the ReversedColors Provider. {@link https://cultureamp.design/?path=/docs/actions-button-button-v3-api-specification--docs#variants}
*/
isReversed?: boolean
}

export type ButtonProps = ButtonBaseProps & PendingButtonProps
Expand All @@ -45,11 +50,12 @@ export const Button = forwardRef(
isPending,
hasHiddenPendingLabel: propsHasHiddenPendingLabel = false,
pendingLabel,
isReversed = false,
...restProps
}: ButtonProps,
ref: React.ForwardedRef<HTMLButtonElement>
) => {
const isReversed = useReversedColors()
const isReversedVariant = useReversedColors() || isReversed
const pendingProps: PendingButtonProps = isPending
? {
isPending,
Expand All @@ -71,7 +77,7 @@ export const Button = forwardRef(
styles[size],
hasHiddenLabel && styles[`${size}IconButton`],
isDisabled && styles.isDisabled,
isReversed ? styles[`${variant}Reversed`] : styles[variant],
isReversedVariant ? styles[`${variant}Reversed`] : styles[variant],
isFullWidth && styles.fullWidth,
className
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ The following example and table showcases the essential props that enable the co

<Canvas of={exampleStories.Playground} />

<Controls of={exampleStories.Playground} className="mb-64" include={["children", "hasHiddenLabel", "className", "size", "variant", "onPress", "icon", "iconPosition", "isFullWidth", "isDisabled", "isPending","pendingLabel", "hasHiddenPendingLabel" ]} />
<Controls of={exampleStories.Playground} className="mb-64" include={["children", "hasHiddenLabel", "className", "size", "variant", "isReversed", "onPress", "icon", "iconPosition", "isFullWidth", "isDisabled", "isPending","pendingLabel", "hasHiddenPendingLabel" ]} />

## Buttons and links

Expand All @@ -43,7 +43,7 @@ This is built on top of [React Aria's Button component](https://react-spectrum.a

<Canvas of={exampleStories.ButtonVariants} />

Reversed variants are handled via the `ReversedColors` Provider - read more on this in the [reversed colors section](#reversed-colors).
Reversed variants are handled via the `ReversedColors` Provider.

<DocsStory of={exampleStories.ButtonVariantsReversed} expanded={false} />

Expand Down

0 comments on commit 4ae4a0f

Please sign in to comment.