File tree Expand file tree Collapse file tree 5 files changed +12
-8
lines changed
Expand file tree Collapse file tree 5 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 88 < title > TODO: Change page title</ title >
99 < script >
1010 // This script is used to prevent flashing on page load, as it loads the apporiate theme first before loading the css
11- const theme = localStorage . getItem ( "swamphacks- ui-theme" ) || "system" ;
11+ const theme = localStorage . getItem ( "ui-theme" ) || "system" ;
1212 const root = window . document . documentElement ;
1313
1414 root . classList . remove ( "light" , "dark" ) ;
2323 } else {
2424 root . classList . add ( theme ) ;
2525 }
26+
27+ // Only apply this class only after the theme has been applied, hence the calling the onload function
28+ window . onload = ( ) => {
29+ document . body . classList . add ( "enable-theme-transition" ) ;
30+ } ;
2631 </ script >
2732 </ head >
2833 < body >
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ const ThemeProviderContext = createContext<ThemeProviderState>(initialState);
2727export function ThemeProvider ( {
2828 children,
2929 defaultTheme = "system" ,
30- storageKey = "vite- ui-theme" ,
30+ storageKey = "ui-theme" ,
3131 ...props
3232} : ThemeProviderProps ) {
3333 const [ theme , setTheme ] = useState < Theme > (
@@ -74,7 +74,7 @@ export function ThemeProvider({
7474 ) ;
7575}
7676
77- export const ThemeSwitch = ( ) => {
77+ export const DevThemeSwitch = ( ) => {
7878 const { theme, setTheme } = useTheme ( ) ;
7979
8080 return (
Original file line number Diff line number Diff line change 1818}
1919
2020/* https://stackoverflow.com/questions/68400074/how-to-apply-transition-effects-when-switching-from-light-mode-to-dark-in-tailwi */
21- body * {
21+ body . enable-theme-transition * {
2222 @apply transition-colors duration-500;
2323}
Original file line number Diff line number Diff line change 1- /* eslint-disable react-refresh/only-export-components */
21import { StrictMode } from "react" ;
32import { createRoot } from "react-dom/client" ;
43import { RouterProvider , createRouter } from "@tanstack/react-router" ;
@@ -25,7 +24,7 @@ declare module "@tanstack/react-router" {
2524
2625function App ( ) {
2726 return (
28- < ThemeProvider defaultTheme = "system" storageKey = "swamphacks-ui-theme" >
27+ < ThemeProvider defaultTheme = "system" >
2928 < QueryClientProvider client = { queryClient } >
3029 < InnerApp />
3130 </ QueryClientProvider >
Original file line number Diff line number Diff line change 1- import { ThemeSwitch } from "@/components/ThemeProvider" ;
1+ import { DevThemeSwitch } from "@/components/ThemeProvider" ;
22import type { auth } from "@/lib/authClient" ;
33import { createRootRouteWithContext , Outlet } from "@tanstack/react-router" ;
44
@@ -14,7 +14,7 @@ export const Route = createRootRouteWithContext<RouterContext>()({
1414 < Outlet />
1515 { IS_DEV && (
1616 < div className = "fixed inline-flex w-fit z-[999] bottom-3 left-3 text-white" >
17- < ThemeSwitch />
17+ < DevThemeSwitch />
1818 </ div >
1919 ) }
2020 </ >
You can’t perform that action at this time.
0 commit comments