Revert "fix: readable pill text via WCAG contrast, not a luminance threshold"

This reverts commit 595d12f81b.
This commit is contained in:
Claude
2026-06-18 23:06:47 +00:00
parent 595d12f81b
commit ca11b0a37b
@@ -246,7 +246,7 @@ private fun CategoryPill(
Surface(
modifier = modifier,
color = color,
contentColor = readableOn(color),
contentColor = if (color.luminance() > 0.55f) Color.Black else Color.White,
shape = RoundedCornerShape(50),
shadowElevation = 3.dp,
) {
@@ -259,19 +259,6 @@ private fun CategoryPill(
}
}
/**
* Picks black or white — whichever has the higher WCAG contrast ratio against
* [background]. A plain luminance threshold mis-handles mid-tone colors (e.g.
* turquoise/gray), leaving white text barely legible; the contrast ratio does
* not.
*/
private fun readableOn(background: Color): Color {
val l = background.luminance()
val contrastWithBlack = (l + 0.05f) / 0.05f
val contrastWithWhite = 1.05f / (l + 0.05f)
return if (contrastWithBlack >= contrastWithWhite) Color.Black else Color.White
}
/**
* Best available coordinate for the card map: the event's explicit `lat`/`lon`
* tags when present, otherwise the center of the finest published geohash.