Files
supabase/apps/www/lib/theme.utils.ts
T
Francesco Sansalvadore e76aa11508 homepage cleanup (#29295)
* new homepage logos marquee

* add products claim

* logos spacing

* dashboard table editor demo

* dashboard table editor demo

* dashboard recordings

* rls policies

* update hp frameworks

* add dataAPIs to homepage bento

* tweet section update

* padding

* hp products update

* new customer stories hp section

* height

* finish homepage details

* update logos

* fix database visual

* improve functions visual ux

* animate data-apis visual

* realtime visual update

* reduce-motion and update chatbase logo

* lighter heading paragraph

* improve video tabs components

* add priority to offsetted images

* video plays inline

* fix mobile tweets spacing

* smoll

* load video slightly before the component enters the viewport

* fix product pointer-events

* theme based and light weight dashboard video

* testimonials margin

* remove yellow tint from light mode recordings

* fix vitest window-matchMedia error

* fix vitest window-matchMedia error

* fix url type

* remove tweet
2024-09-17 11:07:38 +02:00

45 lines
1.4 KiB
TypeScript

import { useEffect } from 'react'
import { useTheme } from 'next-themes'
import { useRouter } from 'next/router'
import useDarkLaunchWeeks from '../hooks/useDarkLaunchWeeks'
export function useForceDeepDark() {
const router = useRouter()
const { resolvedTheme, theme } = useTheme()
const isDarkTheme = resolvedTheme?.includes('dark')
const forceDarkMode = useDarkLaunchWeeks()
useEffect(() => {
const handleDocumentLoad = () => {
// Update the HTML element attributes
const theme = forceDarkMode || isDarkTheme ? 'dark' : 'light'
document.documentElement.setAttribute('data-theme', theme)
document.documentElement.style.colorScheme = theme
// wait before setting the theme
setTimeout(() => {
document.documentElement.setAttribute('data-theme', theme)
document.documentElement.style.colorScheme = theme
}, 200)
// Clean up the event listener
window.removeEventListener('load', handleDocumentLoad)
}
// Check if document is already loaded
if (document.readyState === 'complete') {
handleDocumentLoad()
} else {
// Add a global load event listener
window.addEventListener('load', handleDocumentLoad)
}
// Clean up the event listener on component unmount
return () => {
window.removeEventListener('load', handleDocumentLoad)
}
}, [resolvedTheme, theme, isDarkTheme, router])
}