Skip to content
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

css-color-5 #177

Closed
4 of 6 tasks
depoulo opened this issue Jan 18, 2022 · 7 comments
Closed
4 of 6 tasks

css-color-5 #177

depoulo opened this issue Jan 18, 2022 · 7 comments
Labels
feature request New feature or request

Comments

@depoulo
Copy link

depoulo commented Jan 18, 2022

What would you want to propose?

While I know that css-color-4 is just being implemented, I already wish postcss-preset-env supported https://drafts.csswg.org/css-color-5/.

  • color-mix
  • color-contrast (css-color-6 now)
  • relative colors

Suggested solution

🤷🏽‍♂️

Additional context

No response

Validations

  • Follow our Code of Conduct
  • Check that there isn't already an issue that request the same feature to avoid creating a duplicate.

Would you like to open a PR for this feature?

  • I'm willing to open a PR
@romainmenke
Copy link
Member

🎉 shipped :

@t0byman
Copy link

t0byman commented Apr 14, 2023

Do you have an ETA when the relative colors polyfill (with full support for dynamic CSS Custom Properties) ships?
Would make me very happy because then I can change:

:root {
    --c-dark: #333;

    @supports (color: oklch(0 0 0)) {
        --c-dark: oklch(0.3211 0 0);
    }
}

@supports not (background-color: oklch(from #000 l c h / 0%)) {
    background-color: color-mod(var(--c-dark) a(80%));
}

@supports (background-color: oklch(from #000 l c h / 0%)) {
    background-color: oklch(from var(--c-dark) l c h / 80%);
}

to just:

:root {
    --c-dark: oklch(0.3211 0 0);
}

background-color: oklch(from var(--c-title) l c h / 80%);

@romainmenke
Copy link
Member

romainmenke commented Apr 14, 2023

@t0byman We will never ship support for variables because it is impossible to statically determine their value.

We are still waiting on the specification to finalize.
Currently we have no idea what we need to create.

@romainmenke
Copy link
Member

🎉 shipped :

We now cover css-color-5 as much as possible.
We will open a new issue for css-color-6 and color-contrast when the specification progresses enough.

Thank you everyone for your interest in these features 🚀

@t0byman
Copy link

t0byman commented May 20, 2023

@t0byman We will never ship support for variables because it is impossible to statically determine their value.

We are still waiting on the specification to finalize. Currently we have no idea what we need to create.

Is it maybe possible to do it the the color-mod way?
By default, var() variables will be used if their corresponding Custom Properties are found in a :root rule, or if a fallback value is specified.

@romainmenke
Copy link
Member

Is it maybe possible to do it the the color-mod way?
By default, var() variables will be used if their corresponding Custom Properties are found in a :root rule, or if a fallback value is specified.

That is arguably a bug, not a feature :/

It is only correct when people are using custom properties as named constant values.
Which is not the intended use case of custom properties.

It is not good for the community when postcss-preset-env rolls out features that are sometimes wrong.

If you want to use custom properties as named constant values you can use postcss-custom-properties (standalone, not through postcss-preset-env) to resolve all values.

@t0byman
Copy link

t0byman commented May 20, 2023

Thanks for the tip, I got it working!

module.exports = {
  plugins: {
    '@csstools/postcss-global-data': { files: ['assets/css/base/variables.css'] },
    'postcss-custom-properties': { preserve: false },
    '@csstools/postcss-relative-color-syntax': { preserve: true },
    'postcss-extend': {},
    'postcss-advanced-variables': {},
    'postcss-preset-env': {
      stage: 1,
      features: {
        'gradients-interpolation-method': false,
      },
    },
  },
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants