Skip to content

Commit 3584b03

Browse files
avelinelaurkimaaronccasanova
authored
Migration update button component (#10263)
### WHY are these changes introduced? Fixes #10161 ### WHAT is this pull request doing? Migration updates `920` files in `web` Adds comments to `1650` files to be updated manually ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) <!-- Give as much information as needed to experiment with the component in the playground. --> <details> <summary>Copy-paste this code in <code>playground/Playground.tsx</code>:</summary> ```jsx import React from 'react'; import {Page} from '../src'; export function Playground() { return ( <Page title="Playground"> {/* Add the code you want to test in here */} </Page> ); } ``` </details> ### 🎩 checklist - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide --------- Co-authored-by: Lo Kim <26749317+laurkim@users.noreply.github.com> Co-authored-by: Aaron Casanova <32409546+aaronccasanova@users.noreply.github.com>
1 parent 5dfc913 commit 3584b03

13 files changed

+703
-0
lines changed

.changeset/neat-balloons-shop.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris-migrator': minor
3+
---
4+
5+
Added migration for `Button` component
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {check} from '../../../utilities/check';
2+
3+
const transform = 'v12-react-update-button-component';
4+
const fixtures = [
5+
'v12-react-update-button-component',
6+
'v12-react-update-button-local-name',
7+
'v12-react-update-button-primary-plain-component',
8+
'v12-react-update-button-plain-monochrome-component',
9+
'v12-react-update-button-self-closing',
10+
];
11+
12+
for (const fixture of fixtures) {
13+
check(__dirname, {
14+
fixture,
15+
transform,
16+
});
17+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import React from 'react';
2+
import type {ButtonProps} from '@shopify/polaris';
3+
import {Button} from '@shopify/polaris';
4+
import {PhoneMajor} from '@shopify/polaris-icons';
5+
6+
declare function CustomButton(props: ButtonProps): JSX.Element;
7+
declare const Styles: {
8+
[className: string]: string;
9+
};
10+
11+
export function App() {
12+
const hasFormError = false;
13+
const polarisSummerEditions2023Enabled = true;
14+
const disabled = false;
15+
const primary = true;
16+
const MyButton = Button;
17+
return (
18+
<>
19+
<Button destructive outline disabled>
20+
Delete App
21+
</Button>
22+
<Button icon={PhoneMajor} size="large" monochrome outline>
23+
Call
24+
</Button>
25+
<Button plain>Edit</Button>
26+
<Button monochrome>Monochrome</Button>
27+
<Button outline>Outline</Button>
28+
<Button destructive>Destructive</Button>
29+
<Button primarySuccess>Primary success</Button>
30+
<Button destructive outline>
31+
Destructive outline
32+
</Button>
33+
<Button destructive plain>
34+
Destructive plain
35+
</Button>
36+
<Button
37+
disclosure="select"
38+
fullWidth
39+
textAlign="left"
40+
outline={hasFormError}
41+
destructive={hasFormError}
42+
disabled={disabled}
43+
size={polarisSummerEditions2023Enabled ? 'large' : undefined}
44+
>
45+
Selected branch
46+
</Button>
47+
<Button
48+
icon={PhoneMajor}
49+
removeUnderline
50+
plain={!primary}
51+
monochrome={!primary}
52+
disabled={disabled}
53+
primarySuccess={primary}
54+
>
55+
Content
56+
</Button>
57+
<Button
58+
outline={!polarisSummerEditions2023Enabled}
59+
plain={polarisSummerEditions2023Enabled}
60+
primary={polarisSummerEditions2023Enabled}
61+
>
62+
Button
63+
</Button>
64+
<MyButton plain>My Button</MyButton>
65+
<CustomButton plain />
66+
<div className={Styles.Button}>Fake Button</div>
67+
</>
68+
);
69+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import React from 'react';
2+
import type {ButtonProps} from '@shopify/polaris';
3+
import {Button} from '@shopify/polaris';
4+
import {PhoneMajor} from '@shopify/polaris-icons';
5+
6+
declare function CustomButton(
7+
props: /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */
8+
ButtonProps,
9+
): JSX.Element;
10+
declare const Styles: {
11+
[className: string]: string;
12+
};
13+
14+
export function App() {
15+
const hasFormError = false;
16+
const polarisSummerEditions2023Enabled = true;
17+
const disabled = false;
18+
const primary = true;
19+
const MyButton =
20+
/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */
21+
Button;
22+
return (
23+
<>
24+
<Button disabled tone="critical">
25+
Delete App
26+
</Button>
27+
<Button icon={PhoneMajor} size="large">
28+
Call
29+
</Button>
30+
<Button variant="plain">Edit</Button>
31+
<Button>Monochrome</Button>
32+
<Button>Outline</Button>
33+
<Button variant="primary" tone="critical">
34+
Destructive
35+
</Button>
36+
<Button variant="primary" tone="success">
37+
Primary success
38+
</Button>
39+
<Button tone="critical">Destructive outline</Button>
40+
<Button variant="plain" tone="critical">
41+
Destructive plain
42+
</Button>
43+
{/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */}
44+
<Button
45+
disclosure="select"
46+
fullWidth
47+
textAlign="left"
48+
outline={hasFormError}
49+
destructive={hasFormError}
50+
disabled={disabled}
51+
size={polarisSummerEditions2023Enabled ? 'large' : undefined}
52+
>
53+
Selected branch
54+
</Button>
55+
{/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */}
56+
<Button
57+
icon={PhoneMajor}
58+
removeUnderline
59+
plain={!primary}
60+
monochrome={!primary}
61+
disabled={disabled}
62+
primarySuccess={primary}
63+
>
64+
Content
65+
</Button>
66+
{/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */}
67+
<Button
68+
outline={!polarisSummerEditions2023Enabled}
69+
plain={polarisSummerEditions2023Enabled}
70+
primary={polarisSummerEditions2023Enabled}
71+
>
72+
Button
73+
</Button>
74+
<MyButton plain>My Button</MyButton>
75+
<CustomButton plain />
76+
<div className={Styles.Button}>Fake Button</div>
77+
</>
78+
);
79+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from 'react';
2+
import {Button as MyButton} from '@shopify/polaris';
3+
4+
export function App() {
5+
return (
6+
<>
7+
<MyButton plain primary>
8+
Edit
9+
</MyButton>
10+
</>
11+
);
12+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react';
2+
import {Button as MyButton} from '@shopify/polaris';
3+
4+
export function App() {
5+
return (
6+
<>
7+
<MyButton variant="tertiary">Edit</MyButton>
8+
</>
9+
);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import {Button} from '@shopify/polaris';
3+
import {PhoneMajor} from '@shopify/polaris-icons';
4+
5+
export function App() {
6+
const isPolarisUplift = true;
7+
return (
8+
<>
9+
<Button plain monochrome>
10+
Edit
11+
</Button>
12+
<Button monochrome plain>
13+
Edit
14+
</Button>
15+
<Button plain monochrome={isPolarisUplift}>
16+
Edit
17+
</Button>
18+
<Button plain={isPolarisUplift} monochrome>
19+
Edit
20+
</Button>
21+
<Button icon={PhoneMajor} plain monochrome />
22+
</>
23+
);
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import {Button} from '@shopify/polaris';
3+
import {PhoneMajor} from '@shopify/polaris-icons';
4+
5+
export function App() {
6+
const isPolarisUplift = true;
7+
return (
8+
<>
9+
<Button variant="monochromePlain">Edit</Button>
10+
<Button variant="monochromePlain">Edit</Button>
11+
{/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */}
12+
<Button plain monochrome={isPolarisUplift}>
13+
Edit
14+
</Button>
15+
{/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */}
16+
<Button plain={isPolarisUplift} monochrome>
17+
Edit
18+
</Button>
19+
<Button icon={PhoneMajor} variant="monochromePlain" />
20+
</>
21+
);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import {Button} from '@shopify/polaris';
3+
import {PhoneMajor} from '@shopify/polaris-icons';
4+
5+
export function App() {
6+
const isPolarisUplift = true;
7+
return (
8+
<>
9+
<Button plain primary>
10+
Edit
11+
</Button>
12+
<Button primary plain>
13+
Edit
14+
</Button>
15+
<Button plain primary={isPolarisUplift}>
16+
Edit
17+
</Button>
18+
<Button plain={isPolarisUplift} primary>
19+
Edit
20+
</Button>
21+
<Button icon={PhoneMajor} plain primary />
22+
</>
23+
);
24+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from 'react';
2+
import {Button} from '@shopify/polaris';
3+
import {PhoneMajor} from '@shopify/polaris-icons';
4+
5+
export function App() {
6+
const isPolarisUplift = true;
7+
return (
8+
<>
9+
<Button variant="tertiary">Edit</Button>
10+
<Button variant="tertiary">Edit</Button>
11+
{/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */}
12+
<Button plain primary={isPolarisUplift}>
13+
Edit
14+
</Button>
15+
{/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */}
16+
<Button plain={isPolarisUplift} primary>
17+
Edit
18+
</Button>
19+
<Button icon={PhoneMajor} variant="tertiary" />
20+
</>
21+
);
22+
}

0 commit comments

Comments
 (0)