forked from Shopify/polaris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create migration for replacing v11
space
custom properties (Shopify…
…#10305) ### WHY are these changes introduced? Fixes Shopify#10445 ### WHAT is this pull request doing? This PR creates a migration for deprecated `space` custom properties in v12 using the generic codemod [`styles-replace-custom-property`](Shopify#8265). #### v12-styles-replace-custom-property-space | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-space-05` | `--p-space-050` | | `--p-space-1` | `--p-space-100` | | `--p-space-1_5-experimental` | `--p-space-150` | | `--p-space-2` | `--p-space-200` | | `--p-space-3` | `--p-space-300` | | `--p-space-4` | `--p-space-400` | | `--p-space-5` | `--p-space-500` | | `--p-space-6` | `--p-space-600` | | `--p-space-8` | `--p-space-800` | | `--p-space-10` | `--p-space-1000` | | `--p-space-12` | `--p-space-1200` | | `--p-space-16` | `--p-space-1600` | | `--p-space-20` | `--p-space-2000` | | `--p-space-24` | `--p-space-2400` | | `--p-space-28` | `--p-space-2800` | | `--p-space-32` | `--p-space-3200` |
- Loading branch information
Showing
5 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@shopify/polaris-migrator': minor | ||
--- | ||
|
||
Created migration to replace deprecated `space` custom properties in polaris-react v12.0.0 |
12 changes: 12 additions & 0 deletions
12
...-migrator/src/migrations/v12-styles-replace-custom-property-space/tests/transform.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import {check} from '../../../utilities/check'; | ||
|
||
const transform = 'v12-styles-replace-custom-property-space'; | ||
const fixtures = ['v12-styles-replace-custom-property-space']; | ||
|
||
for (const fixture of fixtures) { | ||
check(__dirname, { | ||
fixture, | ||
transform, | ||
extension: 'scss', | ||
}); | ||
} |
18 changes: 18 additions & 0 deletions
18
...s-replace-custom-property-space/tests/v12-styles-replace-custom-property-space.input.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.space { | ||
padding: var(--p-space-05); | ||
padding: var(--p-space-1); | ||
padding: var(--p-space-1_5-experimental); | ||
padding: var(--p-space-2); | ||
padding: var(--p-space-3); | ||
padding: var(--p-space-4); | ||
padding: var(--p-space-5); | ||
padding: var(--p-space-6); | ||
padding: var(--p-space-8); | ||
padding: var(--p-space-10); | ||
padding: var(--p-space-12); | ||
padding: var(--p-space-16); | ||
padding: var(--p-space-20); | ||
padding: var(--p-space-24); | ||
padding: var(--p-space-28); | ||
padding: var(--p-space-32); | ||
} |
18 changes: 18 additions & 0 deletions
18
...-replace-custom-property-space/tests/v12-styles-replace-custom-property-space.output.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.space { | ||
padding: var(--p-space-050); | ||
padding: var(--p-space-100); | ||
padding: var(--p-space-150); | ||
padding: var(--p-space-200); | ||
padding: var(--p-space-300); | ||
padding: var(--p-space-400); | ||
padding: var(--p-space-500); | ||
padding: var(--p-space-600); | ||
padding: var(--p-space-800); | ||
padding: var(--p-space-1000); | ||
padding: var(--p-space-1200); | ||
padding: var(--p-space-1600); | ||
padding: var(--p-space-2000); | ||
padding: var(--p-space-2400); | ||
padding: var(--p-space-2800); | ||
padding: var(--p-space-3200); | ||
} |
28 changes: 28 additions & 0 deletions
28
polaris-migrator/src/migrations/v12-styles-replace-custom-property-space/transform.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type {FileInfo, API} from 'jscodeshift'; | ||
|
||
import stylesReplaceCustomProperty from '../styles-replace-custom-property/transform'; | ||
|
||
export default function transformer(fileInfo: FileInfo, _: API) { | ||
return stylesReplaceCustomProperty(fileInfo, _, {replacementMaps}); | ||
} | ||
|
||
const replacementMaps = { | ||
'/.+/': { | ||
'--p-space-05': '--p-space-050', | ||
'--p-space-1': '--p-space-100', | ||
'--p-space-1_5-experimental': '--p-space-150', | ||
'--p-space-2': '--p-space-200', | ||
'--p-space-3': '--p-space-300', | ||
'--p-space-4': '--p-space-400', | ||
'--p-space-5': '--p-space-500', | ||
'--p-space-6': '--p-space-600', | ||
'--p-space-8': '--p-space-800', | ||
'--p-space-10': '--p-space-1000', | ||
'--p-space-12': '--p-space-1200', | ||
'--p-space-16': '--p-space-1600', | ||
'--p-space-20': '--p-space-2000', | ||
'--p-space-24': '--p-space-2400', | ||
'--p-space-28': '--p-space-2800', | ||
'--p-space-32': '--p-space-3200', | ||
}, | ||
}; |