( c: keyof Theme | Color | undefined, theme: ThemeName, type: ColorType = 'foreground', )
| 7 | * values before delegating to the ink renderer's colorize. |
| 8 | */ |
| 9 | export function color( |
| 10 | c: keyof Theme | Color | undefined, |
| 11 | theme: ThemeName, |
| 12 | type: ColorType = 'foreground', |
| 13 | ): (text: string) => string { |
| 14 | return text => { |
| 15 | if (!c) { |
| 16 | return text |
| 17 | } |
| 18 | // Raw color values bypass theme lookup |
| 19 | if ( |
| 20 | c.startsWith('rgb(') || |
| 21 | c.startsWith('#') || |
| 22 | c.startsWith('ansi256(') || |
| 23 | c.startsWith('ansi:') |
| 24 | ) { |
| 25 | return colorize(text, c, type) |
| 26 | } |
| 27 | // Theme key lookup |
| 28 | return colorize(text, getTheme(theme)[c as keyof Theme], type) |
| 29 | } |
| 30 | } |
| 31 |
no test coverage detected