Skip to content

Commit a651dac

Browse files
Fix duplicate semicolon in built CSS styles (#13179)
<!-- ☝️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 - Open it as a draft if it’s a work in progress --> ### WHY are these changes introduced? Fixes #13151 <!-- link to issue if one exists --> Came across this issue when trying to add tailwind v4 to a Shopify app template. Tailwind has switched CSS parsers in v4, and the vite plugin now errors if the app imports the Polaris styles with the error: ``` [plugin:@tailwindcss/vite:generate:serve] Unexpected semicolon .../node_modules/.pnpm/@Shopify+polaris@12.27.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@shopify/polaris/build/esm/styles.css ``` <!-- 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. Include a video if your changes include interactive content. 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> --> This PR removes the semi-colons from the shopify-react mixins which cause the double semicolons in the final built CSS file. It also removes the semicolon from the shadow button primary variable from within polaris-tokens, which was causing an additional duplicate semicolon. ### How to 🎩 - Storybook styling should remain unaffected - Using the tailwindcss v4 parser should not throw errors To test with tailwind, you should: - Go get the latest release of tailwind on GitHub at https://github.com/tailwindlabs/tailwindcss/releases/ and find the appropriate one for your operating system. Make sure it is executable if necessary. - Write a small input.css file that imports the shopify polaris built CSS file: ``` @import './build/esm/styles.css'; ``` - Parse the file with `./tailwindcss --input input.css --output output.css` N.B. It should be possible to recreate the error by parsing the styles.css before these changes were made (or in a separate existing project that uses shopify polaris): ``` @import './node_modules/@shopify/polaris/build/esm/styles.css'; ``` 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#install-dependencies-and-build-workspaces) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) ### 🎩 checklist - [ ] Tested a [snapshot](https://github.com/Shopify/polaris/blob/main/documentation/Releasing.md#-snapshot-releases) - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [x] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide
1 parent 25ca59d commit a651dac

File tree

5 files changed

+33
-27
lines changed

5 files changed

+33
-27
lines changed

.changeset/beige-eggs-live.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@shopify/polaris-tokens': patch
3+
'@shopify/polaris': patch
4+
---
5+
6+
Remove extra semicolons in CSS declarations that were causing duplicate semicolons in the built output

polaris-react/postcss-mixins/control-backdrop.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,53 @@ module.exports = (_, _style) => {
77
switch (style) {
88
case 'base': {
99
return {
10-
position: 'relative;',
11-
border: 'var(--p-border-width-050) solid var(--p-color-input-border);',
12-
backgroundColor: 'var(--p-color-bg-surface);',
13-
borderRadius: 'var(--p-border-radius-100);',
10+
position: 'relative',
11+
border: 'var(--p-border-width-050) solid var(--p-color-input-border)',
12+
backgroundColor: 'var(--p-color-bg-surface)',
13+
borderRadius: 'var(--p-border-radius-100)',
1414
'&.hover,&:hover': {
15-
cursor: 'pointer;',
16-
borderColor: 'var(--p-color-border-hover);',
15+
cursor: 'pointer',
16+
borderColor: 'var(--p-color-border-hover)',
1717
},
1818
};
1919
}
2020
case 'active': {
2121
return {
22-
borderColor: 'var(--p-color-border-emphasis);',
22+
borderColor: 'var(--p-color-border-emphasis)',
2323

2424
'&::before': {
2525
opacity: 1,
26-
transform: 'scale(1);',
26+
transform: 'scale(1)',
2727
'@media (-ms-high-contrast: active)': {
28-
border: 'var(--p-border-width-050) solid windowText;',
28+
border: 'var(--p-border-width-050) solid windowText',
2929
},
3030
},
3131
};
3232
}
3333
case 'disabled': {
3434
return {
35-
borderColor: 'var(--p-color-border-disabled);',
35+
borderColor: 'var(--p-color-border-disabled)',
3636

3737
'&::before': {
38-
backgroundColor: 'var(--p-color-bg-surface-disabled);',
38+
backgroundColor: 'var(--p-color-bg-surface-disabled)',
3939
},
4040

4141
'&:hover': {
42-
cursor: 'default;',
42+
cursor: 'default',
4343
},
4444
};
4545
}
4646
case 'error': {
4747
return {
48-
borderColor: 'var(--p-color-border-critical);',
49-
backgroundColor: 'var(--p-color-bg-fill-critical-secondary);',
48+
borderColor: 'var(--p-color-border-critical)',
49+
backgroundColor: 'var(--p-color-bg-fill-critical-secondary)',
5050

5151
'&.hover, &:hover': {
52-
borderColor: 'var(--p-color-border-critical);',
52+
borderColor: 'var(--p-color-border-critical)',
5353
},
5454

5555
'&::before': {
56-
backgroundColor: 'var(--p-color-border-critical);',
56+
backgroundColor: 'var(--p-color-border-critical)',
5757
},
5858
};
5959
}

polaris-react/postcss-mixins/responsive-props.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = (mixin, componentName, componentProp, declarationProp) => {
2929
var(--pc-${componentName}-${componentProp}-xs)
3030
)
3131
)
32-
);`,
32+
)`,
3333
},
3434
'@media (--p-breakpoints-xl-up)': {
3535
[declarationProp]: `var(
@@ -44,7 +44,7 @@ module.exports = (mixin, componentName, componentProp, declarationProp) => {
4444
)
4545
)
4646
)
47-
);`,
47+
)`,
4848
},
4949
};
5050
};

polaris-react/postcss-mixins/visually-hidden.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ module.exports = {
55
https://github.com/Shopify/polaris-react/pull/5208
66
*/
77
top: 0,
8-
width: '1px !important;',
9-
height: '1px !important;',
10-
margin: '0 !important;',
11-
padding: '0 !important;',
12-
overflow: 'hidden !important;',
13-
clipPath: 'inset(50%) !important;',
14-
border: '0 !important;',
15-
whiteSpace: 'nowrap !important;',
8+
width: '1px !important',
9+
height: '1px !important',
10+
margin: '0 !important',
11+
padding: '0 !important',
12+
overflow: 'hidden !important',
13+
clipPath: 'inset(50%) !important',
14+
border: '0 !important',
15+
whiteSpace: 'nowrap !important',
1616
};

polaris-tokens/src/themes/base/shadow.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const shadow: {
8282
},
8383
'shadow-button-primary': {
8484
value:
85-
'0px -1px 0px 1px rgba(0, 0, 0, 0.8) inset, 0px 0px 0px 1px rgba(48, 48, 48, 1) inset, 0px 0.5px 0px 1.5px rgba(255, 255, 255, 0.25) inset;',
85+
'0px -1px 0px 1px rgba(0, 0, 0, 0.8) inset, 0px 0px 0px 1px rgba(48, 48, 48, 1) inset, 0px 0.5px 0px 1.5px rgba(255, 255, 255, 0.25) inset',
8686
},
8787
'shadow-button-primary-hover': {
8888
value:

0 commit comments

Comments
 (0)