-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathindex.tsx
More file actions
128 lines (118 loc) · 4.09 KB
/
index.tsx
File metadata and controls
128 lines (118 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
"use client"
import { sendGAEvent } from "@next/third-parties/google"
import Image from "next/image"
import { useEffect, useState } from "react"
import { Container, Stack, Typography } from "@mui/material"
import Button from "@/components/Button"
import { formatLargeNumber } from "@/utils"
import GetSCRDialog from "./GetSCRDialog"
import Statistic from "./Statistic"
import DATA from "./data"
const Header = props => {
const { circulatingSupply, votableSupply } = props
const [getSCROpen, setGetSCROpen] = useState(false)
const [height, setHeight] = useState("auto")
useEffect(() => {
function handleResize() {
if (window.innerHeight - 65 > 858) {
setHeight("calc(100vh - 6.5rem)")
} else {
setHeight("auto")
}
}
handleResize()
window.addEventListener("resize", handleResize)
return () => {
window.removeEventListener("resize", handleResize)
}
}, [])
const actionList = [
{
id: "get-scr",
values: [circulatingSupply, votableSupply],
action: () => {
setGetSCROpen(true)
sendGAEvent("event", "click_get_SCR", {
label: "Get SCR now",
})
},
},
{
id: "stake-scr",
action: () => {
// TODO: coming soon
// sendGAEvent("event", "click_stack_SCR", {
// label: "Stack SCR now",
// })
},
},
]
const handleCloseDialog = () => {
setGetSCROpen(false)
}
return (
<Container
sx={{
pt: "4rem",
pb: ["4.8rem", "8rem"],
height: ["auto", "auto", height],
display: "flex",
flexDirection: "column",
justifyContent: "center",
}}
>
<Stack direction="row" justifyContent="center">
<Image src="/imgs/token/scr.svg" alt="scr" width="64" height="64" className="w-[4.8rem] sm:w-[6.4rem] aspect-square"></Image>
<Image
src="/imgs/token/sSCR.svg"
alt="scr"
width="64"
height="64"
className="w-[4.8rem] sm:w-[6.4rem] aspect-square ml-[-0.6rem] sm:ml-[-1rem]"
></Image>
<Typography sx={{ fontSize: ["4rem", "6.4rem"], lineHeight: ["4,8rem", "8.8rem"], fontWeight: 600, ml: ["1.6rem", "2rem"] }}>
SCR & sSCR
</Typography>
</Stack>
<Stack direction={["column", "column", "row"]} sx={{ mt: ["4rem", "5rem"], gap: ["1.6rem", "3.2rem"] }}>
{DATA.map(item => (
<Stack
key={item.id}
direction="column"
alignItems="center"
sx={{
flex: 1,
p: ["2.4rem", "4rem 2.4rem"],
backgroundColor: "background.default",
borderRadius: "2rem",
gap: "1.6rem",
}}
>
<Image src={item.imageURL} alt={item.title} width={516} height={408} className="w-auto h-[12rem] sm:h-[18rem]"></Image>
<Typography sx={{ fontSize: ["2rem", "3.2rem"], lineHeight: ["3.2rem", "4.8rem"], fontWeight: 600 }}>{item.title}</Typography>
<Typography sx={{ fontSize: ["1.6rem", "1.8rem"], lineHeight: ["2.4rem", "2.8rem"], textAlign: "center", flex: 1 }}>
{item.description}
</Typography>
<Stack direction="row" justifyContent="center" sx={{ width: "100%", gap: ["0.8rem", "2.4rem"], mb: ["0.8rem", "2.4rem"] }}>
{item.values.map(({ label, value }, index) => (
<Statistic key={label} label={label}>
{value === null ? "--" : formatLargeNumber(actionList.find(action => action.id === item.id)!.values?.[index] ?? value)}
</Statistic>
))}
</Stack>
<Button
color={item.upcoming ? "default" : "primary"}
className="!w-full sm:!w-[20.8rem]"
gloomy={!!item.upcoming}
onClick={actionList.find(action => action.id === item.id)!.action}
>
{item.actionLabel}
</Button>
</Stack>
))}
</Stack>
<GetSCRDialog open={getSCROpen} onClose={handleCloseDialog}></GetSCRDialog>
</Container>
)
}
export default Header