Skip to content

Commit ba1fb8d

Browse files
authored
[Button] Remove destructive boolean (#10164)
### WHY are these changes introduced? Fixes #0000 <!-- link to issue if one exists --> ### WHAT is this pull request doing? Removes `destructive` boolean prop from `Button`
1 parent 238c46d commit ba1fb8d

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

.changeset/loud-hounds-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': major
3+
---
4+
5+
Renamed `destructive` prop to `tone` for `Button` component

polaris-react/src/components/ActionMenu/components/SecondaryAction/SecondaryAction.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface SecondaryAction extends ButtonProps {
1515

1616
export function SecondaryAction({
1717
children,
18-
destructive,
18+
tone,
1919
helpText,
2020
onAction,
2121
getOffsetWidth,
@@ -47,7 +47,7 @@ export function SecondaryAction({
4747
<div
4848
className={classNames(
4949
styles.SecondaryAction,
50-
destructive && styles.destructive,
50+
tone === 'critical' && styles.destructive,
5151
)}
5252
ref={secondaryActionsRef}
5353
>

polaris-react/src/components/Button/Button.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ import styles from './Button.scss';
2323
export interface ButtonProps extends BaseButton {
2424
/** The content to display inside the button */
2525
children?: string | string[];
26-
/** Indicates a dangerous or potentially negative action */
27-
destructive?: boolean;
2826
/**
2927
* Changes the size of the button, giving it more or less padding
3028
* @default 'medium'
@@ -117,7 +115,6 @@ export function Button({
117115
onTouchStart,
118116
onPointerDown,
119117
icon,
120-
destructive,
121118
disclosure,
122119
removeUnderline,
123120
size = DEFAULT_SIZE,
@@ -220,12 +217,12 @@ export function Button({
220217
if (connectedDisclosure) {
221218
const connectedDisclosureClassName = classNames(
222219
styles.Button,
223-
variant && variant === 'primary' && styles.primary,
224-
variant && variant === 'monochromePlain' && styles.monochrome,
225-
variant && variant === 'monochromePlain' && styles.plain,
220+
variant === 'primary' && styles.primary,
221+
variant === 'monochromePlain' && styles.monochrome,
222+
variant === 'monochromePlain' && styles.plain,
226223
size && size !== DEFAULT_SIZE && styles[variationName('size', size)],
227224
textAlign && styles[variationName('textAlign', textAlign)],
228-
destructive && styles.destructive,
225+
tone === 'critical' && styles.destructive,
229226
connectedDisclosure.disabled && styles.disabled,
230227
styles.iconOnly,
231228
styles.ConnectedDisclosure,

polaris-react/src/components/Page/Page.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function Default() {
3333
secondaryActions={[
3434
{
3535
content: 'Delete',
36-
destructive: true,
36+
tone: 'critical',
3737
icon: DeleteMinor,
3838
accessibilityLabel: 'Delete action label',
3939
onAction: () => console.log('Delete action'),
@@ -124,7 +124,7 @@ export function WithDestructiveSecondaryAction() {
124124
return (
125125
<Page
126126
title="General"
127-
secondaryActions={[{content: 'Delete', destructive: true}]}
127+
secondaryActions={[{content: 'Delete', tone: 'critical'}]}
128128
>
129129
<p>Page content</p>
130130
</Page>

0 commit comments

Comments
 (0)