Skip to content

Commit 0a4693c

Browse files
authored
Merge pull request #13967 from ethereum/updateUpcomingEventsList
Migrate UpcomingEventsList to Shadcn
2 parents 298d126 + 7143f84 commit 0a4693c

File tree

1 file changed

+14
-52
lines changed

1 file changed

+14
-52
lines changed

src/components/UpcomingEventsList.tsx

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { useEffect, useState } from "react"
22
import _ from "lodash"
33
import { useRouter } from "next/router"
44
import { useTranslation } from "next-i18next"
5-
import { Box, Grid, Heading } from "@chakra-ui/react"
65

76
import type { CommunityConference, Lang } from "@/lib/types"
87

9-
import { Button } from "@/components/Buttons"
108
import EventCard from "@/components/EventCard"
119
import InfoBanner from "@/components/InfoBanner"
12-
import InlineLink from "@/components/Link"
10+
import { Button } from "@/components/ui/buttons/Button"
11+
import Link from "@/components/ui/Link"
1312

1413
import { trackCustomEvent } from "@/lib/utils/matomo"
1514
import { getLocaleTimestamp } from "@/lib/utils/time"
@@ -22,7 +21,6 @@ const UpcomingEventsList = () => {
2221
const monthsPerLoad = 2
2322

2423
const [monthGroupedEvents, setMonthGroupedEvents] = useState({})
25-
2624
const [maxRange, setMaxRange] = useState<number>(monthsPerLoad)
2725

2826
// Create Date object from each YYYY-MM-DD JSON date string
@@ -70,7 +68,6 @@ const UpcomingEventsList = () => {
7068
}
7169
})
7270
const groupedEvents = _.groupBy(formattedEvents, ({ startDate }) => {
73-
// .replace(/-/g, "/") ==> Fixes Safari Invalid date
7471
const start = new Date(startDate.replace(/-/g, "/"))
7572
const formatYearMonth = new Intl.DateTimeFormat(locale, {
7673
month: "short",
@@ -80,9 +77,7 @@ const UpcomingEventsList = () => {
8077
})
8178

8279
setMonthGroupedEvents(groupedEvents)
83-
84-
// eslint-disable-next-line react-hooks/exhaustive-deps
85-
}, [])
80+
}, [locale])
8681

8782
const loadMoreEvents = () => {
8883
setMaxRange((counter) => {
@@ -101,43 +96,23 @@ const UpcomingEventsList = () => {
10196
return (
10297
<InfoBanner emoji=":information_source:">
10398
{t("page-community-upcoming-events-no-events")}{" "}
104-
<InlineLink href="https://github.com/ethereum/ethereum-org-website/blob/dev/src/data/community-events.json">
99+
<Link href="https://github.com/ethereum/ethereum-org-website/blob/dev/src/data/community-events.json">
105100
{t("page-community-please-add-to-page")}
106-
</InlineLink>
101+
</Link>
107102
</InfoBanner>
108103
)
109104
}
110105

111106
return (
112-
<>
107+
<div>
113108
{Object.keys(monthGroupedEvents)
114109
?.slice(0, maxRange)
115110
?.map((month) => {
116111
const events = monthGroupedEvents[month]
117112
return (
118-
<Box key={`events_in_${month}`}>
119-
<Heading
120-
as="h3"
121-
fontSize={{ base: "xl", md: "2xl" }}
122-
py={8}
123-
fontWeight="semibold"
124-
lineHeight={1.4}
125-
>
126-
{month}
127-
</Heading>
128-
<Grid
129-
width={{ base: "100%" }}
130-
templateColumns={{
131-
base: "repeat(1,1fr)",
132-
md: "repeat(2,1fr)",
133-
lg: "repeat(3,1fr)",
134-
}}
135-
justifyContent={"center"}
136-
alignItems={"center"}
137-
alignSelf={"center"}
138-
gap={5}
139-
overflow={"hidden"}
140-
>
113+
<div key={`events_in_${month}`}>
114+
<h3 className="py-8">{month}</h3>
115+
<div className="grid grid-cols-1 gap-5 md:grid-cols-2 lg:grid-cols-3">
141116
{events.map(
142117
(
143118
{
@@ -164,32 +139,19 @@ const UpcomingEventsList = () => {
164139
/>
165140
)
166141
)}
167-
</Grid>
168-
</Box>
142+
</div>
143+
</div>
169144
)
170145
})}
171146

172-
<Box
173-
width="100%"
174-
margin="30px auto"
175-
position="relative"
176-
padding="0 10px"
177-
transition="all 0.4s ease"
178-
></Box>
179147
{Object.keys(monthGroupedEvents)?.length !== maxRange && (
180-
<Box
181-
display="flex"
182-
justifyContent="center"
183-
maxWidth="620px"
184-
marginTop="5"
185-
paddingY="8"
186-
>
148+
<div className="flex justify-center py-8">
187149
<Button onClick={loadMoreEvents}>
188150
{t("page-community-upcoming-events-load-more")}
189151
</Button>
190-
</Box>
152+
</div>
191153
)}
192-
</>
154+
</div>
193155
)
194156
}
195157

0 commit comments

Comments
 (0)