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

Palettes: Migrate color shades to CSS relative colors #84

Open
simeonoff opened this issue Jun 12, 2023 · 1 comment · May be fixed by #137 or IgniteUI/igniteui-angular#13769
Open

Palettes: Migrate color shades to CSS relative colors #84

simeonoff opened this issue Jun 12, 2023 · 1 comment · May be fixed by #137 or IgniteUI/igniteui-angular#13769
Assignees
Labels

Comments

@simeonoff
Copy link
Contributor

Currently, each color shade is generated using the calc function with the h, s, and l components of the base 500 color being multiplied by a factor to achieve a runtime adjustable palette. With the CSS color-mix function now available in most ever-green browsers, we can reimplement how color shades are calculated so that:

  1. The input color/base variant doesn't need to be in the HSL color space.
  2. Have a more robust color palette that scales better.
@simeonoff
Copy link
Contributor Author

simeonoff commented Jun 16, 2023

After initial review and testing, it seems that changing the alpha values of the generated colors using color-mix is virtually impossible, which is a dealbreaker for now.

Looks like the Relative colors syntax is a better candidate for it that doesn't introduce any breaking changes. However, this syntax is only supported in Safari.

Related issue in Chrome
Related issue in Firefox

Example with relative colors:

Declaring global palette colors:

--primary-500: #09f;
--primary-600: hsl(from var(--primary-500) h calc(s * 1.26) calc(l * 0.89));

Consuming colors:

/* Add 50% opacity to the primary 600 variant. */
igc-avatar {
    background-color: hsl(from var(--primary-600) h s l / .5);
}

The approach above opens the door for eventually switching to another color space and a different formula for generating color shades that produces better results with variable base colors (500 variant).

@simeonoff simeonoff changed the title Palettes: Migrate color shades to CSS color-mix function Palettes: Migrate color shades to CSS relative color syntax Aug 7, 2023
@simeonoff simeonoff changed the title Palettes: Migrate color shades to CSS relative color syntax Palettes: Migrate color shades to CSS relative colors Aug 7, 2023
@simeonoff simeonoff assigned SisIvanova and didimmova and unassigned simeonoff Dec 11, 2023
@SisIvanova SisIvanova linked a pull request Dec 12, 2023 that will close this issue
@SisIvanova SisIvanova linked a pull request Jan 2, 2024 that will close this issue
14 tasks
@SisIvanova SisIvanova linked a pull request Jan 2, 2024 that will close this issue
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants