Skip to content

Commit cf80608

Browse files
authored
[Button] Replace booleans with new props (Shopify#10090)
### WHY are these changes introduced? Fixes Shopify#10047 ### WHAT is this pull request doing? - Adds `variant` and `tone` props - Removes `primary`, `outline`, `plain`, `monochrome`, and `primarySuccess` booleans - Updates props on usages of `Button` - Renames `primaryPlain` variant to `tertiary`
1 parent aa4347b commit cf80608

File tree

76 files changed

+286
-612
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+286
-612
lines changed
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+
Consolidated boolean `Button` props into `variant` prop

documentation/guides/migrating-from-v11-to-v12.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,6 @@ Secondary, becomes oneThird:
5151
**HorizontalGrid**
5252

5353
`npx @shopify/polaris-migrator react-rename-component <path> --renameFrom="HorizontalGrid" --renameTo="InlineGrid" --renamePropsFrom="HorizontalGridProps" --renamePropsTo="InlineGridProps"`
54+
55+
**Button**
56+
// TODO

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function AccountConnection({
7676
) : null;
7777

7878
const actionElement = action
79-
? buttonFrom(action, {primary: !connected})
79+
? buttonFrom(action, {variant: connected ? undefined : 'primary'})
8080
: null;
8181

8282
return (

polaris-react/src/components/AccountConnection/tests/AccountConnection.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('<AccountConnection />', () => {
6363
expect(accountConnection).toContainReactComponent(Button, {
6464
children: action.content,
6565
onClick: action.onAction,
66-
primary: true,
66+
variant: 'primary',
6767
});
6868
});
6969

@@ -78,7 +78,6 @@ describe('<AccountConnection />', () => {
7878
expect(accountConnection).toContainReactComponent(Button, {
7979
children: action.content,
8080
onClick: action.onAction,
81-
primary: false,
8281
});
8382
});
8483
});

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ export function RollupActions({
3838
const activatorMarkup = (
3939
<div className={styles.RollupActivator}>
4040
<Button
41-
outline
4241
icon={HorizontalDotsMinor}
4342
accessibilityLabel={
4443
accessibilityLabel ||

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ export function BannerLayout({
150150
) : null,
151151
dismissButton: onDismiss ? (
152152
<Button
153-
plain
154-
primary
153+
variant="tertiary"
155154
icon={
156155
<span
157156
className={

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

Lines changed: 2 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@
198198

199199
.primary,
200200
.destructive,
201-
.primaryPlain {
201+
.tertiary {
202202
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
203203
@include focus-ring($border-width: 0);
204204
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
@@ -470,7 +470,7 @@
470470
}
471471
}
472472

473-
.primaryPlain {
473+
.tertiary {
474474
// stylelint-disable -- Button custom properties
475475
--pc-button-color: transparent;
476476
--pc-button-text: var(--p-color-text);
@@ -584,91 +584,6 @@
584584
}
585585
}
586586

587-
.outline {
588-
background: transparent;
589-
border: var(--p-border-width-1) solid var(--p-color-border);
590-
box-shadow: none;
591-
color: var(--p-color-text);
592-
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
593-
@include focus-ring($border-width: 1px);
594-
595-
&:hover {
596-
border: var(--p-border-width-1) solid var(--p-color-border);
597-
box-shadow: none;
598-
background: var(--p-color-bg-hover);
599-
}
600-
601-
&:focus-visible {
602-
border: var(--p-border-width-1) solid var(--p-color-border);
603-
box-shadow: none;
604-
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
605-
@include focus-ring($style: 'focused');
606-
}
607-
608-
&:active {
609-
border: var(--p-border-width-1) solid var(--p-color-border);
610-
box-shadow: none;
611-
background: var(--p-color-bg-active);
612-
613-
&::after {
614-
box-shadow: none;
615-
}
616-
}
617-
618-
&.pressed {
619-
background: var(--p-color-bg-subdued-active);
620-
border: var(--p-border-width-1) solid var(--p-color-border);
621-
box-shadow: none;
622-
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
623-
color: var(--pc-button-text);
624-
}
625-
626-
&.disabled {
627-
border: var(--p-border-width-1) solid var(--p-color-border-disabled);
628-
color: var(--p-color-text-disabled);
629-
}
630-
631-
&.destructive {
632-
background: transparent;
633-
border: var(--p-border-width-1) solid var(--p-color-border-critical);
634-
box-shadow: none;
635-
color: var(--p-color-text-critical);
636-
637-
svg {
638-
fill: var(--p-color-icon-critical);
639-
}
640-
641-
&:hover {
642-
border: var(--p-border-width-1) solid var(--p-color-border-critical);
643-
background: var(--p-color-bg-critical-subdued);
644-
}
645-
646-
&:focus-visible {
647-
border: var(--p-border-width-1) solid var(--p-color-border-critical);
648-
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
649-
@include focus-ring($style: 'focused');
650-
}
651-
652-
&:active {
653-
border: var(--p-border-width-1) solid var(--p-color-border-critical);
654-
background: var(--p-color-bg-critical-subdued);
655-
}
656-
657-
// stylelint-disable-next-line selector-max-class -- too many classes
658-
&.disabled {
659-
border: var(--p-border-width-1) solid var(--p-color-border-disabled);
660-
color: var(--p-color-text-disabled);
661-
}
662-
663-
// stylelint-disable-next-line selector-max-class -- too many classes
664-
&.pressed {
665-
border: var(--p-border-width-1) solid var(--p-color-border-critical);
666-
background: var(--p-color-bg-critical-subdued);
667-
color: var(--p-color-text-critical);
668-
}
669-
}
670-
}
671-
672587
.disabled {
673588
cursor: default;
674589
pointer-events: none;
@@ -1024,7 +939,6 @@
1024939
}
1025940

1026941
.monochrome {
1027-
&.outline,
1028942
&.plain {
1029943
color: currentColor;
1030944

@@ -1070,72 +984,11 @@
1070984
fill: currentColor;
1071985
}
1072986
}
1073-
}
1074987

1075-
&.plain {
1076988
.Text:not(.removeUnderline) {
1077989
text-decoration: underline;
1078990
}
1079991
}
1080-
1081-
&.outline {
1082-
position: relative;
1083-
border-color: currentColor;
1084-
box-shadow: 0 0 0 var(--p-border-width-1) currentColor;
1085-
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
1086-
@include focus-ring($border-width: 2px);
1087-
1088-
&::before {
1089-
content: '';
1090-
position: absolute;
1091-
top: 0;
1092-
right: 0;
1093-
bottom: 0;
1094-
left: 0;
1095-
background-color: currentColor;
1096-
opacity: 0;
1097-
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
1098-
z-index: 0;
1099-
}
1100-
1101-
&.pressed {
1102-
background: transparent;
1103-
box-shadow: none;
1104-
color: currentColor;
1105-
1106-
&::before {
1107-
opacity: 0.2;
1108-
}
1109-
}
1110-
1111-
&:hover,
1112-
&:focus,
1113-
&:active {
1114-
background-color: transparent;
1115-
border-color: currentColor;
1116-
1117-
&::before {
1118-
opacity: 0.07;
1119-
}
1120-
}
1121-
1122-
&:focus-visible {
1123-
box-shadow: 0 0 0 var(--p-border-width-1) currentColor;
1124-
// stylelint-disable-next-line -- generated by polaris-migrator DO NOT COPY
1125-
@include focus-ring($style: 'focused');
1126-
}
1127-
1128-
&:active::after {
1129-
box-shadow: none;
1130-
}
1131-
1132-
&:hover,
1133-
&:active {
1134-
&::before {
1135-
opacity: 0.05;
1136-
}
1137-
}
1138-
}
1139992
}
1140993
// stylelint-enable selector-max-specificity, selector-max-class
1141994

@@ -1160,12 +1013,6 @@
11601013
&.primary,
11611014
&.destructive {
11621015
margin-left: calc(var(--p-space-05) * -1);
1163-
1164-
// stylelint-disable-next-line selector-max-class -- generated by polaris-migrator DO NOT COPY
1165-
&.outline {
1166-
margin-left: 0;
1167-
border-left: 0;
1168-
}
11691016
}
11701017

11711018
&:active {

0 commit comments

Comments
 (0)