Skip to content

Commit

Permalink
fix(prop-type): fix deprecation of buttonVariantPropType (#1433)
Browse files Browse the repository at this point in the history
  • Loading branch information
Birkbjo authored Nov 28, 2023
1 parent adb0d0d commit 81644a8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 12 deletions.
18 changes: 12 additions & 6 deletions components/button/src/dropdown-button/dropdown-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ DropdownButton.propTypes = {
/** Component to show/hide when button is clicked */
component: PropTypes.element,
dataTest: PropTypes.string,
/** Button variant. Mutually exclusive with `primary` and `secondary` props */
destructive: sharedPropTypes.buttonVariantPropType,
/**
* Applies 'destructive' button appearance, implying a dangerous action.
*/
destructive: PropTypes.bool,
/** Make the button non-interactive */
disabled: PropTypes.bool,
icon: PropTypes.element,
Expand All @@ -187,10 +189,14 @@ DropdownButton.propTypes = {
name: PropTypes.string,
/** Controls popper visibility. When implementing this prop the component becomes a controlled component */
open: PropTypes.bool,
/** Button variant. Mutually exclusive with `destructive` and `secondary` props */
primary: sharedPropTypes.buttonVariantPropType,
/** Button variant. Mutually exclusive with `primary` and `destructive` props */
secondary: sharedPropTypes.buttonVariantPropType,
/**
* Applies 'primary' button appearance, implying the most important action.
*/
primary: PropTypes.bool,
/**
* Applies 'secondary' button appearance.
*/
secondary: PropTypes.bool,
/** Button size. Mutually exclusive with `large` prop */
small: sharedPropTypes.sizePropType,
tabIndex: PropTypes.string,
Expand Down
18 changes: 12 additions & 6 deletions components/button/src/split-button/split-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ SplitButton.propTypes = {
/** Component to render when the dropdown is opened */
component: PropTypes.element,
dataTest: PropTypes.string,
/** Applies 'destructive' appearance to indicate purpose. Mutually exclusive with `primary` and `secondary` props */
destructive: sharedPropTypes.buttonVariantPropType,
/**
* Applies 'destructive' button appearance, implying a dangerous action.
*/
destructive: PropTypes.bool,
/** Disables the button and makes it uninteractive */
disabled: PropTypes.bool,
/** An icon to add inside the button */
Expand All @@ -158,10 +160,14 @@ SplitButton.propTypes = {
/** Changes button size. Mutually exclusive with `small` prop */
large: sharedPropTypes.sizePropType,
name: PropTypes.string,
/** Applies 'primary' appearance to indicate purpose. Mutually exclusive with `destructive` and `secondary` props */
primary: sharedPropTypes.buttonVariantPropType,
/** Applies 'secondary' appearance to indicate purpose. Mutually exclusive with `primary` and `destructive` props */
secondary: sharedPropTypes.buttonVariantPropType,
/**
* Applies 'primary' button appearance, implying the most important action.
*/
primary: PropTypes.bool,
/**
* Applies 'secondary' button appearance.
*/
secondary: PropTypes.bool,
/** Changes button size. Mutually exclusive with `large` prop */
small: sharedPropTypes.sizePropType,
tabIndex: PropTypes.string,
Expand Down
23 changes: 23 additions & 0 deletions constants/src/shared-prop-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ export const statusArgType = {
control: { type: 'boolean' },
}

/**
* @deprecated Not unused, will be removed in a future version.
* Button variant propType
* @return {PropType} Mutually exclusive variants:
* primary/secondary/destructive
*/
export const buttonVariantPropType = mutuallyExclusive(
['primary', 'secondary', 'destructive'],
PropTypes.bool
)
export const buttonVariantArgType = {
// No description because it should be set for the component description
table: {
type: {
summary: 'bool',
detail: "'primary', 'secondary', and 'destructive' are mutually exclusive props",
},
},
control: {
type: 'boolean',
},
}

/**
* Size variant propType
* @return {PropType} Mutually exclusive variants:
Expand Down

0 comments on commit 81644a8

Please sign in to comment.