diff --git a/CHANGELOG.md b/CHANGELOG.md index 34310f4b..ca420843 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project are documented in this file. ## [Unreleased] +### Changed + +- Improve generated directory-index readability with adjacent-row separators, + explicit light and dark empty-state text colors, and text-only hover/focus + underlining while retaining the full interactive target's focus outline. + ### Fixed - Generate the inline-style Content Security Policy SHA-256 source expression @@ -14,8 +20,13 @@ All notable changes to this project are documented in this file. - Add a real generated-file regression test that independently recomputes the declared style hash from the emitted `""") + .find(generatedHtml()) + ?.groupValues + ?.get(1) + return requireNotNull(style) { "Generated HTML must contain one inline style block" } + } + + private fun contrastRatio(foreground: String, background: String): Double { + val foregroundLuminance = relativeLuminance(foreground) + val backgroundLuminance = relativeLuminance(background) + val lighter = maxOf(foregroundLuminance, backgroundLuminance) + val darker = minOf(foregroundLuminance, backgroundLuminance) + return (lighter + 0.05) / (darker + 0.05) + } + + private fun relativeLuminance(hexColor: String): Double { + val channels = hexColor.removePrefix("#") + .chunked(2) + .map { it.toInt(16) / 255.0 } + .map { channel -> + if (channel <= 0.04045) { + channel / 12.92 + } else { + ((channel + 0.055) / 1.055).pow(2.4) + } + } + return (0.2126 * channels[0]) + (0.7152 * channels[1]) + (0.0722 * channels[2]) + } +}