Serialization / Deserialization
An issue to track this feature. Achieving full CSS parity is a complex task and will likely remain out of scope (and I imagine the CSS spec will continue to grow in complexity, with things like [relative colors](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_colors/Relative_colors) and calculation).
However, it would be nice to have a serializer/deserializer that achieves the following:
- [ ] Serializes to a CSS-like color string, which works for expected spaces (such as sRGB, OKLCH) but is not expected to work for non-supported spaces (e.g. Rec2020Linear)
- [ ] Deserializes basic strings into a `{ id, coords }` object
- [ ] Evaluate whether there is a way to achieve keywords ("purple" etc) without increasing bundle size for all users
- [ ] Perhaps some easy way to "parse" a string into a predictable color space – so that you don't have to do a manual lookup against the `{ id }`
- [ ] Somehow this should be achievable without creating additional file size bloat for users who don't need to deal with CSS color strings
- [ ] Should be a way to handle arbitrary custom color spaces – for example if somebody creates CIELab color space, there should be a way for that to hook into serialize/deserialize functions
Although most of this is working already, the main thing is to figure out and perhaps refactor things to finish the last three tasks.
In addition to `@texel/color`, it would be nice to have `@texel/css-color` or something, that is able to parse and serialize strings with full CSS parity and keywords.
0 条评论