diff --git a/src/js/main.js b/src/js/main.js index 7961f87..1b20577 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -424,9 +424,9 @@ let textColor = chroma($("html").css("--spice-text")).hex(); let textColorBg = chroma($("html").css("--spice-main")).hex(); let sidebarColor = chroma($("html").css("--spice-sidebar")).hex(); -function setRootColor(name, colHex) { - $("html").css(`--spice-${name}`, colHex); - $("html").css(`--spice-rgb-${name}`, chroma(colHex).rgb().join(",")); +function setRootColor(name, color) { + $("html").css(`--spice-${name}`, chroma(color).hex()); + $("html").css(`--spice-${name}-rgb`, chroma(color).rgb().join(",")); } function toggleDark(setDark) { diff --git a/src/styles/Colors.scss b/src/styles/Colors.scss index e1460de..4c84933 100644 --- a/src/styles/Colors.scss +++ b/src/styles/Colors.scss @@ -17,17 +17,46 @@ $colors: ( misc: #bfbfbf ); +// Set initial Vars :root { @each $key, $color in $colors { --spice-#{$key}: #{$color}; - --spice-rgb-#{$key}: #{red($color)}, #{green($color)}, #{blue($color)}; + --spice-#{$key}-rgb: #{red($color)}, #{green($color)}, #{blue($color)}; } } +// Set Transitions +@each $key, $color in $colors { + @property --spice-#{$key} { + syntax: ""; + initial-value: $color; + inherits: true; + } + + @property --spice-#{$key}-rgb { + syntax: ", , "; + initial-value: #{red($color)}, #{green($color)}, #{blue($color)}; + inherits: true; + } +} + +:root { + $props: (); + + @each $key, $color in $colors { + $props: append($props, --spice-#{$key}, comma); + $props: append($props, --spice-#{$key}-rgb, comma); + } + + transition: all var(--song-transition-speed) linear; + transition-property: $props; +} + +// Color Function @function spiceColor($key, $alpha: 1) { @if $alpha == 1 { @return var(--spice-#{$key}); } @else { - @return rgba(var(--spice-rgb-#{$key}), $alpha); + @return rgba(var(--spice-#{$key}-rgb), $alpha); } } diff --git a/src/styles/main.scss b/src/styles/main.scss index 843c515..f3e8b8e 100644 --- a/src/styles/main.scss +++ b/src/styles/main.scss @@ -49,36 +49,6 @@ font-weight: 500; } -/* smooth color transitions */ -@property --spice-sidebar { - syntax: ""; - initial-value: magenta; - inherits: true; -} - -@property --spice-main { - syntax: ""; - initial-value: magenta; - inherits: true; -} - -@property --spice-text { - syntax: ""; - initial-value: magenta; - inherits: true; -} - -@property --spice-button { - syntax: ""; - initial-value: magenta; - inherits: true; -} - -:root { - transition: all var(--song-transition-speed) linear; - transition-property: --spice-sidebar, --spice-main, --spice-text, --spice-button; -} - body { --glue-font-family: "Google Sans Display", "Roboto", spotify-circular, spotify-circular-cyrillic, spotify-circular-arabic, spotify-circular-hebrew, Helvetica Neue, helvetica, arial, Hiragino Kaku Gothic Pro, Meiryo, MS Gothic, sans-serif; --info-font-family: "Roboto", spotify-circular, spotify-circular-cyrillic, spotify-circular-arabic, spotify-circular-hebrew, Helvetica Neue, helvetica, arial, Hiragino Kaku Gothic Pro, Meiryo, MS Gothic, sans-serif;