|
|
@@ -102,15 +102,16 @@ type Theme = ThemeColors & {
|
|
|
thinkingOpacity: number
|
|
|
}
|
|
|
|
|
|
-export function selectedForeground(theme: Theme): RGBA {
|
|
|
+export function selectedForeground(theme: Theme, bg?: RGBA): RGBA {
|
|
|
// If theme explicitly defines selectedListItemText, use it
|
|
|
if (theme._hasSelectedListItemText) {
|
|
|
return theme.selectedListItemText
|
|
|
}
|
|
|
|
|
|
- // For transparent backgrounds, calculate contrast based on primary color
|
|
|
+ // For transparent backgrounds, calculate contrast based on the actual bg (or fallback to primary)
|
|
|
if (theme.background.a === 0) {
|
|
|
- const { r, g, b } = theme.primary
|
|
|
+ const targetColor = bg ?? theme.primary
|
|
|
+ const { r, g, b } = targetColor
|
|
|
const luminance = 0.299 * r + 0.587 * g + 0.114 * b
|
|
|
return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255)
|
|
|
}
|