(theme: Theme, bg?: RGBA)
| 93 | export type SyntaxStyleOverrides = Record<string, { italic?: boolean }> |
| 94 | |
| 95 | export function selectedForeground(theme: Theme, bg?: RGBA): RGBA { |
| 96 | // If theme explicitly defines selectedListItemText, use it |
| 97 | if (theme._hasSelectedListItemText) { |
| 98 | return theme.selectedListItemText |
| 99 | } |
| 100 | |
| 101 | // For transparent backgrounds, calculate contrast based on the actual bg (or fallback to primary) |
| 102 | if (theme.background.a === 0) { |
| 103 | const targetColor = bg ?? theme.primary |
| 104 | const { r, g, b } = targetColor |
| 105 | const luminance = 0.299 * r + 0.587 * g + 0.114 * b |
| 106 | return luminance > 0.5 ? RGBA.fromInts(0, 0, 0) : RGBA.fromInts(255, 255, 255) |
| 107 | } |
| 108 | |
| 109 | // Fall back to background color |
| 110 | return theme.background |
| 111 | } |
| 112 | |
| 113 | type HexColor = `#${string}` |
| 114 | type RefName = string |
no outgoing calls
no test coverage detected