Skip to content

Commit c6e32a3

Browse files
committed
feat(web): add svg header for mobile, desktop
1 parent f6c2582 commit c6e32a3

File tree

7 files changed

+252
-11
lines changed

7 files changed

+252
-11
lines changed

web/src/assets/svgs/header/header-darkmode-desktop.svg

Lines changed: 73 additions & 0 deletions
Loading

web/src/assets/svgs/header/header-darkmode-mobile.svg

Lines changed: 53 additions & 0 deletions
Loading

web/src/assets/svgs/header/header-lightmode-desktop.svg

Lines changed: 15 additions & 0 deletions
Loading

web/src/assets/svgs/header/header-lightmode-mobile.svg

Lines changed: 53 additions & 0 deletions
Loading

web/src/pages/Home/index.tsx

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
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";
33
import CourtOverview from "./CourtOverview";
44
import LatestCases from "./LatestCases";
55
import Community from "./Community";
66
import { HomePageProvider } from "hooks/useHomePageContext";
77
import { 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

914
const 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

2662
export default Home;

web/src/styles/smallScreenStyle.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { css, FlattenSimpleInterpolation } from "styled-components";
2+
3+
export const BREAKPOINT_SMALL_SCREEN = 768;
4+
5+
export const smallScreenStyle = (style: FlattenSimpleInterpolation) => css`
6+
@media (max-width: ${BREAKPOINT_SMALL_SCREEN}px) {
7+
${style}
8+
}
9+
`;

web/src/styles/themes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { lightTheme as componentsLightTheme, darkTheme as componentsDarkTheme }
22

33
export const lightTheme = {
44
...componentsLightTheme,
5+
name: "light",
56
primaryPurple: "#4D00B4",
67
secondaryPurple: "#9013FE",
78
mediumPurple: "#F8F1FF",
@@ -38,6 +39,7 @@ export const lightTheme = {
3839

3940
export const darkTheme = {
4041
...componentsDarkTheme,
42+
name: "dark",
4143
primaryPurple: "#7E1BD4",
4244
secondaryPurple: "#B45FFF",
4345
mediumPurple: "#390F6C",

0 commit comments

Comments
 (0)