You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For projects that use the [`@use` rule](https://sass-lang.com/documentation/at-rules/use), all Sass related migrations (ex: `replace-sass-spacing`) accept a `namespace` flag to target a specific `<namespace>.<variable|function|mixin>`.
Replace the legacy Sass `color()` function with the supported CSS custom property token equivalent (ex: `var(--p-surface)`). This will only replace a limited subset of mapped values. See the [color-maps.ts](https://github.com/Shopify/polaris/blob/main/polaris-migrator/src/migrations/replace-sass-color/color-maps.ts) for a full list of color mappings based on the CSS property.
82
82
@@ -88,10 +88,10 @@ Replace the legacy Sass `color()` function with the supported CSS custom propert
Replace legacy static breakpoint mixins with the new Polaris [media query variables](https://github.com/Shopify/polaris/blob/main/documentation/guides/migrating-from-v9-to-v10.md#media-query-variables).
112
112
@@ -116,10 +116,10 @@ Replace legacy static breakpoint mixins with the new Polaris [media query variab
Replace legacy Typography functions and hardcoded lengths with Polaris custom properties for `font-family`, `font-size`, `font-weight`, and `line-height` declarations.
139
139
@@ -152,10 +152,10 @@ Replace legacy Typography functions and hardcoded lengths with Polaris custom pr
Replace lengths (`px`, `rem`) and legacy Sass functions (`rem()`,`border()`, `border-width()`, `border-radius()`) in border declarations (`border`, `border-width`, and `border-radius`) with the corresponding Polaris [shape](https://polaris.shopify.com/tokens/shape) token.
Replace the legacy Sass `z-index()` function with the supported CSS custom property token equivalent (ex: `var(--p-z-1)`).
189
189
@@ -232,7 +232,7 @@ In these cases you may also want to run `npx sass-migrator module <path> --migra
232
232
Be aware that this may also create additional code changes in your codebase, we recommend running this only if there are large number of instances of migrations from `z-index` to `map.get`. Otherwise it may be easier to add `use 'sass:map'` to the top of your `.scss` file manually.
? [PLOP] Please choose a generator. (Use arrow keys)
256
-
❯ sass-migration
256
+
❯ scss-migration
257
257
typescript-migration
258
258
```
259
259
260
-
Next, provide the name of your migration. For example; `replace-sass-function`:
260
+
Next, provide the name of your migration. For example; `scss-replace-function`:
261
261
262
262
```sh
263
263
? [PLOP] Please choose a generator. sass-migration
264
-
? Name of the migration (e.g. replace-sass-layout) replace-sass-function
264
+
? Name of the migration (e.g. scss-replace-function) scss-replace-function
265
265
```
266
266
267
267
The generator will create the following files in the `migrations` folder:
268
268
269
269
```
270
270
migrations
271
-
└── replace-sass-function
272
-
├── replace-sass-function.ts
271
+
└── scss-replace-function
272
+
├── scss-replace-function.ts
273
273
└── tests
274
-
├── replace-sass-function.input.scss
275
-
├── replace-sass-function.output.scss
276
-
└── replace-sass-function.test.ts
274
+
├── scss-replace-function.input.scss
275
+
├── scss-replace-function.output.scss
276
+
└── scss-replace-function.test.ts
277
277
```
278
278
279
-
#### The SASS migration function
279
+
#### The SCSS migration function
280
280
281
281
Each migrator has a default export adhering to the [PostCSS Plugin API](https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md) with one main difference: events are only executed once.
282
282
283
283
Continuing the example, here is what the migration may look like if our goal is to replace the Sass function `hello()` with `world()`.
A more complete example can be seen in [`replace-spacing-lengths.ts`](https://github.com/Shopify/polaris/blob/main/polaris-migrator/src/migrations/replace-spacing-lengths/replace-spacing-lengths.ts).
315
+
A more complete example can be seen in [`styles-tokenize-space.ts`](https://github.com/Shopify/polaris/blob/main/polaris-migrator/src/migrations/styles-tokenize-space/styles-tokenize-space.ts).
316
316
317
317
#### Testing
318
318
319
319
The template will also generate starting test files you can use to test your migration. In your migrations `tests` folder, you can see 3 files:
320
320
321
-
-`replace-sass-function.test.ts` – Runs the fixtures and sets up additional migration options
322
-
-`replace-sass-function.input.scss` – The starting source input
323
-
-`replace-sass-function.output.scss` – The expected output after migration
321
+
-`scss-replace-function.test.ts` – Runs the fixtures and sets up additional migration options
322
+
-`scss-replace-function.input.scss` – The starting source input
323
+
-`scss-replace-function.output.scss` – The expected output after migration
324
324
325
325
The main test file will load the input/output fixtures to test your migration against. You can configure additional fixtures and test migration options (see the `replace-sass-spacing.test.ts` as an example).
326
326
@@ -329,7 +329,7 @@ The main test file will load the input/output fixtures to test your migration ag
329
329
Run tests locally from workspace root by filtering to the migrations package:
330
330
331
331
```sh
332
-
npx turbo run test --filter=polaris-migrator -- replace-sass-function
332
+
npx turbo run test --filter=polaris-migrator -- scss-replace-function
333
333
```
334
334
335
335
### Testing in another codebase
@@ -340,7 +340,7 @@ In your PR, you can add a comment with the text `/snapit` to create a new [snaps
Copy file name to clipboardExpand all lines: polaris-migrator/src/migrations/replace-static-breakpoint-mixins/tests/replace-static-breakpoint-mixins.test.ts
Copy file name to clipboardExpand all lines: polaris-migrator/src/migrations/replace-static-mixins-with-declarations/tests/replace-static-mixins-with-declarations.test.ts
Copy file name to clipboardExpand all lines: polaris-migrator/src/migrations/replace-typography-declarations/tests/replace-typography-declarations.test.ts
0 commit comments