|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import { useRef } from 'react' |
| 3 | +import { useRef, useState } from 'react' |
4 | 4 | import Feed from '@/components/feed/Feed' |
5 | 5 | import Footer from '@/components/footer/Footer' |
6 | 6 | import Hero from '@/components/hero/Hero' |
7 | 7 | import Navigation from '@/components/navigation/Navigation' |
8 | 8 | import Quote from '@/components/quote/Quote' |
9 | 9 | import Users from '@/components/users/Users' |
| 10 | +import { ContextContentLoaded } from '@/context/ContextContentLoaded' |
10 | 11 | import { ContextQuote } from '@/context/ContextQuote' |
11 | 12 | import { ContextTopTenPosts } from '@/context/ContextTopTenPosts' |
12 | 13 | import { ContextTopUsers } from '@/context/ContextTopUsers' |
13 | 14 | import { useFocusTrap } from '@/hooks/useFocusTrap' |
| 15 | +import { useGotoWindowScrollY } from '@/hooks/useGotoWindowScrollY' |
14 | 16 | import { useScrollRestoration } from '@/hooks/useScrollRestoration' |
| 17 | +import { useSetWindowScrollY } from '@/hooks/useSetWindowScrollY' |
15 | 18 |
|
16 | 19 | export default function Home() { |
| 20 | + const [contentLoaded, setContentLoaded] = useState<{ |
| 21 | + posts: boolean |
| 22 | + quote: boolean |
| 23 | + users: boolean |
| 24 | + }>({ |
| 25 | + posts: false, |
| 26 | + quote: false, |
| 27 | + users: false, |
| 28 | + }) |
| 29 | + |
17 | 30 | const quoteRef = useRef<HTMLQuoteElement>(null) |
18 | 31 | const topTenPostsRef = useRef<HTMLDivElement | null>(null) |
19 | 32 | const topUsersRef = useRef<HTMLDivElement | null>(null) |
20 | 33 |
|
21 | 34 | useFocusTrap() |
| 35 | + useGotoWindowScrollY(contentLoaded) |
22 | 36 | useScrollRestoration() |
| 37 | + useSetWindowScrollY() |
23 | 38 |
|
24 | 39 | return ( |
25 | 40 | <div className="min-h-svh flex flex-col items-center justify-start bg-gradient-to-b from-stone-700 to-stone-800"> |
26 | | - <ContextQuote.Provider value={quoteRef}> |
27 | | - <ContextTopTenPosts.Provider value={topTenPostsRef}> |
28 | | - <ContextTopUsers.Provider value={topUsersRef}> |
29 | | - <Navigation /> |
30 | | - <Hero /> |
31 | | - <Users /> |
32 | | - <Quote /> |
33 | | - <Feed /> |
34 | | - <Footer /> |
35 | | - </ContextTopUsers.Provider> |
36 | | - </ContextTopTenPosts.Provider> |
37 | | - </ContextQuote.Provider> |
| 41 | + <ContextContentLoaded.Provider |
| 42 | + value={[contentLoaded, setContentLoaded]} |
| 43 | + > |
| 44 | + <ContextQuote.Provider value={quoteRef}> |
| 45 | + <ContextTopTenPosts.Provider value={topTenPostsRef}> |
| 46 | + <ContextTopUsers.Provider value={topUsersRef}> |
| 47 | + <Navigation /> |
| 48 | + <Hero /> |
| 49 | + <Users /> |
| 50 | + <Quote /> |
| 51 | + <Feed /> |
| 52 | + <Footer /> |
| 53 | + </ContextTopUsers.Provider> |
| 54 | + </ContextTopTenPosts.Provider> |
| 55 | + </ContextQuote.Provider> |
| 56 | + </ContextContentLoaded.Provider> |
38 | 57 | </div> |
39 | 58 | ) |
40 | 59 | } |
0 commit comments