Merge pull request #78 from ok2/codex/improve-border-visibility-in-detail-view
Improve event border visibility
This commit is contained in:
commit
ff5d2a7816
16
script.js
16
script.js
@ -67,10 +67,24 @@ function getContrastColor(hex) {
|
||||
return yiq >= 128 ? '#000' : '#fff';
|
||||
}
|
||||
|
||||
function lightenColor(hex, percent) {
|
||||
if (!hex) return '#fff';
|
||||
let c = hex.replace('#','');
|
||||
if (c.length === 3) c = c.split('').map(x=>x+x).join('');
|
||||
let r = parseInt(c.substr(0,2),16);
|
||||
let g = parseInt(c.substr(2,2),16);
|
||||
let b = parseInt(c.substr(4,2),16);
|
||||
r = Math.min(255, Math.round(r + (255 - r) * percent));
|
||||
g = Math.min(255, Math.round(g + (255 - g) * percent));
|
||||
b = Math.min(255, Math.round(b + (255 - b) * percent));
|
||||
return '#' + [r,g,b].map(x=>x.toString(16).padStart(2,'0')).join('');
|
||||
}
|
||||
|
||||
function applyEventColors(elem, color, alpha) {
|
||||
if (!color || !elem) return;
|
||||
elem.style.setProperty('--bg-color', hexToRgba(color, alpha));
|
||||
elem.style.setProperty('--border-color', color);
|
||||
// Use a lighter shade for the border so it stands out even for dark colors
|
||||
elem.style.setProperty('--border-color', lightenColor(color, 0.4));
|
||||
elem.style.setProperty('--text-color', getContrastColor(color));
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user