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

Code in exercises is "very low contrast" error in accessibility checker #76

Closed
brownsarahm opened this issue Oct 31, 2023 · 6 comments
Closed
Labels
{varnish} HTML/CSS/JS templates

Comments

@brownsarahm
Copy link

this might not be the right place, but while doing accessibility checks on an incubator lesson I noticed this.

Is there a different way lesson authors should denote code in exercise blocks? or is this an acceptable low contrast? (the exercise block background is the same color as a code block background)

linking to review issue for future reference

@tobyhodges
Copy link
Member

I can confirm that, based on https://coolors.co/contrast-checker/d63384-f8f9f9, this falls short of the 4.5:1 ratio required for the WCAG AA success criterion. The code-formatted text on pure white background meets that ratio exactly (see https://coolors.co/contrast-checker/d63384-ffffff).

Can we adjust the colour for inline code to keep a high contrast on this grey background, e.g. to #A50D5E?

@ErinBecker
Copy link
Contributor

Thanks for this issue @brownsarahm. The @carpentries/workbench-maintainers started to discuss this at our meeting today. Here's what we've tracked down so far:

Kelly and I started by inspecting the code for in-line code within an exercise block. The color for the in-line code appears to come from the _rfs.scss stylesheet (line 294).

Screenshot 2023-11-03 at 8 52 51 AM

This sylesheet appears to be imported from Bootstrap, but line 294 of this style sheet appears to be about resizing safari iframes. We have no idea how this is related to setting text color.

Screenshot 2023-11-03 at 9 27 03 AM

Varnish's styles.css.scss imports codeblocks.scss, which includes a definition of a code element starting on line 46. Line 53 sets the color property for the code element to inherit.

Screenshot 2023-11-03 at 9 03 24 AM

We found a tutorial video about css cascading that seems relevant, but haven't yet been able to track down where the code element is inheriting its color from. We are pretty confident we can override this inhertance by defining code color somewhere, but we don't know where it should be defined.

We'll be checking in with the other Workbench Maintainers next week, who know a lil' more about css (😂) and hopefully figure out where this property needs to be set. This is turning into a great learning opportunity for us to understand how the Workbench uses css.

@tobyhodges
Copy link
Member

Note that the issue is with contrast of inline code (i.e. monospaced text within a paragraph of normal text), rather than code in codeblocks. e.g. code {color: #a50d5e;} rather than

code {
    color: #a50d5e;
}

So codeblocks.scss may not be the correct location for making a change like this. Having said that, I am not sure where else to suggest! But it could be an important distinction.

@froggleston
Copy link
Contributor

Hi all. The CSS of the code block declaration in bootstrap is overridden by the syntax-highlighting.scss class in varnish. @ErinBecker is correct that inheritance is in play here, but as the syntax-highlighting.scss inherits from the bootstrap code class, but doesn't specify its own color, then it will inherit the bootstrap color. We can override this by adding a specific color property in the syntax-highlighting.scss class:
image

@froggleston
Copy link
Contributor

Many thanks for raising this @brownsarahm - @zkamvar and I went through this today, and we agreed that setting the background-color to white for the inline code should increase the contrast. I've implemented a fix and it will be in the upcoming varnish 0.3.2 release.

@zkamvar
Copy link
Contributor

zkamvar commented Nov 8, 2023

Just a note, Rob created the release 20 minutes ago and it is now live on the R universe: https://carpentries.r-universe.dev/varnish

@zkamvar zkamvar closed this as completed Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
{varnish} HTML/CSS/JS templates
Projects
None yet
Development

No branches or pull requests

5 participants