fix(mobile): tune cover palette contrast

This commit is contained in:
joshuafhiggins committed 2026-10-17 15:17:16 -04:00 Verified
1 parent df0aa7f84d
commit 4f74b3c3e0
1 file changed
+7 -8
+7 -8
View File
@@ -28,7 +28,9 @@ export type CoverSwatches = {
accent: string[]
}
const PRIMARY_MIN_CONTRAST = 7
// Best effort: `legibleBackground` only guarantees that white or black reaches
// 7:1, so on some backgrounds primary text settles for pure white or black.
const PRIMARY_MIN_CONTRAST = 10
const SECONDARY_MIN_CONTRAST = 4.5
const SECONDARY_TO_PRIMARY_CONTRAST = 0.62
const ACCENT_MIN_CONTRAST = 3
@@ -97,12 +99,9 @@ export function deriveCoverPalette(
)
const accent = pickAccent(swatches.accent, background) ?? foreground
const accentForeground =
contrastRatio(background, accent) >= SECONDARY_MIN_CONTRAST
? background
: contrastRatio([255, 255, 255], accent) >= contrastRatio([0, 0, 0], accent)
? ([255, 255, 255] as Rgb)
: ([0, 0, 0] as Rgb)
const accentForeground: Rgb = prefersLightText(accent)
? [255, 255, 255]
: [0, 0, 0]
return {
background: toHex(background),
@@ -129,7 +128,7 @@ function legibleBackground(color: Rgb, schemeIsDark: boolean): Rgb {
return clamped
}
const pivot = schemeIsDark ? 0.24 : 0.16
const pivot = schemeIsDark ? 0.28 : 0.14
return y < pivot
? withLuminance(clamped, DARK_BACKGROUND_MAX_LUMINANCE)
: withLuminance(clamped, LIGHT_BACKGROUND_MIN_LUMINANCE)