Re: [csswg-drafts] [css-color-6] Let's finally settle contrast-color() syntax (#7937)

The CSS Working Group just discussed `[css-color-6] Let's finally settle contrast-color() syntax`.

<details><summary>The full IRC log of that discussion</summary>
&lt;TabAtkins> lea: The primary problem we couldn't settle on was what to call foreground/background. We reoslved to distinguish them in the syntax but couldn't decide on names<br>
&lt;TabAtkins> lea: foreground/background too long, fg/bg too cryptic, others suggested front/back, fore/back<br>
&lt;TabAtkins> lea: There's a table of the options<br>
&lt;TabAtkins> lea: And should we have a default if the keyword isn't specified? Probably with bg as the base color, which'll be the most common case? Or should we require the keyword?<br>
&lt;TabAtkins> fantasai: I think I'm strongly in favor of it being mandatory, so people will pay attention<br>
&lt;TabAtkins> lea: advantage of making it options is that only the fg word actually matters so we can just pick a good name there. can also be longer since it's not typed as much<br>
&lt;TabAtkins> argyle: That's my proposal - make it optional and make the fg keyword short and easy.<br>
&lt;argyle> https://observablehq.com/@argyleink/contrast-color<br>
&lt;TabAtkins> argyle: This is the interactive explianer, syntax is right under the demo<br>
&lt;argyle> https://www.irccloud.com/pastebin/mO4ENSCC/<br>
&lt;lea> s/and make the fg keyword short and easy./and have the whole foreground keyword, since it's the exception/<br>
&lt;TabAtkins> [gonna have argyleink present]<br>
&lt;TabAtkins> Rossen_: If you need to present visually, our next zoom meeting will be next month<br>
&lt;TabAtkins> [more presentation chatter]<br>
&lt;TabAtkins> argyle: Bunch of examples in this observable document later<br>
&lt;TabAtkins> argyle: The current spec isn't far off from excellent, i think, so my important bits in myc ounter proposal:<br>
&lt;TabAtkins> argyle: First, doesn't require a color list<br>
&lt;TabAtkins> argyle: Lot of presenting to devs and using it myself, i often dont' care about the final color<br>
&lt;TabAtkins> argyle: It'll find the first color that passes for you, in the same hue, in whatever contrast algo you're using<br>
&lt;TabAtkins> argyle: Further my proposal builds in the contrast MQ pref<br>
&lt;TabAtkins> argyle: So if the user prefers more contrast and the page is rendered without a color list, or an explicit contrast pref in the function, the browser will take the user's preference by default.<br>
&lt;TabAtkins> argyle: This potentially eliminates several MQs for authors to have to worry about<br>
&lt;TabAtkins> argyle: If an author *does* write a specific target score - "Weber 2" or whatever - they're actually potentially excluding users.<br>
&lt;TabAtkins> argyle: So if someone does want to handhold the contrast today, they have to write several MQs to set things correctly in several circumstances. My proposal folds it all in by default.<br>
&lt;TabAtkins> argyle: Color list is still important, if you *do* want it, but you don't need it a lot of the time.<br>
&lt;TabAtkins> argyle: As said earlier, it defaults to "background". You can click it to foreground and see it change the syntax to include the keyword.<br>
&lt;TabAtkins> argyle: In most caess I've done I'm starting from a background, it's just the most common.<br>
&lt;TabAtkins> argyle: Also have a "max" contrast target<br>
&lt;astearns> "color: contrast-color(#eee / max);"<br>
&lt;TabAtkins> argyle: If I just pass a starting color it'll get the max-contrast color (white or black)<br>
&lt;lea> q?<br>
&lt;TabAtkins> argyle: There's also options matching the contrast MQ - "more" or "less"<br>
&lt;TabAtkins> argyle: Without having to specify exactly a contrast algo.<br>
&lt;TabAtkins> argyle: The contrast algo is auto by default, i know that's controversial<br>
&lt;argyle> https://codepen.io/argyleink/pen/RwgzJXV<br>
&lt;TabAtkins> argyle: Here's a demo<br>
&lt;TabAtkins> argyle: I'm writing a codepen with light/dark and low/medium/high contrast<br>
&lt;TabAtkins> argyle: You should be immediately overwhelmed<br>
&lt;TabAtkins> argyle: Just a lot to write<br>
&lt;argyle> https://codepen.io/argyleink/pen/eYKmMmN<br>
&lt;TabAtkins> argyle: This demo is what I've seen people instead already do<br>
&lt;TabAtkins> argyle: Hand-managing oklch deltas in each MQ. Slightly automated, better than WCAG 2 but not perfect. But it works today and gets light/dark and low/medium/high contrasts<br>
&lt;TabAtkins> argyle: My proposal today would make both of those demos a one-liner.<br>
&lt;TabAtkins> argyle: Looks at user pref and auto-discovers what colors they should get<br>
&lt;argyle> contrast-color(Canvas)<br>
&lt;TabAtkins> argyle: This one-liner gives you light/dark and low/med/high contrast<br>
&lt;lea> q+<br>
&lt;TabAtkins> argyle: Current proposal requires authors to write a longer function, and repeat it several times.<br>
&lt;TabAtkins> argyle: so "auto" as the algo complements the author's desire for not having to make a choice. browser can just do what's bet.<br>
&lt;TabAtkins> argyle: If there's no auto target there's no way to give up choice<br>
&lt;TabAtkins> argyle: So to summarize, my proposal doesn't require a color list, defaults to background, offers less/more/max contrast keywords, has an auto contrast keyword<br>
&lt;TabAtkins> argyle: It starts simple, *can* do everything currently in the spec, but doesn't require all the complexity immediately.<br>
&lt;Rossen_> ack lea<br>
&lt;TabAtkins> lea: We all like sensible defaults, but there were several issues with default algorithm that were discussed ad nauseum<br>
&lt;TabAtkins> lea: WCAG 2.0, the current default, is just bad. There are better algos, but there are patent/licensing issues<br>
&lt;TabAtkins> lea: In our experiments in Color.js the other contrast algos listed in the proposal don't actually give good results either<br>
&lt;TabAtkins> lea: So I don't think they're needed<br>
&lt;TabAtkins> lea: I like the idea of integrating this with the preferred contrast MQ<br>
&lt;TabAtkins> lea: Unclear what it does exactly - same keywords, or does the MQ value actually affect the function?<br>
&lt;TabAtkins> lea: minor comment - i find the identifiers side-by-side kinda hard to read, like "abca max"<br>
&lt;TabAtkins> lea: Nothing making it clear that they're tied together - current syntax makes the algos functions so you're sure the args are realted<br>
&lt;TabAtkins> lea: Also not sure what "more"/"less" correspond to mechanically<br>
&lt;TabAtkins> lea: I do like the idea of having background be the default<br>
&lt;TabAtkins> lea: Not sure we need "backgroudn" keyword at all then<br>
&lt;TabAtkins> argyle: yeah, wcag2 is bad, apca3 is still not producing good results yet, still a few years out<br>
&lt;TabAtkins> argyle: If we wait for optimal it'll never ship<br>
&lt;TabAtkins> argyle: I think auto sets it up to grow and for users, if they have a pref, they can specify it<br>
&lt;TabAtkins> argyle: I think most people won't even look past wcag2 being bad<br>
&lt;lea> q+ to say several members were skeptical about having an auto algorithm that could change. Worries we'll be stuck with it forever because authors will depend on the results not changing<br>
&lt;TabAtkins> argyle: so it's hard for us<br>
&lt;TabAtkins> argyle: Say apca comes out and is stable, firefox flips to taht, it woudl b eneat to see it upgrade over time<br>
&lt;TabAtkins> argyle: I just don't like baking in a bad choice<br>
&lt;TabAtkins> argyle: I also agree nobody really knows about the other algos, yeah<br>
&lt;TabAtkins> argyle: So MQ syntax, what is more/less? I had to invent this in my demo - what is more/less in each algo?<br>
&lt;TabAtkins> argyle: I have a table in my proposal mapping them to particular values in each algo.<br>
&lt;lea> Btw our experiments with these other algos (for black/white only): https://colorjs.io/apps/blackwhite/<br>
&lt;TabAtkins> argyle: we'll have to figure this out anyway, for the MQ<br>
&lt;TabAtkins> +1 to the simple keywords that correspond to *some* reasonable values for the algos, I really like that<br>
&lt;argyle> contrast-color(#eee / max apca)<br>
&lt;TabAtkins> argyle: You commented that this looks a little weird<br>
&lt;TabAtkins> argyle: I think this reads really nice personally<br>
&lt;TabAtkins> argyle: I want max contrast from apca<br>
&lt;lea> q+ just remembered, there's also the issue of allowing multiple algos (e.g. a good one + wcag for legal requirements), this syntax cannot grow to accommodate that since params and algos are on the same level<br>
&lt;TabAtkins> argyle: If you do change the algo to something else, you're saying "here's my bg color, here's the target score"<br>
&lt;TabAtkins> argyle: --and hopefully you alway suse auto, anything else can exclude users with particular prefs--<br>
&lt;Rossen_> q?<br>
&lt;lea> I also like "more" or "less"<br>
&lt;TabAtkins> lea: I wrote in IRC what i was gonna say<br>
&lt;TabAtkins> lea: In prev discussions several WG members wer eskeptical about an auto algorithm that can change<br>
&lt;TabAtkins> lea: We'll freeze in practice anyway<br>
&lt;TabAtkins> lea: The other issue is that we might want to allow multiple algos that all need to pass - specify a "good" algo but also a "legally required" algo. Current syntax doesn't accommodate this, since the algo specifiers are on the same level as the algo name itself<br>
&lt;argyle> contrast-color(#eee / 60 lstar)<br>
&lt;TabAtkins> lea: I do like the more/less keywords fwiw<br>
&lt;lea> q?<br>
&lt;TabAtkins> argyle: You're right, I can't do multiple algos right now - "60 lstar, and 4 wcag"<br>
&lt;Rossen_> ack lea<br>
&lt;Zakim> lea, you wanted to say several members were skeptical about having an auto algorithm that could change. Worries we'll be stuck with it forever because authors will depend on the<br>
&lt;Zakim> ... results not changing<br>
&lt;lea> contrast-color(#eee / 60 lstar 5.4 wcag2) makes no sense<br>
&lt;TabAtkins> fantasai: I think this exploration was v helpful<br>
&lt;TabAtkins> fantasai: I do think there are problems with the proposal<br>
&lt;lea> +1 to this exploration being v helpful!<br>
&lt;TabAtkins> fantasai: Really do need to keep the target amount a functional argument<br>
&lt;TabAtkins> fantasai: Both good for reading and for parsing<br>
&lt;TabAtkins> fantasai: functional notation lets us extend the new algos with whatever we need without ambiguity<br>
&lt;argyle> functional notation is an easy change<br>
&lt;TabAtkins> fantasai: i have concerns about auto picking colors to minimum acceptable contrast<br>
&lt;lea> (note that functional notation can also have an argument-less syntax, where we omit the ())<br>
&lt;TabAtkins> fantasai: "pick the right contrast" is usually not the minimum acceptable<br>
&lt;TabAtkins> (we can also have some simple args to the "default" algo not require mentioning the algo)<br>
&lt;TabAtkins> [whoops, missed]<br>
&lt;TabAtkins> fantasai: if we do color ranges, should probably have ability to do ranges of any color, not just the bg hue<br>
&lt;TabAtkins> fantasai: maybe default it to the bg hue<br>
&lt;TabAtkins> fantasai: BAck to syntax, you're having a color, then a slash, then a list of colors<br>
&lt;TabAtkins> fantasai: some disagreement in earlier proposals about where the algo goes, i find your syntax choice interesting and think it reads nicely<br>
&lt;TabAtkins> fantasai: wrt fg/bg i'm pretty strongly against allowing one of them to be defaulted. i do think that needs to be an explicit choice<br>
&lt;fantasai> https://github.com/w3c/csswg-drafts/issues/7937#issuecomment-1431751840<br>
&lt;TabAtkins> fantasai: but I think we can do that without being too wordy if we put it into the function name - contrast-foreground() and contrast-background()<br>
&lt;TabAtkins> fantasai: And I think we need to tackle these problems individually<br>
&lt;TabAtkins> fantasai: auto algo? No, we already resolved that.<br>
&lt;lea> unclear if contrast-foreground(red) is declaring that red is the foreground or asking for a foreground color where red is the background<br>
&lt;TabAtkins> fantasai: function algos? etc. we can address those one by one.<br>
&lt;argyle> thx y'all, sorry that def wasnt 5m<br>
&lt;TabAtkins> Yeah I think that's confusing too<br>
&lt;lea> argyle: nothing syntax related ever is 5m :)<br>
&lt;TabAtkins> (re: Lea's comment)<br>
&lt;TabAtkins> Rossen_: We'll continue discussing in issue.<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/7937#issuecomment-1431788247 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 15 February 2023 18:03:04 UTC