Skip to content

Commit dc2990a

Browse files
lgriffeechloericeaaronccasanova
authored
Add gap properties to replace-spacing-lengths migration (#7342)
<!-- ☝️How to write a good PR title: - Prefix it with [ComponentName] (if applicable), for example: [Button] - Start with a verb, for example: Add, Delete, Improve, Fix… - Give as much context as necessary and as little as possible - Prefix it with [WIP] while it’s a work in progress --> ### WHY are these changes introduced? Part of #7212 <!-- link to issue if one exists --> <!-- Context about the problem that’s being addressed. --> ### WHAT is this pull request doing? <!-- Summary of the changes committed. Before / after screenshots are appreciated for UI changes. Make sure to include alt text that describes the screenshot. If you include an animated gif showing your change, wrapping it in a details tag is recommended. Gifs usually autoplay, which can cause accessibility issues for people reviewing your PR: <details> <summary>Summary of your gif(s)</summary> <img src="..." alt="Description of what the gif shows"> </details> --> Adding more functionality to the `replace-spacing-lengths` migration script. Running ```npx @shopify/polaris-migrator replace-spacing-lengths "**/*.scss"``` will now also target the following `gap` properties and replace any `px`, `rem` or `rem()` values that align with our [spacing tokens](https://github.com/Shopify/polaris/blob/a192e3641a8629a2ea9e1a1bd5d6c20aaf9a499c/polaris-tokens/src/token-groups/spacing.ts). - `gap` - `grid-gap` - `row-gap` - `grid-row-gap` - `column-gap` - `grid-column-gap` Co-Authored-By: Chloe Rice <18447883+chloerice@users.noreply.github.com> Co-authored-by: Chloe Rice <18447883+chloerice@users.noreply.github.com> Co-authored-by: Chloe Rice <chloe.rice@shopify.com> Co-authored-by: Aaron Casanova <32409546+aaronccasanova@users.noreply.github.com>
1 parent 6228875 commit dc2990a

File tree

12 files changed

+503
-422
lines changed

12 files changed

+503
-422
lines changed

.changeset/dirty-students-move.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/polaris-migrator': minor
3+
---
4+
5+
Rename `replace-sass-length` migration to `replace-spacing-lengths`
6+
Add `gap` properties to `replace-sass-space` migration

polaris-migrator/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ A generic codemod to rename any component prop.
4949
npx @shopify/polaris-migrator rename-component-prop <path> --component=MyComponent --from=prop --to=newProp
5050
```
5151

52+
### `replace-spacing-lengths`
53+
54+
Replace lengths and functions (`px`, `rem` and `rem()`) in spacing declarations (`padding`, `margin`, and `gap`) with the corresponding Polaris spacing token.
55+
56+
```diff
57+
- padding: 16px;
58+
+ padding: var(--p-space-4);
59+
60+
- margin: 1rem;
61+
+ margin: var(--p-space-4);
62+
63+
- gap: rem(16px);
64+
+ gap: var(--p-space-4);
65+
```
66+
67+
```sh
68+
npx @shopify/polaris-migrator replace-spacing-lengths <path>
69+
```
70+
5271
### v9
5372

5473
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>`.

polaris-migrator/src/migrations/replace-sass-lengths/replace-sass-lengths.ts

Lines changed: 0 additions & 120 deletions
This file was deleted.

polaris-migrator/src/migrations/replace-sass-lengths/tests/replace-sass-lengths.output.scss

Lines changed: 0 additions & 80 deletions
This file was deleted.

polaris-migrator/src/migrations/replace-sass-lengths/tests/with-namespace.output.scss

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)