(folder, hex)
| 1218 | } |
| 1219 | |
| 1220 | function applyFolderColorToOption(folder, hex) { |
| 1221 | // accepts folder like "root" or "A/B" |
| 1222 | const sel = folder === 'root' |
| 1223 | ? '#rootRow .folder-option' |
| 1224 | : `.folder-option[data-folder="${CSS.escape(folder)}"]`; |
| 1225 | const el = document.querySelector(sel); |
| 1226 | if (!el) return; |
| 1227 | |
| 1228 | if (!hex) { |
| 1229 | el.style.removeProperty('--filr-folder-front'); |
| 1230 | el.style.removeProperty('--filr-folder-back'); |
| 1231 | el.style.removeProperty('--filr-folder-stroke'); |
| 1232 | return; |
| 1233 | } |
| 1234 | |
| 1235 | const front = hex; // main |
| 1236 | const back = lighten(hex, 14); // body (slightly lighter) |
| 1237 | const stroke = darken(hex, 22); // outline |
| 1238 | |
| 1239 | el.style.setProperty('--filr-folder-front', front); |
| 1240 | el.style.setProperty('--filr-folder-back', back); |
| 1241 | el.style.setProperty('--filr-folder-stroke', stroke); |
| 1242 | } |
| 1243 | |
| 1244 | function applyAllFolderColors(scope = document) { |
| 1245 | Object.entries(window.folderColorMap || {}).forEach(([folder, hex]) => { |
no test coverage detected