mirror of
				https://github.com/Wonderfall/hugo-WonderMod.git
				synced 2025-10-30 19:35:26 +01:00 
			
		
		
		
	refactor theme.js
This commit is contained in:
		| @@ -1,8 +1,11 @@ | |||||||
| // for now this is assuming default theme is set to dark |  | ||||||
| // will probably refactor in the future for much better handling |  | ||||||
| function loadPreferredTheme() { | function loadPreferredTheme() { | ||||||
|     if (localStorage.getItem("pref-theme") === "light") { |     const preferredTheme = localStorage.getItem("pref-theme"); | ||||||
|  |     const isDarkTheme = document.body.classList.contains("dark"); | ||||||
|  |  | ||||||
|  |     if (preferredTheme === "light" && isDarkTheme) { | ||||||
|         document.body.classList.remove('dark') |         document.body.classList.remove('dark') | ||||||
|  |     } else if (preferredTheme === "dark" && !isDarkTheme) { | ||||||
|  |         document.body.classList.add('dark') | ||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Wonderfall
					Wonderfall