Skip to content

Commit b5d8db5

Browse files
committed
replace-sass-transition migration
1 parent 8c19896 commit b5d8db5

File tree

9 files changed

+1291
-4
lines changed

9 files changed

+1291
-4
lines changed

.changeset/famous-ghosts-march.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+
Introduce `migrate-motion` migration for migrating `transition`, `transition-duration`, and `transition-delay` usages of duration values.

polaris-migrator/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,37 @@ Be aware that this may also create additional code changes in your codebase, we
235235
npx @shopify/polaris-migrator replace-sass-spacing <path>
236236
```
237237

238+
### `replace-sass-transition`
239+
240+
Replace timings (`ms`, `s`) and legacy Sass functions (`duration()`,`easing()`) in transition declarations (`transition`, `transition-duration`, `transition-delay`, and `transition-timing-function`) with the corresponding Polaris [motion](https://polaris.shopify.com/tokens/motion) token.
241+
242+
```diff
243+
- transition-duration: 100ms;
244+
+ transition-duration: var(--p-duration-100);
245+
246+
- transition-duration: legacy-polaris-v8.duration('slow');
247+
+ transition-duration: var(--p-duration-300);
248+
249+
- transition-timing-function: linear;
250+
+ transition-timing-function: var(--p-linear);
251+
252+
- transition-timing-function: legacy-polaris-v8.easing('in');
253+
+ transition-timing-function: var(--p-ease-in);
254+
255+
- transition: opacity 100ms linear;
256+
+ transition: opacity var(--p-duration-100) linear;
257+
258+
- transition: opacity legacy-polaris-v8.duration('slow') linear;
259+
+ transition: opacity var(--p-duration-300) linear;
260+
261+
- transition: opacity 100ms linear, left 100ms linear;
262+
+ transition: opacity var(--p-duration-100) linear, left var(--p-duration-100) linear;
263+
```
264+
265+
```sh
266+
npx @shopify/polaris-migrator replace-sass-transition <path>
267+
```
268+
238269
## Creating Migrations
239270

240271
Sometimes referred to as "codemods", migrations are JavaScript functions which modify some code from one form to another (eg; to move between breaking versions of `@shopify/polaris`). ASTs (Abstract Syntax Trees) are used to "walk" through the code in discreet, strongly typed steps, called "nodes". All changes made to nodes (and thus the AST) are then written out as the new/"migrated" version of the code.

0 commit comments

Comments
 (0)