Skip to content
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 live examples: color contrast improvements #2848

Merged
merged 4 commits into from
Oct 11, 2024

Conversation

ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Oct 9, 2024

Description

For the demonstration elements with background-color: set and text content, also set explicit foreground color.

Motivation

Prevents contrast issues (unreadable text inside the element), with the dark skin.

Additional details

I noticed at https://developer.mozilla.org/en-US/docs/Web/CSS/inset-block-start#try_it that, with the dark site palette enabled, the yellow absolutely-positioned element appeared to contain no text — because it was rendered in white over yellow, due to the element's background-color being set while leaving the default text color.

I'd be pretty surprised if this is the only instance of color clashes due to incomplete styles, across the examples — it'd probably make sense to tackle them all at once, or at least as many as possible. So, feel free to consider this a WIP / starting-point PR. I'm willing to scan (ar at least grep) through the rest of the demo CSS files to look for more styles that need to be fixed in a similar manner, if it'd be a useful project to undertake.

@ferdnyc ferdnyc requested a review from a team as a code owner October 9, 2024 10:36
@ferdnyc ferdnyc requested review from chrisdavidmills and removed request for a team October 9, 2024 10:36
Copy link

github-actions bot commented Oct 9, 2024

It looks like this is your first pull request. 🎉 Thank you for your contribution! One of the project maintainers will triage and assign the pull request for review. We appreciate your patience. To safeguard the health of the project, please take a moment to read our code of conduct.

Copy link
Contributor

@chrisdavidmills chrisdavidmills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ferdnyc, and thanks for your contribution to MDN — this is really useful!

I have approved it and could merge, but I'm holding off for now in case you want to add more fixes to this PR. Let me know if you want me to go ahead and merge it.

For the demonstration elements with
background-color: yellow, also set explicit
foreground color. Prevents white-on-yellow
text, with the dark skin.
For demonstration elements with background-color: set and text content,
also set explicit foreground color.
@ferdnyc
Copy link
Contributor Author

ferdnyc commented Oct 11, 2024

Thanks @chrisdavidmills — so far I've found three more inset-{block-inline}-* examples with the same color scheme (which I fixed by adding to the same commit; sorry for rewriting history, but it's a very small change and seemed cleaner), and one more at:

https://developer.mozilla.org/en-US/docs/Web/CSS/content-visibility

Also fixed (in a separate commit). I'll keep looking through the examples for more.

@ferdnyc ferdnyc changed the title css logical inset-block-start: Set fg & bg color css examples: Set both fg & bg color Oct 11, 2024
The default filter in the example is a drop-shadow, which will be
invisible in dark mode against the default black background. Add an
`.example-container` div with background-color set to `#fff`, so
that the effect is visible regardless of the selected theme.
@ferdnyc
Copy link
Contributor Author

ferdnyc commented Oct 11, 2024

And https://developer.mozilla.org/en-US/docs/Web/CSS/filter#try_it needed a container element added to make the background white, so that the default drop-shadow filter is visible in dark mode.

@chrisdavidmills chrisdavidmills changed the title css examples: Set both fg & bg color CSS live examples: color contrast improvements Oct 11, 2024
@chrisdavidmills
Copy link
Contributor

Nice work @ferdnyc; these make perfect sense.

Tell you what, I'm going to merge this now; I think it'd be good for you to open new PRs for any more that you find. Maybe do them in blocks of about 8-10 per PR, so that improvements are published quickly and each one is nicely manageable?

Thanks again for the super-helpful contribution.

@chrisdavidmills chrisdavidmills merged commit 728624a into mdn:main Oct 11, 2024
5 checks passed
Copy link

Congratulations on your first merged pull request. 🎉 Thank you for your contribution! Did you know we have a project board with high-impact contribution opportunities? We look forward to your next contribution.

@ferdnyc ferdnyc deleted the patch-1 branch October 11, 2024 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants