MCPcopy Create free account
hub / github.com/darkreader/darkreader / modifyLightModeHSL

Function modifyLightModeHSL

src/inject/dynamic-theme/modify-colors.ts:116–141  ·  view source on GitHub ↗
({h, s, l, a}: HSLA, poleFg: HSLA, poleBg: HSLA)

Source from the content-addressed store, hash-verified

114}
115
116function modifyLightModeHSL({h, s, l, a}: HSLA, poleFg: HSLA, poleBg: HSLA): HSLA {
117 const isDark = l < 0.5;
118 let isNeutral: boolean;
119 if (isDark) {
120 isNeutral = l < 0.2 || s < 0.12;
121 } else {
122 const isBlue = h > 200 && h < 280;
123 isNeutral = s < 0.24 || (l > 0.8 && isBlue);
124 }
125
126 let hx = h;
127 let sx = s;
128 if (isNeutral) {
129 if (isDark) {
130 hx = poleFg.h;
131 sx = poleFg.s;
132 } else {
133 hx = poleBg.h;
134 sx = poleBg.s;
135 }
136 }
137
138 const lx = scale(l, 0, 1, poleFg.l, poleBg.l);
139
140 return {h: hx, s: sx, l: lx, a};
141}
142
143const MAX_BG_LIGHTNESS = 0.4;
144

Callers

nothing calls this directly

Calls 1

scaleFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…