@@ -17,29 +17,36 @@ import { ChartAreaIcon, RefreshCw, User } from 'lucide-react';
1717import { useTranslation } from 'react-i18next' ;
1818import { useNavigate } from 'react-router-dom' ;
1919
20- const SideBar = ( ) => {
21- const navigate = useNavigate ( ) ;
22-
20+ function MainPageHeader ( {
21+ refreshData,
22+ isLoading,
23+ isValidating,
24+ } : {
25+ refreshData : ( ) => void ;
26+ isLoading ?: boolean ;
27+ isValidating ?: boolean ;
28+ } ) {
2329 return (
24- < >
25- < SearchBar
26- onSearch = { ( keyword ) => {
27- navigate ( '/filter' , {
28- state : {
29- initialKeyword : keyword . trim ( ) ,
30- } ,
31- } ) ;
32- } }
30+ < div
31+ className = "group bg-background sticky top-0 z-10 flex cursor-pointer items-center gap-2 p-4 py-4.5 font-light text-gray-600"
32+ onClick = { refreshData }
33+ >
34+ < Logo className = "h-6 w-fit" color = "#07C160" />
35+ < img
36+ className = "text-theme mb-[2px] ml-2 h-4 opacity-0 duration-300 group-hover:opacity-100"
37+ src = { slogenImg }
38+ alt = "slogen"
3339 />
34- < Heatmap />
35- < TagMap />
36- < RandomRote />
37- </ >
40+
41+ { isLoading ||
42+ ( isValidating && (
43+ < RefreshCw className = "text-primary ml-auto size-4 animate-spin duration-300" />
44+ ) ) }
45+ </ div >
3846 ) ;
39- } ;
47+ }
4048
41- function HomePage ( ) {
42- const { t } = useTranslation ( 'translation' , { keyPrefix : 'pages.home' } ) ;
49+ function MainPage ( ) {
4350 const { data : profile } = useAPIGet < Profile > ( 'profile' , ( ) =>
4451 get ( '/users/me/profile' ) . then ( ( res ) => res . data )
4552 ) ;
@@ -74,32 +81,8 @@ function HomePage() {
7481 } ;
7582
7683 return (
77- < ContainerWithSideBar
78- sidebar = { < SideBar /> }
79- sidebarHeader = {
80- < div className = "flex items-center gap-2 p-4 text-lg font-semibold" >
81- < div className = "flex h-8 items-center gap-2" >
82- < ChartAreaIcon className = "size-5" />
83- { t ( 'statistics' ) }
84- </ div >
85- </ div >
86- }
87- >
88- < div
89- className = "group bg-background sticky top-0 z-10 flex cursor-pointer items-center gap-2 p-4 py-3 font-light text-gray-600"
90- onClick = { refreshData }
91- >
92- < Logo className = "w-24" color = "#07C160" />
93- < img
94- className = "text-theme mb-[2px] ml-2 h-4 opacity-0 duration-300 group-hover:opacity-100"
95- src = { slogenImg }
96- alt = "slogen"
97- />
98- { isLoading ||
99- ( isValidating && (
100- < RefreshCw className = "text-primary ml-auto size-4 animate-spin duration-300" />
101- ) ) }
102- </ div >
84+ < >
85+ < MainPageHeader refreshData = { refreshData } isLoading = { isLoading } isValidating = { isValidating } />
10386 < div className = "flex gap-4 p-4" >
10487 < Avatar className = "hidden size-10 shrink-0 overflow-hidden rounded-full xl:block" >
10588 { profile ?. avatar ? (
@@ -118,6 +101,47 @@ function HomePage() {
118101 />
119102 </ div >
120103 < RoteList data = { data } loadMore = { loadMore } mutate = { mutate } />
104+ </ >
105+ ) ;
106+ }
107+
108+ function HomePage ( ) {
109+ const { t } = useTranslation ( 'translation' , { keyPrefix : 'pages.home' } ) ;
110+
111+ const SideBar = ( ) => {
112+ const navigate = useNavigate ( ) ;
113+
114+ return (
115+ < >
116+ < SearchBar
117+ onSearch = { ( keyword ) => {
118+ navigate ( '/filter' , {
119+ state : {
120+ initialKeyword : keyword . trim ( ) ,
121+ } ,
122+ } ) ;
123+ } }
124+ />
125+ < Heatmap />
126+ < TagMap />
127+ < RandomRote />
128+ </ >
129+ ) ;
130+ } ;
131+
132+ return (
133+ < ContainerWithSideBar
134+ sidebar = { < SideBar /> }
135+ sidebarHeader = {
136+ < div className = "flex items-center gap-2 p-4 text-lg font-semibold" >
137+ < div className = "flex items-center gap-2" >
138+ < ChartAreaIcon className = "size-5" />
139+ { t ( 'statistics' ) }
140+ </ div >
141+ </ div >
142+ }
143+ >
144+ < MainPage />
121145 </ ContainerWithSideBar >
122146 ) ;
123147}
0 commit comments