-
Notifications
You must be signed in to change notification settings - Fork 682
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
[css-color-6] contrast-color()
syntax proposal
#7954
Comments
related #7937 |
related #7553 |
Some miscellaneous critique:
|
Wow, that ObservableHQ demo is sweet! 🤩 Not looking at the details/order of the syntax, I do see all the necessary parts are there. It reminds me of this syntax I suggested:
The main components are there, similar to Adam’s proposed syntax. Key difference though is that the This allows an algo to have more than 1 argument. The (unfinished) wcag3 for example also takes font weight and size into account, which could then be expressed as |
engineering made it sound like they could derive that as they needed and wouldnt require authors to pass it explicitly to fulfill the algo. hopefully authors wont have to know that much about the api surface area of a contrast algorithm to use it right. something to consider..The longer this function sits, the more that folks will use cielab to estimate L* differences for contrast. See this post here where the author suggests we don't need
All things that BUT, this L* calc() ability is about to be in hands before |
|
Hi Adam @argyleink
I just came across this thread, I am here to answer any questions that might come up or to provide assistance. As I think you are aware, user personalization is the most important thing that can be done for accessibility. If real effective user personalization can be had, then many other concerns about accessibility become very secondary or even moot. As such I've been considering some of the needs that could potentially be addressed by appropriate media queries, such as prefers contrast or theme, etc. Conflicts of NeedsOne issue is that what one user needs, another user may find harmful or interferes with their needs. Visual presentation is probably one of the more complicated and common situations where this issue is present. There are easily 10 basic themes or contrast modes, I put the supporting minutia in the spoiler. Visual Needs/Themes examplesIn an ideal world, the user's environment or at least the entire screen luminance would be taken into consideration. As well, the use-cases relating to tasks, i.e. reading long form material, or interacting with forms, have two different needs in terms of contrast and presentation. Some arguably useful luminance and contrast themes: Dark Mode for dark environments Light mode for bright environments Luminance contrasts relate to readability for all sighted users, color (hue/colorfulness) relate to distinguishability and discernibility. Reduced color (hue/chroma) contrast (without reducing luminance contrast) ReadingLuminance contrast is critical for visual readability for all sighted users. Excess brightness as in too much luminance relative to the eye's adaptation state in their environment leads to rapid eye fatigue. This is an emerging problem with people that are using HDR displays. "Too much contrast" is a complaint given for what is actually excess brightness. Reducing contrast with a bright background by making the text a lighter gray is exactly the opposite correction needed. More: "Please Stop sing Grey Text" Automated color palette development requires perceptual uniformity in whatever model is being used. Hi @bramus + @argyleink
You definitely do not need to send APCA the font size and weight. If you have one color, you then only need a target Lc value (lightness contrast) to determine the needed second color. If you don't have an Lc, Weight, and SizeIn other words, if you have one color, with font size and weight, then you can determine the second color. Or if you have one color and an However, for font size & weight to really work, we need to have a reliable way to set x-height directly, and a reliable way to determine a font's actual weight since there's no standardization here. This is something that we're working on, but it's not something that's gonna be happening anytime soon. Hi @tabatkins
I agree that automatically selecting some algorithm is fraught with a lot of unexpected behavior. A black and white font flipper could work, but you don't need much of an algorithm for that. You can pretty much convert to luminance and flip between black and white at Hi @argyleink
Unfortunately I was working with The tangent is DPS contrast a.k.a. Delta Phi Star, which uses SummaryI hope this post was useful please ping me if you have questions. Thank you for reading |
Presented and discussed in #7937 (comment) |
This proposal intends to empower the prefers-contrast media query by creating a function that implements the options of the media query, is simple to get started with, but can scale to advanced needs of authors and users. I feel, and others have provided feedback, that the current proposal is becoming unwieldy for the average developer and is lacking an automatic choice feature.
Since contrast is such a visual thing, I needed to build an interactive syntax so I could see and feel out the syntax results. I chose ObservableHQ as it allows creating transparent and inspectable logic and documentation, plus the ability to make things interactive and real time.
Interact with the syntax, read finer details about the implementation, all here:
https://observablehq.com/@argyleink/contrast-color
Demo usage of the interactive proposal:
Kapture.2022-10-25.at.13.41.50.mp4
Some notable things to observe in the proposal and video are:
contrast-color(#eee)
contrast-color(foreground #eee)
contrast-color(#eee)
contrast-color(#eee / apca)
prefers-contrast
media query keywords likemore
andless
and maps them to the algorithm's equivalent of contrast, but if left out of the function (auto
) the browser uses the users current contrast preference from the OScontrast-color(#eee / more wcag21)
same ascontrast-color(#eee / 7 wcag21)
max
as a keyword, simplifying the request forwhite
orblack
depending on which contrasts morecontrast-color(#eee / max)
The goal is to encourage usage of
auto
so users preferences are respected and remain dynamic. This means most usage of the function will be short and sweet.But, if experts want to, they can grab the reigns and really specify what they want like:
From presenting the previous syntax a few times to groups of devs, staying current with the current issues logged against this contrast function, and wanting the previous WG resolutions on contrast preference handling, this spec proposal attempts to sum as much of it up as it can, while being terse and approachable.
There's plenty of details to talk about, but this proposal feels closest to the desirable developer experience I acquired in feedback. It also aligns functionality more with existing contrast resolutions made by the CSSWG. I'd like to present the proposal and accept questions about details.
The Observable document has a section called Explanations and Reasoning that should help answer a few of the common questions:
Have fun! I feel like it's quite nice having something visual and playful to work with instead of just reading theoretical syntax over and over. You can go try it out, see results, and discover the syntax you'll want in your project.
The text was updated successfully, but these errors were encountered: