* Resolves a color value that may be a theme key to a raw Color.
(color: keyof Theme | Color | undefined, theme: Theme)
| 64 | * Resolves a color value that may be a theme key to a raw Color. |
| 65 | */ |
| 66 | function resolveColor(color: keyof Theme | Color | undefined, theme: Theme): Color | undefined { |
| 67 | if (!color) return undefined; |
| 68 | // Check if it's a raw color (starts with rgb(, #, ansi256(, or ansi:) |
| 69 | if (color.startsWith('rgb(') || color.startsWith('#') || color.startsWith('ansi256(') || color.startsWith('ansi:')) { |
| 70 | return color as Color; |
| 71 | } |
| 72 | // It's a theme key - resolve it |
| 73 | return theme[color as keyof Theme] as Color; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Theme-aware Text component that resolves theme color keys to raw colors. |