-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Parse both dashed-ident and ident versions, and add missing dashed-idents to color spaces. #439
Conversation
✅ Deploy Preview for colorjs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the HDR color spaces in CSS Color HDR Module Level 1 have a <dashed-ident>?
Will we remove the <dashed-ident> cssId
as a breaking change if/when the HDR spaces are implemented in browsers?
I think we should go with unprefixed ids for the HDR spaces as they'll most likely be made a standard part of CSS.
Overall I prefer this PR to #435.
I went with
Yes, my assumption is that as colors are added to the spec and implemented in browsers, we will remove the dashed-ident from their
🎉 |
src/parse.js
Outdated
@@ -102,17 +103,24 @@ export default function parse (str, {meta} = {}) { | |||
Object.assign(meta, {formatId: "color", types}); | |||
} | |||
|
|||
if (colorSpec.id.startsWith("--") && !id.startsWith("--")) { | |||
console.warn(`Use prefixed color(${colorSpec.id}) instead of color(${id}).`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to clarify why this distinction exists, otherwise the warning makes it sound like Color.js is annoying for no reason. E.g. something like:
console.warn(`Use prefixed color(${colorSpec.id}) instead of color(${id}).`); | |
console.warn(`${space.name} is a non-standard space, so you should use color(${colorSpec.id}) instead of color(${id}).`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -14,6 +14,7 @@ const fromXYZ_M = [ | |||
|
|||
export default new RGBColorSpace({ | |||
id: "p3-linear", | |||
cssId: "--display-p3-linear", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oof. I understand why it's as awkward as it is, but it makes me sad.
I wonder if it may make sense to allow providing multiple dashed ids, so we could also provide --p3-linear
but that's a out of scope for this PR…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not have called it just "p3" because that is ambiguous. Cinema uses DCI-P3, video uses P3-D65 and CSS (among other things) uses Display-P3.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is fantastic work @jgerigmeyer, thank you so much for working on this!!
My only substantive comment at this point is that I'd prefer to keep the trailing commas to keep the diff small, but even that I wouldn't elevate it to a blocker.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
92e0915
to
b1cf95a
Compare
* main: Enforce trailing commas unless `]` or `}` is on the same line. (#440) Update index.html Update color-swatch.css lint [apps/gamut-mapping] Support multiple colors [apps/gamut-mapping] Show favicon and title immediately, not just when color changes [apps/gamut-mapping] Prepare HTML & CSS for supporting multiple colors
I like the idea of parsing both the dashed and undashed forms.
Note that CSS Color HDR is now an official CSSWG spec, building on CSS Color 4 which remains SDR-only. So we should not have dashed idents for things already part of that spec. See also: |
@@ -14,6 +14,7 @@ const fromXYZ_M = [ | |||
|
|||
export default new RGBColorSpace({ | |||
id: "p3-linear", | |||
cssId: "--display-p3-linear", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not have called it just "p3" because that is ambiguous. Cinema uses DCI-P3, video uses P3-D65 and CSS (among other things) uses Display-P3.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
…ents to color spaces. (color-js#439) * Parse both dashed-ident and ident versions, and add missing dashed-idents to color spaces. * Warn when using incorrect dashed-ident/ident * refactor * Update warnings * Add trailing commas and make warning more descriptive. * Remove dashed-ident prefix for HDR colors.
Partial solution for #433, as an alternative to #435.
This PR makes a few changes, and I'm not tied strongly to any of them -- this is a starting point for discussion.
<dashed-ident>
and<ident>
versions ofcolor()
spaces, warning if e.g.color(rec2100-hlg)
is used instead ofcolor(--rec2100-hlg)
, and similarly ifcolor(--display-p3)
is used instead ofcolor(display-p3)
.formats.color.id
defined if it's missing -- defaults tocssId
if provided, otherwiseid
.cssId
option to color spaces, using dashed-ident where appropriate, and removes unnecessaryformats.color
definitions.This PR does not attempt to auto-generate
coordGrammer
for color spaces.This shouldn't be a breaking change in terms of parsing colors (and it does fix #433), but it is a breaking change in the sense that now e.g.
color(acescc)
will be serialized ascolor(--acescc)
.