diff --git a/styles/gitbash/profile.ps1 b/styles/gitbash/profile.ps1 index 34e5649..aaf0502 100644 --- a/styles/gitbash/profile.ps1 +++ b/styles/gitbash/profile.ps1 @@ -13,7 +13,7 @@ $Host.UI.RawUI.WindowTitle = 'GITBASH // MINGW64' function global:prompt { $Esc = [char]27 $Green = "$Esc[38;2;0;128;0m" - $Yellow = "$Esc[38;2;166;160;0m" + $Yellow = "$Esc[38;2;155;150;29m" $Cyan = "$Esc[38;2;0;119;119m" $Magenta = "$Esc[38;2;187;0;187m" $Gray = "$Esc[38;2;56;56;56m" diff --git a/styles/gitbash/scheme.json b/styles/gitbash/scheme.json index 26aea94..10c2ffa 100644 --- a/styles/gitbash/scheme.json +++ b/styles/gitbash/scheme.json @@ -7,7 +7,7 @@ "black": "#000000", "red": "#a31515", "green": "#008000", - "yellow": "#a6a000", + "yellow": "#9b961d", "blue": "#0000bb", "purple": "#bb00bb", "cyan": "#007777", @@ -15,7 +15,7 @@ "brightBlack": "#555555", "brightRed": "#cd3131", "brightGreen": "#11a52b", - "brightYellow": "#c4a500", + "brightYellow": "#ad9000", "brightBlue": "#005ec1", "brightPurple": "#bc05bc", "brightCyan": "#00a3a3", diff --git a/styles/golden-forest/scheme.json b/styles/golden-forest/scheme.json index a685caa..9e6c045 100644 --- a/styles/golden-forest/scheme.json +++ b/styles/golden-forest/scheme.json @@ -8,7 +8,7 @@ "red": "#a85a2a", "green": "#7a8f3e", "yellow": "#d4a017", - "blue": "#4d5d3a", + "blue": "#566743", "purple": "#8b6f3a", "cyan": "#a9b87c", "white": "#e8d68a", diff --git a/styles/neon-rain/scheme.json b/styles/neon-rain/scheme.json index 97b748f..7c8f9a0 100644 --- a/styles/neon-rain/scheme.json +++ b/styles/neon-rain/scheme.json @@ -9,7 +9,7 @@ "green": "#5ee090", "yellow": "#ffd848", "blue": "#5a90d0", - "purple": "#5a4870", + "purple": "#6c6279", "cyan": "#88c0e0", "white": "#e8e8e0", "brightBlack": "#2a3548", diff --git a/styles/rain/profile.ps1 b/styles/rain/profile.ps1 index 72d9d85..acd820b 100644 --- a/styles/rain/profile.ps1 +++ b/styles/rain/profile.ps1 @@ -53,7 +53,7 @@ if (Get-Module -ListAvailable PSReadLine) { Keyword = '#9CA0CC' Member = '#C8C5DC' Default = '#C8C5DC' - Error = '#A85850' + Error = '#A26D66' Selection = "$Esc[48;2;60;64;96m" } try { diff --git a/styles/rain/scheme.json b/styles/rain/scheme.json index 5e8d50f..fa8f606 100644 --- a/styles/rain/scheme.json +++ b/styles/rain/scheme.json @@ -5,7 +5,7 @@ "cursorColor": "#9ca0cc", "selectionBackground": "#3c4060", "black": "#0f1220", - "red": "#a85850", + "red": "#a26d66", "green": "#5c8e5c", "yellow": "#a89860", "blue": "#7a8ac8", diff --git a/styles/snowday/profile.ps1 b/styles/snowday/profile.ps1 index 68c9c64..818f255 100644 --- a/styles/snowday/profile.ps1 +++ b/styles/snowday/profile.ps1 @@ -24,7 +24,7 @@ if (Get-Module -ListAvailable PSReadLine) { Operator = '#E8D4B8' Variable = '#88A8B8' Type = '#A08098' - Keyword = '#3A6890' + Keyword = '#44739B' Member = '#E8D4B8' Default = '#E8D4B8' Error = '#C46850' diff --git a/styles/snowday/scheme.json b/styles/snowday/scheme.json index f7d18d8..216d752 100644 --- a/styles/snowday/scheme.json +++ b/styles/snowday/scheme.json @@ -8,7 +8,7 @@ "red": "#c46850", "green": "#7a9078", "yellow": "#d8b878", - "blue": "#3a6890", + "blue": "#44739b", "purple": "#a08098", "cyan": "#88a8b8", "white": "#e8d4b8", diff --git a/styles/umbrella/scheme.json b/styles/umbrella/scheme.json index dd563c6..d43fea8 100644 --- a/styles/umbrella/scheme.json +++ b/styles/umbrella/scheme.json @@ -9,7 +9,7 @@ "green": "#6e8e6e", "yellow": "#c9a66b", "blue": "#7b6e5a", - "purple": "#8b3030", + "purple": "#815350", "cyan": "#a89878", "white": "#e8dcc8", "brightBlack": "#4a423a", diff --git a/tests/Scheme-Contrast.Tests.ps1 b/tests/Scheme-Contrast.Tests.ps1 new file mode 100644 index 0000000..adec830 --- /dev/null +++ b/tests/Scheme-Contrast.Tests.ps1 @@ -0,0 +1,58 @@ +# Legibility guard: every chromatic ANSI color in a bundled scheme.json must +# stay readable against that scheme's own background. Colored text below ~3:1 +# reads as muddy syntax highlighting in the prompt. WCAG 1.4.11 puts the floor +# for non-body / accent color at 3:1, which is the right bar for terminal token +# colors (they are short identifiers, not paragraphs). +# +# Scope note: black / white (and their bright variants) are deliberately NOT +# checked -- they are the achromatic ends that blend into the background by +# design (e.g. gitbash is a light theme where white text is never used). +# +# Documented exceptions live in $allow below. +# Run: Invoke-Pester -Path tests +#Requires -Modules @{ ModuleName = 'Pester'; ModuleVersion = '5.0.0' } + +Describe 'Bundled scheme color contrast' { + BeforeDiscovery { + $repoRoot = Split-Path $PSScriptRoot -Parent + $chromatic = 'red','green','yellow','blue','purple','cyan', + 'brightRed','brightGreen','brightYellow','brightBlue','brightPurple','brightCyan' + + # (theme/key) pairs intentionally allowed below the 3:1 floor. + # umbrella/red -- the theme's signature "blood red" (#b41e1e), used for + # the banner, prompt scaffolding and cursor. It sits at 2.99:1, within + # rounding of the floor; lifting it would shift the whole theme's + # identity for an imperceptible contrast gain. + $allow = @{ 'umbrella/red' = $true } + + $cases = foreach ($dir in Get-ChildItem -LiteralPath (Join-Path $repoRoot 'styles') -Directory) { + $schemePath = Join-Path $dir.FullName 'scheme.json' + if (-not (Test-Path -LiteralPath $schemePath)) { continue } + $scheme = Get-Content -LiteralPath $schemePath -Raw | ConvertFrom-Json + foreach ($key in $chromatic) { + if (-not $scheme.$key) { continue } + if ($allow.ContainsKey("$($dir.Name)/$key")) { continue } + @{ Theme = $dir.Name; Key = $key; Color = [string]$scheme.$key; Background = [string]$scheme.background } + } + } + } + + It '/ () is >=3:1 against ' -ForEach $cases { + function Get-RelativeLuminance([string]$hex) { + $h = $hex.TrimStart('#') + $chan = 0, 2, 4 | ForEach-Object { + $v = [Convert]::ToInt32($h.Substring($_, 2), 16) / 255 + if ($v -le 0.03928) { $v / 12.92 } else { [math]::Pow(($v + 0.055) / 1.055, 2.4) } + } + 0.2126 * $chan[0] + 0.7152 * $chan[1] + 0.0722 * $chan[2] + } + + $lColor = Get-RelativeLuminance $Color + $lBg = Get-RelativeLuminance $Background + $hi = [math]::Max($lColor, $lBg) + $lo = [math]::Min($lColor, $lBg) + $ratio = ($hi + 0.05) / ($lo + 0.05) + + $ratio | Should -BeGreaterThan 3.0 -Because "$Theme/$Key ($Color) must stay readable on $Background" + } +}