-
Notifications
You must be signed in to change notification settings - Fork 179
/
Copy pathepoch.js
225 lines (214 loc) · 5.68 KB
/
epoch.js
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
import { Box, Flex, Grid, Image, Link, Text } from 'theme-ui'
import { useEffect, useState } from 'react'
import Buttons from './button'
import CardModel from './card-model'
export default function Epoch() {
const calculateTimeLeft = () => {
const difference = +new Date(`2022-12-30T12:30:00.000Z`) - +new Date()
let timeLeft = {}
if (difference > 0) {
timeLeft = {
days: Math.floor(difference / (1000 * 60 * 60 * 24)),
hours: Math.floor((difference / (1000 * 60 * 60)) % 24),
min: Math.floor((difference / 1000 / 60) % 60),
sec: Math.floor((difference / 1000) % 60)
}
}
return timeLeft
}
const [timeLeft, setTimeLeft] = useState(calculateTimeLeft())
useEffect(() => {
const timer = setTimeout(() => {
setTimeLeft(calculateTimeLeft())
}, 1000)
return () => clearTimeout(timer)
})
const timer = []
Object.keys(timeLeft).forEach(e => {
if (!timeLeft[e]) {
if (e === 'days') {
return
} else if (e === 'hours') {
if (!timeLeft['days']) {
return
}
} else if (e === 'min') {
if (!timeLeft['days'] && !timeLeft['hours']) {
return
}
} else {
if (!timeLeft['days'] && !timeLeft['hours'] && !timeLeft['min']) {
return
}
}
}
var name = ''
if (e === 'days') {
if (timeLeft[e] === 1 || timeLeft[e] === 0) {
name = 'day'
} else {
name = 'days'
}
} else if (e === 'hours') {
if (timeLeft[e] === 1 || timeLeft[e] === 0) {
name = 'hour'
} else {
name = 'hours'
}
} else if (e === 'min') {
name = 'min'
} else {
name = 'sec'
}
timer.push(
<Box
sx={theme => ({
color: '#FF4794',
position: 'relative',
width: [null, '85%', '80%'],
height: [null, '50%', '85%'],
border: 'none',
borderColor: '#FF4794',
fontSize: [3, 4],
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
textAlign: 'center',
opacity: 0.7
})}
>
<Box>
<Text
sx={{
color: '#FF4794'
}}
>
{timeLeft[e]}{' '}
</Text>
<Text
sx={{
color: 'white',
position: 'relative',
fontSize: [1, '16px', '20px'],
display: 'block',
pb: '15px'
}}
>
{name}
</Text>
</Box>
</Box>
)
})
return (
<CardModel
id="epoch"
color="white"
sx={{
backgroundColor: '#000'
}}
>
<Image
src="/home/epoch-bg.webp"
sx={{
objectFit: 'cover',
position: 'absolute',
width: '100%',
height: '100%',
ml: ['-24px', '-32px', '-32px', '-32px'],
mt: ['-24px', '-32px', '-32px', '-32px']
}}
alt="Hack Club Presents Epoch background"
/>
<Grid columns={[1, 1, '1fr 1.5fr']} sx={{ position: 'relative' }}>
<Box>
<Image
src="https://cloud-jzsq7jfvg-hack-club-bot.vercel.app/0group_9.png"
sx={{
width: ['220px', '220px', '240px', '350px'],
position: 'relative',
zIndex: 2
}}
alt="Hack Club Presents Epoch header"
/>
<Box>
{timer.length ? (
<Grid
key="{e}"
columns={['1fr 1fr 1fr 1fr']}
sx={{ mr: 2, mt: 2 }}
>
{timer}
</Grid>
) : (
<></>
)}
</Box>
</Box>
<Box ml={[0, 0, 3]}>
<Text as="p" variant="subtitle" sx={{ mt: 0 }}>
Join us this winter as 150+ teenage hackers from all around the
world travel to Delhi, India for Epoch! Together, we’ll build the
unexpected, share what we’ve learnt in 2022, and experience the
thrill of being in-person together.
</Text>
<Text as="p" variant="subtitle">
In{' '}
<Link
sx={{ color: '#FF4794' }}
href="https://hackclub.slack.com/archives/C04CGDDLC72"
target="_blank"
rel="noopener"
>
Austin
</Link>
,{' '}
<Link
sx={{ color: '#FF4794' }}
href="https://epochba.hackclub.com/"
target="_blank"
rel="noopener"
>
Bay Area
</Link>
, or{' '}
<Link
sx={{ color: '#FF4794' }}
href="https://epochvt.hackclub.com/"
target="_blank"
rel="noopener"
>
Vermont
</Link>
? Join a regional Epoch event!
</Text>
<Flex
sx={{
flexDirection: 'column',
mt: [4, 3, 4],
position: 'relative'
}}
>
<Buttons
// content="travel stipends available"
id="17"
link="https://epoch.hackclub.com"
icon="post"
primary="#FF4794"
>
Sign up and attend Epoch
</Buttons>
<Buttons
content="join #epoch-bts on Slack"
id="18"
link="/slack"
icon="idea"
>
Help plan the hackathon
</Buttons>
</Flex>
</Box>
</Grid>
</CardModel>
)
}