dotfiles
bugabingas dorkfiles
owned by bugabinga
test(nugu): make contrast checks a hard gate
c13fbef1ac12af5e3db13e1f5a93d2b9f3716c57
Oliver Jan Krylow <oliver@bugabinga.net> ·
unsigned
Browse filesCompare with HEAD
Changed files (1)
44 45 const contrast_thresholds = [
45 46 { color:
"error", bg:
"content.backdrop", min:
4.5 },
46 47 { color:
"warning", bg:
"content.backdrop", min:
3.0 },
47 48 { color:
"info", bg:
"content.backdrop", min:
2.5 },
49 + { color:
"content.backdrop", bg:
"error", min:
4.5 },
50 + { color:
"content.backdrop", bg:
"warning", min:
4.5 },
51 + { color:
"content.backdrop", bg:
"info", min:
4.5 },
48 52 { color:
"debug", bg:
"content.backdrop", min:
3.0 },
49 53 { color:
"content.normal", bg:
"content.backdrop", min:
4.5 },
50 54 { color:
"content.accent", bg:
"content.backdrop", min:
4.5 },
94 98 print $
"(ansi yellow_bold)WCAG AA: ($theme_name) theme(ansi reset)" 96 - if (
$failures | length) >
0 {
100 + let failure_count = (
$failures | length)
102 + if $failure_count >
0 {
97 103 for f
in $failures {
98 104 print $
" (ansi red)✗(ansi reset) ($f.color) ($f.hex) on ($f.bg_hex) — ($f.ratio):1, need ($f.min):1" 100 - print $
" (ansi red_bold)($failures | length) warnings(ansi reset)" 106 + print $
" (ansi red_bold)($failure_count) failures(ansi reset)" 102 108 print $
" (ansi green)✓ all colors pass(ansi reset)" 107 114 export def check [] {
109 - validate-theme (new)
"dark" 110 - validate-theme (new --light)
"light" 116 + let failure_count = ([
117 + (validate-theme (new)
"dark")
118 + (validate-theme (new --light)
"light")
120 + if $failure_count >
0 {
121 + error make { msg: $
"($failure_count) Nugu contrast checks failed" }
113 125 def readable-textcolor [bg: string] {