Skip to content

Commit b9ae39e

Browse files
Made the background color calculation compatible with shortened hex value
1 parent 62cb3da commit b9ae39e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

default.hbs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
https://gomakethings.com/dynamically-changing-the-text-color-based-on-background-color-contrast-with-vanilla-js/ */
2727
var accentColor = getComputedStyle(document.documentElement).getPropertyValue('--background-color');
2828
accentColor = accentColor.trim().slice(1);
29+
30+
if (accentColor.length === 3) {
31+
accentColor = accentColor[0] + accentColor[0] + accentColor[1] + accentColor[1] + accentColor[2] + accentColor[2];
32+
}
33+
2934
var r = parseInt(accentColor.substr(0, 2), 16);
3035
var g = parseInt(accentColor.substr(2, 2), 16);
3136
var b = parseInt(accentColor.substr(4, 2), 16);

0 commit comments

Comments
 (0)