(
input: string,
theme: Theme,
modifyFunction: (rgb: RGBA, theme: Theme, useRegisteredVarColor?: boolean) => string,
)
| 810 | } |
| 811 | |
| 812 | function handleRawColorValue( |
| 813 | input: string, |
| 814 | theme: Theme, |
| 815 | modifyFunction: (rgb: RGBA, theme: Theme, useRegisteredVarColor?: boolean) => string, |
| 816 | ) { |
| 817 | const {isRaw, color} = parseRawColorValue(input); |
| 818 | |
| 819 | const rgb = parseColorWithCache(color); |
| 820 | if (rgb) { |
| 821 | const outputColor = modifyFunction(rgb, theme, !isRaw); |
| 822 | |
| 823 | // If it's raw, we need to convert it back to the "raw" format. |
| 824 | if (isRaw) { |
| 825 | // This should technically never fail(returning an empty string), |
| 826 | // but just to be safe, we will return outputColor. |
| 827 | const outputInRGB = parseColorWithCache(outputColor); |
| 828 | return ( |
| 829 | outputInRGB ? ( |
| 830 | Number.isNaN(outputInRGB.a) || outputInRGB.a === 1 ? |
| 831 | `${outputInRGB.r}, ${outputInRGB.g}, ${outputInRGB.b}` : |
| 832 | `${outputInRGB.r}, ${outputInRGB.g}, ${outputInRGB.b}, ${outputInRGB.a}` |
| 833 | ) : |
| 834 | outputColor |
| 835 | ); |
| 836 | } |
| 837 | return outputColor; |
| 838 | } |
| 839 | return color; |
| 840 | } |
| 841 | |
| 842 | function tryModifyBgColor(color: string, theme: Theme) { |
| 843 | return handleRawColorValue(color, theme, modifyBackgroundColor); |
no test coverage detected