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

Function getModifiedScrollbarStyle

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

Source from the content-addressed store, hash-verified

222}
223
224function getModifiedScrollbarStyle(theme: Theme) {
225 let colorTrack: string;
226 let colorThumb: string;
227 if (theme.scrollbarColor === 'auto') {
228 colorTrack = modifyBackgroundColor({r: 241, g: 241, b: 241}, theme);
229 colorThumb = modifyBackgroundColor({r: 176, g: 176, b: 176}, theme);
230 } else {
231 const rgb = parseColorWithCache(theme.scrollbarColor)!;
232 const hsl = rgbToHSL(rgb);
233 const darken = (darker: number) => ({...hsl, l: clamp(hsl.l - darker, 0, 1)});
234 colorTrack = hslToString(darken(0.4));
235 colorThumb = hslToString(hsl);
236 }
237 return [
238 `* {`,
239 ` scrollbar-color: ${colorThumb} ${colorTrack};`,
240 `}`,
241 ].join('\n');
242}
243
244export function getModifiedFallbackStyle(theme: Theme, {strict}: {strict: boolean}): string {
245 const factory = fallbackFactory || defaultFallbackFactory;

Callers 1

Calls 5

modifyBackgroundColorFunction · 0.90
parseColorWithCacheFunction · 0.90
rgbToHSLFunction · 0.90
hslToStringFunction · 0.90
darkenFunction · 0.85

Tested by

no test coverage detected