Download src/components/layout/BodyClass.tsx from HonzaH/Letschat: direct link, hf CLI and curl.
- Browser
- Download file 582 Bytes
-
https://huggingface.co/spaces/HonzaH/Letschat/resolve/main/src/components/layout/BodyClass.tsx
- Command line
-
hf download hf://spaces/HonzaH/Letschat/src/components/layout/BodyClass.tsx
-
curl -L -o BodyClass.tsx https://huggingface.co/spaces/HonzaH/Letschat/resolve/main/src/components/layout/BodyClass.tsx
582 Bytes
| 'use client' | |
| import { useEffect } from 'react' | |
| import { usePathname } from 'next/navigation' | |
| /** | |
| * Toggles global body classes based on the current route to mirror | |
| * the static design (homepage uses the background image). | |
| */ | |
| export function BodyClass() { | |
| const pathname = usePathname() | |
| useEffect(() => { | |
| const isHome = pathname === '/' | |
| if (isHome) { | |
| document.body.classList.add('image') | |
| } else { | |
| document.body.classList.remove('image') | |
| } | |
| return () => { | |
| document.body.classList.remove('image') | |
| } | |
| }, [pathname]) | |
| return null | |
| } | |