Skip to content

Commit

Permalink
fix(postcss-colormin): preserve CSS variables
Browse files Browse the repository at this point in the history
Fix #1120
  • Loading branch information
ludofischer committed May 21, 2021
1 parent 9684747 commit 59d545b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/postcss-colormin/src/__tests__/index.js
Expand Up @@ -318,3 +318,8 @@ test(
'should not attempt to convert variables',
passthroughCSS(':root{--some-color: 200 255 0}')
);

test(
'should respect CSS variables',
passthroughCSS('div{background-color:rgba(51,153,255,var(--tw-bg-opacity))}')
);
3 changes: 3 additions & 0 deletions packages/postcss-colormin/src/colours.js
Expand Up @@ -5,6 +5,9 @@ import toShorthand from './lib/toShorthand';
extend([namesPlugin]);

export default (colour, isLegacy = false) => {
if (colour.includes('var(')) {
return colour;
}
/* check that it is a valid CSS value
https://www.w3.org/TR/css-color-4/#rgb-functions */
if (getFormat(colour) === 'rgb') {
Expand Down

0 comments on commit 59d545b

Please sign in to comment.