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

Function getCSSFilterValue

src/generators/css-filter.ts:116–140  ·  view source on GitHub ↗
(config: Theme)

Source from the content-addressed store, hash-verified

114}
115
116export function getCSSFilterValue(config: Theme): string | null {
117 const filters: string[] = [];
118
119 if (config.mode === FilterMode.dark) {
120 filters.push('invert(100%) hue-rotate(180deg)');
121 }
122 if (config.brightness !== 100) {
123 filters.push(`brightness(${config.brightness}%)`);
124 }
125 if (config.contrast !== 100) {
126 filters.push(`contrast(${config.contrast}%)`);
127 }
128 if (config.grayscale !== 0) {
129 filters.push(`grayscale(${config.grayscale}%)`);
130 }
131 if (config.sepia !== 0) {
132 filters.push(`sepia(${config.sepia}%)`);
133 }
134
135 if (filters.length === 0) {
136 return null;
137 }
138
139 return filters.join(' ');
140}
141
142function createLeadingRule(filterRoot: string, filterValue: string): string {
143 return [

Callers 2

setInversionStyleValueFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected