Skip to content

extend progressive-custom-properties to the var() function #979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

romainmenke
Copy link
Member

@romainmenke romainmenke commented May 26, 2023

see : #978

.text-link {
  --tw-text-opacity: 1;
  color: rgba(87 107 149 / var(--tw-text-opacity));
}

There are two possible ways to generate fallbacks for this case :

A : resolve var() first

/* source */
.text-link {
  --tw-text-opacity: 1;
  color: rgba(87 107 149 / var(--tw-text-opacity));
}

/* step 1 */
.text-link {
  --tw-text-opacity: 1;
  color: rgba(87 107 149 / 1);
  color: rgba(87 107 149 / var(--tw-text-opacity));
}

/* step 2 */
.text-link {
  --tw-text-opacity: 1;
  color: rgba(87, 107, 149);
  color: rgba(87 107 149 / 1);
  color: rgba(87 107 149 / var(--tw-text-opacity));
}

B : resolve functional notation first

/* source */
.text-link {
  --tw-text-opacity: 1;
  color: rgba(87 107 149 / var(--tw-text-opacity));
}

/* step 1 */
.text-link {
  --tw-text-opacity: 1;
  color: rgba(87, 107, 149, var(--tw-text-opacity));
  color: rgba(87 107 149 / var(--tw-text-opacity));
}

/* step 2 */
.text-link {
  --tw-text-opacity: 1;
  color: rgba(87, 107, 149, 1);
  color: rgba(87, 107, 149, var(--tw-text-opacity));
  color: rgba(87 107 149 / var(--tw-text-opacity));
}

Option B is what we want in this case because it happens to cover a more interesting range of browsers correctly.

But it also makes it harder to first resolve var() so that we can fallback features with a more complex syntax. (e.g. color(var(--space) 0 0 0))

The correct solution to both issues is to extend the functionality of progressive-custom-properties so that any value that requires fallbacks and contains a var() function is placed in a @supports check for both that feature and var().

…nassuming-electric-eel-ccf9c8cf85' of https://github.com/csstools/postcss-plugins into extend-progressive-custom-properties-to-var-function--unassuming-electric-eel-ccf9c8cf85
…stom-properties-to-var-function--unassuming-electric-eel-ccf9c8cf85
@@ -58,7 +58,7 @@ The `preserve` option determines whether the original functional color notation
is preserved. By default, it is not preserved.

```js
postcssImageSetFunction({ preserve: true })
postcssColorFunctionalNotation({ preserve: true })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Member

@Antonio-Laguna Antonio-Laguna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM!

Thanks a lot for adding support for all of these plugins!

…function--unassuming-electric-eel-ccf9c8cf85
@romainmenke
Copy link
Member Author

thank you for reviewing all this 🙇

@romainmenke romainmenke merged commit 610cb27 into main Jun 1, 2023
@romainmenke romainmenke deleted the extend-progressive-custom-properties-to-var-function--unassuming-electric-eel-ccf9c8cf85 branch June 1, 2023 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment