| 2 | |
| 3 | |
| 4 | function setTheme(theme) { |
| 5 | const chosenTheme = "./themes/" + theme + ".css"; |
| 6 | document.getElementById("switcher-id").href = chosenTheme; |
| 7 | |
| 8 | localStorage.setItem("style", theme); |
| 9 | if (theme === "default") { |
| 10 | document.documentElement.setAttribute("data-theme", "default"); |
| 11 | } else if (theme === "nature") { |
| 12 | document.documentElement.setAttribute("data-theme", "nature"); |
| 13 | } else if (theme === "metalic") { |
| 14 | document.documentElement.setAttribute("data-theme", "metalic"); |
| 15 | } else if (theme === "matrix") { |
| 16 | document.documentElement.setAttribute("data-theme", "matrix"); |
| 17 | } else if (theme === "sky") { |
| 18 | document.documentElement.setAttribute("data-theme", "sky"); |
| 19 | } else if (theme === "dracula") { |
| 20 | document.documentElement.setAttribute("data-theme", "dracula"); |
| 21 | } else if (theme === "vibrant") { |
| 22 | document.documentElement.setAttribute("data-theme", "vibrant"); |
| 23 | } else if (theme === "galaxy") { |
| 24 | document.documentElement.setAttribute("data-theme", "galaxy"); |
| 25 | } |
| 26 | localStorage.setItem("style", theme); |
| 27 | } |
| 28 | |
| 29 | export { |
| 30 | //function exported |