1- import React from "react" ;
2- import styled from "styled-components" ;
1+ import React , { useEffect , useState } from "react" ;
2+ import styled , { useTheme } from "styled-components" ;
33import CourtOverview from "./CourtOverview" ;
44import LatestCases from "./LatestCases" ;
55import Community from "./Community" ;
66import { HomePageProvider } from "hooks/useHomePageContext" ;
77import { getOneYearAgoTimestamp } from "utils/date" ;
8+ import { BREAKPOINT_SMALL_SCREEN } from "styles/smallScreenStyle" ;
9+ import HeaderLightMobile from "tsx:svgs/header/header-lightmode-mobile.svg" ;
10+ import HeaderDarkMobile from "tsx:svgs/header/header-darkmode-mobile.svg" ;
11+ import HeaderLightDesktop from "tsx:svgs/header/header-lightmode-desktop.svg" ;
12+ import HeaderDarkDesktop from "tsx:svgs/header/header-darkmode-desktop.svg" ;
813
914const Container = styled . div `
1015 width: 100%;
@@ -13,14 +18,45 @@ const Container = styled.div`
1318 padding: 32px;
1419` ;
1520
16- const Home : React . FC = ( ) => (
17- < HomePageProvider timeframe = { getOneYearAgoTimestamp ( ) } >
18- < Container >
19- < CourtOverview />
20- < LatestCases />
21- < Community />
22- </ Container >
23- </ HomePageProvider >
24- ) ;
21+ const Header = ( ) => {
22+ const [ windowWidth , setWindowWidth ] = useState ( window . innerWidth ) ;
23+
24+ useEffect ( ( ) => {
25+ const handleResize = ( ) => {
26+ setWindowWidth ( window . innerWidth ) ;
27+ } ;
28+
29+ window . addEventListener ( "resize" , handleResize ) ;
30+
31+ return ( ) => {
32+ window . removeEventListener ( "resize" , handleResize ) ;
33+ } ;
34+ } , [ ] ) ;
35+
36+ const theme = useTheme ( ) ;
37+ const themeIsLight = theme . name === "light" ;
38+ const breakpointIsBig = windowWidth > BREAKPOINT_SMALL_SCREEN ;
39+ return (
40+ < >
41+ { themeIsLight && breakpointIsBig && < HeaderLightDesktop /> }
42+ { ! themeIsLight && breakpointIsBig && < HeaderDarkDesktop /> }
43+ { themeIsLight && ! breakpointIsBig && < HeaderLightMobile /> }
44+ { ! themeIsLight && ! breakpointIsBig && < HeaderDarkMobile /> }
45+ </ >
46+ ) ;
47+ } ;
48+
49+ const Home : React . FC = ( ) => {
50+ return (
51+ < HomePageProvider timeframe = { getOneYearAgoTimestamp ( ) } >
52+ < Header />
53+ < Container >
54+ < CourtOverview />
55+ < LatestCases />
56+ < Community />
57+ </ Container >
58+ </ HomePageProvider >
59+ ) ;
60+ } ;
2561
2662export default Home ;
0 commit comments