diff --git a/.changeset/neat-balloons-shop.md b/.changeset/neat-balloons-shop.md new file mode 100644 index 00000000000..e8648219fca --- /dev/null +++ b/.changeset/neat-balloons-shop.md @@ -0,0 +1,5 @@ +--- +'@shopify/polaris-migrator': minor +--- + +Added migration for `Button` component diff --git a/polaris-migrator/src/migrations/v12-react-update-button-component/tests/transform.test.ts b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/transform.test.ts new file mode 100644 index 00000000000..b922361c8e7 --- /dev/null +++ b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/transform.test.ts @@ -0,0 +1,17 @@ +import {check} from '../../../utilities/check'; + +const transform = 'v12-react-update-button-component'; +const fixtures = [ + 'v12-react-update-button-component', + 'v12-react-update-button-local-name', + 'v12-react-update-button-primary-plain-component', + 'v12-react-update-button-plain-monochrome-component', + 'v12-react-update-button-self-closing', +]; + +for (const fixture of fixtures) { + check(__dirname, { + fixture, + transform, + }); +} diff --git a/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-component.input.tsx b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-component.input.tsx new file mode 100644 index 00000000000..56c14974592 --- /dev/null +++ b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-component.input.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import type {ButtonProps} from '@shopify/polaris'; +import {Button} from '@shopify/polaris'; +import {PhoneMajor} from '@shopify/polaris-icons'; + +declare function CustomButton(props: ButtonProps): JSX.Element; +declare const Styles: { + [className: string]: string; +}; + +export function App() { + const hasFormError = false; + const polarisSummerEditions2023Enabled = true; + const disabled = false; + const primary = true; + const MyButton = Button; + return ( + <> + + + + + + + + + + + + + My Button + +
Fake Button
+ + ); +} diff --git a/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-component.output.tsx b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-component.output.tsx new file mode 100644 index 00000000000..ed3a7974399 --- /dev/null +++ b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-component.output.tsx @@ -0,0 +1,79 @@ +import React from 'react'; +import type {ButtonProps} from '@shopify/polaris'; +import {Button} from '@shopify/polaris'; +import {PhoneMajor} from '@shopify/polaris-icons'; + +declare function CustomButton( + props: /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ + ButtonProps, +): JSX.Element; +declare const Styles: { + [className: string]: string; +}; + +export function App() { + const hasFormError = false; + const polarisSummerEditions2023Enabled = true; + const disabled = false; + const primary = true; + const MyButton = + /* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */ + Button; + return ( + <> + + + + + + + + + + {/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */} + + {/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */} + + {/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */} + + My Button + +
Fake Button
+ + ); +} diff --git a/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-local-name.input.tsx b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-local-name.input.tsx new file mode 100644 index 00000000000..2e648ea37e3 --- /dev/null +++ b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-local-name.input.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import {Button as MyButton} from '@shopify/polaris'; + +export function App() { + return ( + <> + + Edit + + + ); +} diff --git a/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-local-name.output.tsx b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-local-name.output.tsx new file mode 100644 index 00000000000..0184b91337c --- /dev/null +++ b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-local-name.output.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import {Button as MyButton} from '@shopify/polaris'; + +export function App() { + return ( + <> + Edit + + ); +} diff --git a/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-plain-monochrome-component.input.tsx b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-plain-monochrome-component.input.tsx new file mode 100644 index 00000000000..f9f2bf5aeaa --- /dev/null +++ b/polaris-migrator/src/migrations/v12-react-update-button-component/tests/v12-react-update-button-plain-monochrome-component.input.tsx @@ -0,0 +1,24 @@ +import React from 'react'; +import {Button} from '@shopify/polaris'; +import {PhoneMajor} from '@shopify/polaris-icons'; + +export function App() { + const isPolarisUplift = true; + return ( + <> + + + + + + + {/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */} + + {/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */} + + + + + + + + {/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */} + + {/* polaris-migrator: Unable to migrate the following expression. Please upgrade manually. */} + +