Skip to content

Commit cccd698

Browse files
lgriffeeaaronccasanovaheyjoethomas
authored
Create migrations for replacing legacy v11 custom properties (#8272)
<!-- ☝️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 #8405 <!-- link to issue if one exists --> <!-- Context about the problem that’s being addressed. --> ### WHAT is this pull request doing? This PR creates migrations for the following deprecated custom property groups in v11 using the generic codemod [`styles-replace-custom-property`](#8265). Due to a bit of confusion on my end I also ended up creating some v9 migrations as well 😅 # v11 ### v11-styles-replace-custom-property-border | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-border-radius-base` | `--p-border-radius-1` | | `--p-border-radius-large` | `--p-border-radius-2` | | `--p-border-radius-half` | `--p-border-radius-full` | | `--p-border-base` | `var(--p-border-width-1) solid var(--p-color-border-subdued)` | | `--p-border-dark` | `var(--p-border-width-1) solid var(--p-color-border)` | | `--p-border-transparent` | `var(--p-border-width-1) solid transparent` | | `--p-border-divider` | `var(--p-border-width-1) solid var(--p-color-border-subdued)` | | `--p-border-divider-on-dark` | `var(--p-border-width-1) solid var(--p-color-border-inverse)` | ### v11-styles-replace-custom-property-depth | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-shadow-transparent` | `--p-shadow-none` | |`--p-shadow-faint` | `--p-shadow-sm` | |`--p-shadow-base` | `--p-shadow-md` | |`--p-shadow-deep` | `--p-shadow-md` | |`--p-shadow-button` | `--p-shadow-sm` | |`--p-shadow-top-bar` | `--p-shadow-sm` | |`--p-shadow-card` | `--p-shadow-md` | |`--p-shadow-popover` | `--p-shadow-xl` | |`--p-shadow-layer` | `--p-shadow-2xl` | |`--p-shadow-modal` | `--p-shadow-2xl` | |`--p-shadows-inset-button` | `--p-shadow-none` | |`--p-shadows-inset-button-pressed` | `--p-shadow-inset-md` | ### v11-styles-replace-custom-property-zindex | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-z-1` | `--p-z-index-1` | | `--p-z-2` | `--p-z-index-2` | | `--p-z-3` | `--p-z-index-3` | | `--p-z-4` | `--p-z-index-4` | | `--p-z-5` | `--p-z-index-5` | | `--p-z-6` | `--p-z-index-6` | | `--p-z-7` | `--p-z-index-7` | | `--p-z-8` | `--p-z-index-8` | | `--p-z-9` | `--p-z-index-9` | | `--p-z-10` | `--p-z-index-10` | | `--p-z-11` | `--p-z-index-11` | | `--p-z-12` | `--p-z-index-12` | ### v11-styles-replace-custom-property-legacy | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-override-loading-z-index` | `--p-z-index-6` | | `--p-choice-size` | `1.25rem` | | `--p-icon-size-small` | `0.5rem` | | `--p-icon-size-medium` | `1.25rem` | | `--p-choice-margin` | `--p-space-025` | | `--p-control-border-width` | `--p-border-width-2` | | `--p-banner-border-default` | `inset 0 var(--p-border-width-1) 0 0 var(--p-color-border-strong), inset 0 0 0 (--p-border-width-1) var(--p-color-border-strong)` | | `--p-banner-border-success` | `inset 0 var(--p-border-width-1) 0 0 var(--p-color-border-success-subdued), inset 0 0 0 (--p-border-width-1) var(--p-color-border-success-subdued)` | | `--p-banner-border-highlight` | `inset 0 var(--p-border-width-1) 0 0 var(--p-color-border-info-subdued), inset 0 0 0 (--p-border-width-1) var(--p-color-border-info-subdued)` | | `--p-banner-border-warning` | `inset 0 var(--p-border-width-1) 0 0 var(--p-color-border-caution-subdued), inset 0 0 0 (--p-border-width-1)var(--p-color-border-caution-subdued)` | | `--p-banner-border-critical` | `inset 0 var(--p-border-width-1) 0 0 var(--p-color-border-critical-subdued), inset 0 0 0 (--p-border-width-1) var(--p-color-border-critical-subdued)` | | `--p-thin-border-subdued` | `var(--p-border-width-1) solid var(--p-color-border-subdued)` | | `--p-text-field-spinner-offset` | `0.125rem` | | `--p-text-field-focus-ring-offset` | `-0.25rem` | | `--p-button-group-item-spacing` | `calc(-1 * var(--p-space-025))` | | `--p-range-slider-thumb-size-base` | `1rem` | | `--p-range-slider-thumb-size-active` | `1.5rem` | | `--p-frame-offset` | `0` | # v9 ### v9-styles-replace-custom-property-border | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-border-radius-slim` | `--p-border-radius-05` | | `--p-border-radius-wide` | `--p-border-radius-2` | | `--p-text-field-focus-ring-border-radius` | `0.4375rem` / `7px` | ### v9-styles-replace-custom-property-depth | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-button-drop-shadow` | `--p-shadow-button` | | `--p-button-inner-shadow` | `--p-shadows-inset-button` | | `--p-button-pressed-inner-shadow` | `--p-shadows-inset-button-pressed` | | `--p-card-shadow` | `--p-shadow-card` | | `--p-modal-shadow` | `--p-shadow-modal` | | `--p-popover-shadow` | `--p-shadow-popover` | | `--p-top-bar-shadow` | `--p-shadow-top-bar` | | `--p-shadow-from-ambient-light` | `rgba(23, 24, 24, 0.05)` | | `--p-shadow-from-dim-light` | `rgba(0, 0, 0, 0.2)` | | `--p-shadow-from-direct-light` | `rgba(0, 0, 0, 0.15)` | ### v9-styles-replace-custom-property-font | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-badge-font-weight` | `--p-font-weight-regular` | | `--p-button-font-weight` | `--p-font-weight-medium` | ### v9-styles-replace-custom-property-motion | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-duration-1-0-0` | `--p-duration-100` | | `--p-duration-1-5-0` | `--p-duration-150` | ### v9-styles-replace-custom-property-legacy | Deprecated CSS Custom Property | Replacement Value | | ----------------------------------------- | ---------------------------------- | | `--p-override-none` | `none` | | `--p-override-one` | `1` | | `--p-override-visible` | `visible` | | `--p-override-zero` | `0` | | `--p-override-transparent` | `transparent` | | `--p-non-null-content` | `''` | | `--p-icon-size` | `--p-icon-size-small` | | `--p-range-slider-thumb-scale` | `1.5` | | `--p-badge-mix-blend-mode` | `luminosity` | <!-- 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> --> --------- Co-authored-by: Aaron Casanova <32409546+aaronccasanova@users.noreply.github.com> Co-authored-by: Joe Thomas <joe.thomas@shopify.com>
1 parent 65a678d commit cccd698

File tree

38 files changed

+777
-7
lines changed

38 files changed

+777
-7
lines changed

.changeset/ten-drinks-refuse.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+
'polaris.shopify.com': minor
4+
---
5+
6+
Create migrations to replace deprecated custom properties in polaris-react v11.0.0 and v9.0.0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.border {
2+
border-radius: var(--p-border-radius-base);
3+
border-radius: var(--p-border-radius-large);
4+
border-radius: var(--p-border-radius-half);
5+
border: var(--p-border-base);
6+
border: var(--p-border-dark);
7+
border: var(--p-border-transparent);
8+
border: var(--p-border-divider);
9+
border: var(--p-border-divider-on-dark);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.border {
2+
border-radius: var(--p-border-radius-1);
3+
border-radius: var(--p-border-radius-2);
4+
border-radius: var(--p-border-radius-full);
5+
border: var(--p-border-width-1) solid var(--p-color-border-subdued);
6+
border: var(--p-border-width-1) solid var(--p-color-border);
7+
border: var(--p-border-width-1) solid transparent;
8+
border: var(--p-border-width-1) solid var(--p-color-border-subdued);
9+
border: var(--p-border-width-1) solid var(--p-color-border-inverse);
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {check} from '../../../utilities/testUtils';
2+
3+
const migration = 'v11-styles-replace-custom-property-border';
4+
const fixtures = ['v11-styles-replace-custom-property-border'];
5+
6+
for (const fixture of fixtures) {
7+
check(__dirname, {
8+
fixture,
9+
migration,
10+
extension: 'scss',
11+
});
12+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type {FileInfo, API} from 'jscodeshift';
2+
3+
import stylesReplaceCustomProperty from '../styles-replace-custom-property/styles-replace-custom-property';
4+
5+
const replacementMaps = {
6+
'/.+/': {
7+
'--p-border-radius-base': '--p-border-radius-1',
8+
'--p-border-radius-large': '--p-border-radius-2',
9+
'--p-border-radius-half': '--p-border-radius-full',
10+
'--p-border-base':
11+
'var(--p-border-width-1) solid var(--p-color-border-subdued)',
12+
'--p-border-dark': 'var(--p-border-width-1) solid var(--p-color-border)',
13+
'--p-border-transparent': 'var(--p-border-width-1) solid transparent',
14+
'--p-border-divider':
15+
'var(--p-border-width-1) solid var(--p-color-border-subdued)',
16+
'--p-border-divider-on-dark':
17+
'var(--p-border-width-1) solid var(--p-color-border-inverse)',
18+
},
19+
};
20+
21+
export default function v11StylesReplaceCustomPropertyBorder(
22+
fileInfo: FileInfo,
23+
_: API,
24+
) {
25+
return stylesReplaceCustomProperty(fileInfo, _, {replacementMaps});
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.depth {
2+
box-shadow: var(--p-shadow-transparent);
3+
box-shadow: var(--p-shadow-faint);
4+
box-shadow: var(--p-shadow-base);
5+
box-shadow: var(--p-shadow-deep);
6+
box-shadow: var(--p-shadow-button);
7+
box-shadow: var(--p-shadow-top-bar);
8+
box-shadow: var(--p-shadow-card);
9+
box-shadow: var(--p-shadow-popover);
10+
box-shadow: var(--p-shadow-layer);
11+
box-shadow: var(--p-shadow-modal);
12+
box-shadow: var(--p-shadows-inset-button);
13+
box-shadow: var(--p-shadows-inset-button-pressed);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.depth {
2+
box-shadow: var(--p-shadow-none);
3+
box-shadow: var(--p-shadow-sm);
4+
box-shadow: var(--p-shadow-md);
5+
box-shadow: var(--p-shadow-md);
6+
box-shadow: var(--p-shadow-sm);
7+
box-shadow: var(--p-shadow-sm);
8+
box-shadow: var(--p-shadow-md);
9+
box-shadow: var(--p-shadow-xl);
10+
box-shadow: var(--p-shadow-2xl);
11+
box-shadow: var(--p-shadow-2xl);
12+
box-shadow: var(--p-shadow-none);
13+
box-shadow: var(--p-shadow-inset-md);
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import {check} from '../../../utilities/testUtils';
2+
3+
const migration = 'v11-styles-replace-custom-property-depth';
4+
const fixtures = ['v11-styles-replace-custom-property-depth'];
5+
6+
for (const fixture of fixtures) {
7+
check(__dirname, {
8+
fixture,
9+
migration,
10+
extension: 'scss',
11+
});
12+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import type {FileInfo, API} from 'jscodeshift';
2+
3+
import stylesReplaceCustomProperty from '../styles-replace-custom-property/styles-replace-custom-property';
4+
5+
const replacementMaps = {
6+
'/.+/': {
7+
'--p-shadow-transparent': '--p-shadow-none',
8+
'--p-shadow-faint': '--p-shadow-sm',
9+
'--p-shadow-base': '--p-shadow-md',
10+
'--p-shadow-deep': '--p-shadow-md',
11+
'--p-shadow-button': '--p-shadow-sm',
12+
'--p-shadow-top-bar': '--p-shadow-sm',
13+
'--p-shadow-card': '--p-shadow-md',
14+
'--p-shadow-popover': '--p-shadow-xl',
15+
'--p-shadow-layer': '--p-shadow-2xl',
16+
'--p-shadow-modal': '--p-shadow-2xl',
17+
'--p-shadows-inset-button': '--p-shadow-none',
18+
'--p-shadows-inset-button-pressed': '--p-shadow-inset-md',
19+
},
20+
};
21+
22+
export default function v11StylesReplaceCustomPropertyDepth(
23+
fileInfo: FileInfo,
24+
_: API,
25+
) {
26+
return stylesReplaceCustomProperty(fileInfo, _, {replacementMaps});
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.legacy {
2+
z-index: var(--p-override-loading-z-index);
3+
width: var(--p-choice-size);
4+
width: var(--p-icon-size-small);
5+
width: var(--p-icon-size-medium);
6+
margin: var(--p-choice-margin);
7+
border-width: var(--p-control-border-width);
8+
box-shadow: var(--p-banner-border-default);
9+
box-shadow: var(--p-banner-border-success);
10+
box-shadow: var(--p-banner-border-highlight);
11+
box-shadow: var(--p-banner-border-warning);
12+
box-shadow: var(--p-banner-border-critical);
13+
border: var(--p-thin-border-subdued);
14+
margin: var(--p-text-field-spinner-offset);
15+
margin-left: var(--p-text-field-focus-ring-offset);
16+
padding: var(--p-button-group-item-spacing);
17+
width: var(--p-range-slider-thumb-size-base);
18+
width: var(--p-range-slider-thumb-size-active);
19+
margin: var(--p-frame-offset);
20+
}

0 commit comments

Comments
 (0)