|
11 | 11 | return;
|
12 | 12 | }
|
13 | 13 |
|
14 |
| - // accent colors |
15 |
| - const accents = ['rosewater','flamingo','pink','maroon','red','peach','yellow','green','teal','sapphire','blue','sky','mauve','lavender','white']; |
| 14 | + // Accent colors |
| 15 | + const accents = ['none', 'rosewater', 'flamingo', 'pink', 'maroon', 'red', 'peach', 'yellow', 'green', 'teal', 'sapphire', 'blue', 'sky', 'mauve', 'lavender']; |
16 | 16 |
|
17 | 17 | // Create our own section matching spotifys style and structure
|
18 | 18 | const Section = Spicetify.React.memo(() => {
|
19 |
| - const initialValue = localStorage.getItem('catppuccin-accentColor') ?? 'rosewater'; |
| 19 | + const colorScheme = Spicetify.Config.color_scheme || "frappe"; |
| 20 | + const initialValue = localStorage.getItem('catppuccin-accentColor') ?? 'none'; |
20 | 21 | const [selectedValue, setSelectedValue] = Spicetify.React.useState(initialValue);
|
21 | 22 |
|
22 | 23 | Spicetify.React.useEffect(() => {
|
| 24 | + const accent = selectedValue === "none" ? "text" : selectedValue; |
| 25 | + const properties = { |
| 26 | + "--spice-text": `var(--spice-${selectedValue})`, |
| 27 | + "--spice-button-active": `var(--spice-${selectedValue})`, |
| 28 | + "--spice-equalizer": document.querySelector("body > script.marketplaceScript") ? `url('https://github.com/catppuccin/spicetify/blob/main/catppuccin/assets/${colorScheme}/equalizer-animated-${accent}.gif?raw=true')` : `url('${colorScheme}/equalizer-animated-${accent}.gif')` |
| 29 | + }; |
| 30 | + |
| 31 | + Object.entries(properties).forEach(([property, value]) => { |
| 32 | + if (value.includes("none")) { |
| 33 | + document.documentElement.style.removeProperty(property); |
| 34 | + } else { |
| 35 | + document.documentElement.style.setProperty(property, value); |
| 36 | + } |
| 37 | + }); |
| 38 | + |
23 | 39 | if (initialValue !== selectedValue) {
|
24 | 40 | localStorage.setItem("catppuccin-accentColor", selectedValue);
|
25 | 41 | }
|
26 |
| - |
27 |
| - const url = document.querySelector("body > script.marketplaceScript") ? `url('https://github.com/catppuccin/spicetify/blob/main/catppuccin/assets/${Spicetify.Config.color_scheme}/equalizer-animated-${selectedValue}.gif?raw=true')` : `url('${Spicetify.Config.color_scheme}/equalizer-animated-${selectedValue}.gif')` |
28 |
| - document.documentElement.style.setProperty("--spice-text", `var(--spice-${selectedValue})`); |
29 |
| - document.documentElement.style.setProperty("--spice-button-active", `var(--spice-${selectedValue})`), |
30 |
| - document.documentElement.style.setProperty("--spice-equalizer", url); |
31 | 42 | }, [selectedValue]);
|
32 | 43 |
|
33 | 44 | return Spicetify.React.createElement(
|
|
82 | 93 | {
|
83 | 94 | key: option,
|
84 | 95 | value: option,
|
85 |
| - selected: selectedValue, |
| 96 | + selected: option === selectedValue, |
86 | 97 | },
|
87 | 98 | option
|
88 | 99 | );
|
|
0 commit comments