MCPcopy Index your code
hub / github.com/darkreader/darkreader / getSelectionColor

Function getSelectionColor

src/inject/dynamic-theme/modify-css.ts:191–208  ·  view source on GitHub ↗
(theme: Theme)

Source from the content-addressed store, hash-verified

189}
190
191export function getSelectionColor(theme: Theme): {backgroundColorSelection: string; foregroundColorSelection: string} {
192 let backgroundColorSelection: string;
193 let foregroundColorSelection: string;
194 if (theme.selectionColor === 'auto') {
195 backgroundColorSelection = modifyBackgroundColor({r: 0, g: 96, b: 212}, {...theme, grayscale: 0});
196 foregroundColorSelection = modifyForegroundColor({r: 255, g: 255, b: 255}, {...theme, grayscale: 0});
197 } else {
198 const rgb = parseColorWithCache(theme.selectionColor)!;
199 const hsl = rgbToHSL(rgb);
200 backgroundColorSelection = theme.selectionColor;
201 if (hsl.l < 0.5) {
202 foregroundColorSelection = '#FFF';
203 } else {
204 foregroundColorSelection = '#000';
205 }
206 }
207 return {backgroundColorSelection, foregroundColorSelection};
208}
209
210function getModifiedSelectionStyle(theme: Theme) {
211 const lines: string[] = [];

Callers 2

Calls 4

modifyBackgroundColorFunction · 0.90
modifyForegroundColorFunction · 0.90
parseColorWithCacheFunction · 0.90
rgbToHSLFunction · 0.90

Tested by

no test coverage detected