-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathHomeView.jsx
101 lines (92 loc) Β· 3.17 KB
/
HomeView.jsx
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
import React, { useMemo } from "react";
import { Container, Box, Text, Center, useColorModeValue, Button } from "@chakra-ui/react";
import ChallengeExpandedCard from "../components/ChallengeExpandedCard";
import { challengeInfo } from "../data/challenges";
import useCustomColorModes from "../hooks/useCustomColorModes";
import HeroLogo from "../components/icons/HeroLogo";
import HeroDiamond from "../components/icons/HeroDiamond";
import { useHistory } from "react-router-dom";
export default function HomeView({ connectedBuilder, userProvider }) {
const history = useHistory();
const { primaryFontColor, bgColor } = useCustomColorModes();
const cardBgColor = useColorModeValue("sre.cardBackground", "sreDark.cardBackground");
const builderAttemptedChallenges = useMemo(() => {
if (!connectedBuilder?.challenges) {
return [];
}
return Object.fromEntries(
Object.entries(connectedBuilder.challenges).filter(([_, challengeData]) => challengeData?.status),
);
}, [connectedBuilder]);
const handleCtaClick = () => {
if (window.plausible) {
window.plausible("cta");
}
setTimeout(() => {
history.push(`/challenge/${Object.keys(challengeInfo)[0]}`);
}, 100);
};
return (
<Box>
<Box
bgColor={bgColor}
bgImg="/assets/home_header_clouds.svg"
backgroundPosition="top center"
backgroundRepeat="repeat-x"
backgroundSize="auto 300px"
>
<Container maxW="container.lg" centerContent p="0 20px" mb="45px">
<Center mb="35px" w="100%">
<HeroDiamond maxW="45px" height="auto" />
</Center>
<Text
color={primaryFontColor}
mb="5"
fontSize={{
base: "lg",
lg: "md",
}}
textAlign="center"
>
Learn how to build on <strong>Ethereum</strong>; the superpowers and the gotchas.
</Text>
<Center
mb={{
base: "40px",
lg: "20px",
}}
mt="15px"
w="100%"
>
<HeroLogo maxW="600px" height="auto" />
</Center>
<Button onClick={handleCtaClick} colorScheme="green" mt={4} size="lg">
Start Building on Ethereum
</Button>
</Container>
<Box
bgImg="/assets/header_platform.svg"
backgroundRepeat="repeat-x"
backgroundSize="auto 130px"
h="130px"
pos="relative"
/>
</Box>
<Box mt="-20px" pt="20px" bgColor={cardBgColor}>
{Object.entries(challengeInfo).map(([challengeId, challenge], index, { length }) => (
<ChallengeExpandedCard
challengeId={challengeId}
challenge={challenge}
// Magic number: we don't want to count the Join the BG as a challenge
challengeIndex={index < 5 ? index : index - 1}
builderAttemptedChallenges={builderAttemptedChallenges}
userProvider={userProvider}
connectedBuilder={connectedBuilder}
isFirst={index === 0}
isLast={length - 1 === index}
/>
))}
</Box>
</Box>
);
}