Skip to content

Commit

Permalink
Create migration for replacing v11 space custom properties (Shopify…
Browse files Browse the repository at this point in the history
…#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
lgriffee committed Sep 29, 2023
1 parent ffaebbd commit 0d403c8
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/short-llamas-hope.md
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
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',
});
}
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);
}
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);
}
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',
},
};

0 comments on commit 0d403c8

Please sign in to comment.