* Resolves a color value that may be a theme key to a raw Color.
(color: keyof Theme | Color | undefined, theme: Theme)
| 40 | * Resolves a color value that may be a theme key to a raw Color. |
| 41 | */ |
| 42 | function resolveColor(color: keyof Theme | Color | undefined, theme: Theme): Color | undefined { |
| 43 | if (!color) return undefined; |
| 44 | // Check if it's a raw color (starts with rgb(, #, ansi256(, or ansi:) |
| 45 | if (color.startsWith('rgb(') || color.startsWith('#') || color.startsWith('ansi256(') || color.startsWith('ansi:')) { |
| 46 | return color as Color; |
| 47 | } |
| 48 | // It's a theme key - resolve it |
| 49 | return theme[color as keyof Theme] as Color; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Theme-aware Box component that resolves theme color keys to raw colors. |