mirror of
https://github.com/AnimeThemes/animethemes-web.git
synced 2026-07-11 01:24:31 +02:00
b195c9d667
* Added bracket chart. * Added border radius to all sides of cards. * Added skeletons to home page. * Added support for system color theme. * Added code-splitting for GraphQL. * Added config constants. * Added warning banner on staging. * Added URL caching to API resolver (only for non-page request for now). * Made featured theme load by default. * Changed static path fetching to only fetch paths if not on staging (except for bracket pages). * Changed default color theme to system. * Moved color theme toggle from navigation to profile page. * Replaced sketchy local storage implementation with external package. * Fixed wrong fallback for featured theme on devices which don't support our codecs. * Fixed wrong links in footer. * Fixed code-splitting of Prism package. * Fixed "/" character not working in search input. * Fixed glitching multi cover image on playlist page. * Updated README.md.
17 lines
449 B
JavaScript
17 lines
449 B
JavaScript
import { useEffect } from "react";
|
|
import useLocalStorageState from "use-local-storage-state";
|
|
|
|
export default function useColorTheme() {
|
|
const [ theme, setTheme ] = useLocalStorageState("theme", { ssr: true }, "system");
|
|
|
|
useEffect(() => {
|
|
setTheme(document.body.getAttribute("theme"));
|
|
}, [setTheme]);
|
|
|
|
useEffect(() => {
|
|
document.body.setAttribute("theme", theme);
|
|
}, [theme]);
|
|
|
|
return [theme, setTheme];
|
|
}
|