facebook / stylex

StyleX is the styling system for ambitious user interfaces.
https://stylexjs.com
MIT License
8.21k stars 304 forks source link

Color Format issues #558

Closed meza closed 1 month ago

meza commented 2 months ago

Describe the issue

Custom color formats are disregarded in the generated css. Currently it all gets converted to lab

image

Expected behavior

When using any custom color format like hls or oklch, the generated CSS should retain those formats.

Steps to reproduce

Using:

win32-x64 vite/5.2.10
node-v21.7.1 stylex: 0.6.1 vite-plugin-stylex-dev: 0.6.1 remix: 2.9.1

Define color variables that use specific color formats.

Test case

import * as stylex from '@stylexjs/stylex';

const hues = {
  amber: 73.12
};

export const colours = stylex.defineVars({
  amber01: 'hsl(45,88%,6%)',
  amber02: `oklch(22.05% 0.046 ${hues.amber}deg)`,
  amber03: `oklch(25.32% 0.056 ${hues.amber}deg)`,
  amber04: `oklch(28.43% 0.0638 ${hues.amber}deg)`,
  amber05: `oklch(31.66% 0.0709 ${hues.amber}deg)`,
  amber06: `oklch(35.74% 0.0786 ${hues.amber}deg)`,
  amber07: `oklch(40.86% 0.088 ${hues.amber}deg)`,
  amber08: `oklch(47.33% 0.1045 ${hues.amber}deg)`,
  amber09: `oklch(81.69% 0.1638 ${hues.amber}deg)`,
  amber10: `oklch(86.59% 0.1539 ${hues.amber}deg)`,
  amber11: `oklch(76.93% 0.162 ${hues.amber}deg)`,
  amber12: `oklch(96.7% 0.031 ${hues.amber}deg)`
});

Additional comments

I tried with the vite-stylex-plugin and I tried with the vite-stylex-plugin-dev. My styles that aren't through stylex come out untouched on the other end of my build chain, as expected.

meza commented 2 months ago

What I just realised is that it gets converted to rgb as a default! image

meza commented 1 month ago

Ignore this, lightningcss was the culprit!