From 85f154b62361a67fab4e23c40e4420c256c1cbbb Mon Sep 17 00:00:00 2001 From: Birk Johansson Date: Tue, 28 Nov 2023 13:54:07 +0100 Subject: [PATCH] fix(prop-type): fix deprecation of buttonVariantPropType --- .../src/dropdown-button/dropdown-button.js | 18 ++++++++++----- .../button/src/split-button/split-button.js | 18 ++++++++++----- constants/src/shared-prop-types.js | 23 +++++++++++++++++++ 3 files changed, 47 insertions(+), 12 deletions(-) diff --git a/components/button/src/dropdown-button/dropdown-button.js b/components/button/src/dropdown-button/dropdown-button.js index a04adf72c7..9d636e7b6e 100644 --- a/components/button/src/dropdown-button/dropdown-button.js +++ b/components/button/src/dropdown-button/dropdown-button.js @@ -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, @@ -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, diff --git a/components/button/src/split-button/split-button.js b/components/button/src/split-button/split-button.js index 2f70bebc02..d6051ea4c0 100644 --- a/components/button/src/split-button/split-button.js +++ b/components/button/src/split-button/split-button.js @@ -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 */ @@ -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, diff --git a/constants/src/shared-prop-types.js b/constants/src/shared-prop-types.js index 50c60ef911..db9df2a3cc 100644 --- a/constants/src/shared-prop-types.js +++ b/constants/src/shared-prop-types.js @@ -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: