(enh) improve default theme accessibility#3402
Conversation
e0c83ca to
ef08f0b
Compare
ef08f0b to
6865cb7
Compare
allejo
left a comment
There was a problem hiding this comment.
Because I dealt with this in highlight.php, just some nitpicks if we want this tool to be robust enough to scan all of our themes.
| function contrast_report(rules) { | ||
| console.log("Accessibility Report".yellow); | ||
|
|
||
| var hljs = rules.find (x => x.selectors && x.selectors.includes(".hljs")); |
There was a problem hiding this comment.
| var hljs = rules.find (x => x.selectors && x.selectors.includes(".hljs")); | |
| var hljs = rules.find(x => x.selectors?.includes(".hljs")); |
nitpick
There was a problem hiding this comment.
As you point out this isn't supported everywhere so I'm going to slow down with it until we figure our how/where to specify that dev work requires newer versions...
| this.bg = rule.declarations.find(x => x.property =="background")?.value; | ||
| this.fg = rule.declarations.find(x => x.property =="color")?.value; |
There was a problem hiding this comment.
Two notes on this one:
-
Some styles use
background-colorto differentiate the background for specific elements. I think we should add support for checkingbackground-colorfor WCAG contrast.
highlight.js/src/styles/foundation.css
Lines 74 to 77 in 0bf3ade
-
Should we have a minimum Node defined somewhere for dev environments? Optional chaining was added in Node 14 and our
package.jsonrequires Node 12+ (correctly so, for our users).
There was a problem hiding this comment.
Should we have a minimum Node defined somewhere for dev environments?
Ah, we probably should, but where... damn old versions of Node. :-)
Some styles use background-color
I'll break this out into a separate issue... the tool doesn't have to be perfect for the main thrust of this to be mergeable.
| contrastRatio() { | ||
| if (!this.foreground) return "unknown (no fg)" | ||
| if (!this.background) return "unknown(no bg)" | ||
| return round2(wcagContrast.hex(this.foreground, this.background)); |
There was a problem hiding this comment.
We have some themes that use rgba(), will .hex() work on those values?
highlight.js/src/styles/arduino-light.css
Lines 52 to 54 in 0bf3ade
Co-authored-by: Vladimir Jimenez <allejo@me.com>
Co-authored-by: Vladimir Jimenez <allejo@me.com>
Resolves #3393.
Changes
Dark Theme
Light Theme
Checklist
CHANGES.md