Skip to content

Commit 8ee8495

Browse files
authored
Merge branch 'dev' into staging
2 parents 7ad2599 + ca9e1ac commit 8ee8495

File tree

15 files changed

+573
-180
lines changed

15 files changed

+573
-180
lines changed

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,8 @@
123123
"scripts": {
124124
"postinstall": "yarn theme",
125125
"build": "gatsby build",
126-
"build:lambda": "NODE_OPTIONS=--openssl-legacy-provider netlify-lambda build src/lambda --config=./webpack.lambda.js",
127-
"build:10gb": "NODE_OPTIONS=--max-old-space-size=10240 gatsby build",
128-
"build:lambda-cross-env": "cross-env NODE_OPTIONS=--openssl-legacy-provider netlify-lambda build src/lambda --config=./webpack.lambda.js",
129-
"build:10gb-cross-env": "cross-env NODE_OPTIONS=--max-old-space-size=10240 gatsby build",
126+
"build:lambda": "cross-env NODE_OPTIONS=--openssl-legacy-provider netlify-lambda build src/lambda --config=./webpack.lambda.js",
127+
"build:10gb": "cross-env NODE_OPTIONS=--max-old-space-size=10240 gatsby build",
130128
"clean": "gatsby clean",
131129
"crowdin-clean": "rm -rf .crowdin && mkdir .crowdin",
132130
"crowdin-import": "ts-node src/scripts/crowdin-import.ts",

src/api/calendarEvents.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { GatsbyFunctionRequest, GatsbyFunctionResponse } from "gatsby"
2+
import { lambda } from "../lambda/calendarEvents"
3+
4+
async function handler(
5+
__req: GatsbyFunctionRequest,
6+
res: GatsbyFunctionResponse
7+
): Promise<void> {
8+
// passing env vars as arguments due to a bug on GC functions where env vars
9+
// can not be accessed by imported functions
10+
const { statusCode, body } = await lambda(
11+
process.env.GOOGLE_API_KEY!,
12+
process.env.GOOGLE_CALENDAR_ID!
13+
)
14+
res.status(statusCode).send(body)
15+
}
16+
17+
export default handler
Lines changed: 232 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,232 @@
1+
//Libraries
2+
import React, { ComponentProps } from "react"
3+
import { useI18next, useTranslation } from "gatsby-plugin-react-i18next"
4+
import {
5+
Box,
6+
Center,
7+
Divider,
8+
Flex,
9+
Grid,
10+
GridItem,
11+
Heading,
12+
Icon,
13+
Text,
14+
} from "@chakra-ui/react"
15+
import { FaDiscord } from "react-icons/fa"
16+
import { DateTime, DateTimeFormatOptions } from "luxon"
17+
18+
// Components
19+
import ButtonLink from "../ButtonLink"
20+
import Link from "../Link"
21+
import Translation from "../Translation"
22+
23+
// Utils
24+
import { trackCustomEvent } from "../../utils/matomo"
25+
26+
// Hooks
27+
import {
28+
type Event as EventType,
29+
useCommunityEvents,
30+
} from "./useCommunityEvents"
31+
32+
const matomoEvent = (buttonType: string) => {
33+
trackCustomEvent({
34+
eventCategory: "CommunityEventsWidget",
35+
eventAction: "clicked",
36+
eventName: buttonType,
37+
})
38+
}
39+
40+
const renderEventDateTime = (
41+
date: string,
42+
language: string,
43+
params: DateTimeFormatOptions = {
44+
year: "numeric",
45+
month: "long",
46+
day: "numeric",
47+
hour12: false,
48+
hour: "numeric",
49+
minute: "numeric",
50+
}
51+
) => {
52+
return DateTime.fromISO(date).setLocale(language).toLocaleString(params)
53+
}
54+
55+
const EventLink = (props: ComponentProps<typeof Link>) => (
56+
<Link fontWeight="700" {...props} />
57+
)
58+
59+
interface EventProps {
60+
event: EventType
61+
language: string
62+
type: "upcoming" | "past"
63+
}
64+
65+
const Event = ({ event, language, type }: EventProps) => {
66+
const { date, title, calendarLink } = event
67+
const params: DateTimeFormatOptions = {
68+
year: "numeric",
69+
month: "short",
70+
day: "numeric",
71+
}
72+
73+
return (
74+
<Grid gap={6} templateColumns="auto 1fr">
75+
<GridItem>
76+
<Text>{renderEventDateTime(date, language, params)}</Text>
77+
</GridItem>
78+
<GridItem>
79+
<EventLink to={calendarLink} onClick={() => matomoEvent(type)}>
80+
{title}
81+
</EventLink>
82+
</GridItem>
83+
</Grid>
84+
)
85+
}
86+
87+
const CommunityEvents = () => {
88+
const { language } = useI18next()
89+
const { t } = useTranslation()
90+
const { pastEventData, upcomingEventData, loading, hasError } =
91+
useCommunityEvents()
92+
93+
return (
94+
<Flex
95+
w="full"
96+
flexDirection={{ base: "column", lg: "row" }}
97+
p={{
98+
base: "0",
99+
sm: "2rem 0 0",
100+
lg: "2rem 2rem 0",
101+
}}
102+
>
103+
<Center w={{ base: "100%", lg: "40%" }}>
104+
<Box pr={8} pl={{ base: 8, lg: 0 }}>
105+
<Heading>
106+
<Translation id="community-events-content-heading" />
107+
</Heading>
108+
<Text>
109+
<Translation id="community-events-content-1" />
110+
</Text>
111+
<Text>
112+
<Translation id="community-events-content-2" />
113+
</Text>
114+
</Box>
115+
</Center>
116+
<Flex
117+
w={{ base: "100%", lg: "60%" }}
118+
flexDirection={{ base: "column", lg: "row" }}
119+
>
120+
<Flex
121+
w={{ base: "100%", lg: "50%" }}
122+
bg="layer2Gradient"
123+
p={8}
124+
textAlign="center"
125+
flexDir="column"
126+
>
127+
<Text fontSize="md" fontWeight="bold">
128+
<Translation id="community-events-next-event" />
129+
</Text>
130+
{loading ? (
131+
<Text>
132+
<Translation id="loading" />
133+
</Text>
134+
) : (
135+
<Box>
136+
{hasError ? (
137+
<Text color="error">
138+
<Translation id="loading-error-try-again-later" />
139+
</Text>
140+
) : upcomingEventData.length ? (
141+
<>
142+
<Text m={0} fontSize="xl">
143+
{renderEventDateTime(upcomingEventData[0].date, language)}
144+
</Text>
145+
<Text color={"bodyLight"} fontSize="md">
146+
({Intl.DateTimeFormat().resolvedOptions().timeZone})
147+
</Text>
148+
<Text fontSize="3xl" fontWeight="bold" mb={10}>
149+
{upcomingEventData[0].title}
150+
</Text>
151+
</>
152+
) : (
153+
<Text fontSize="3xl" fontWeight="bold" mb={8}>
154+
<Translation id="community-events-no-events-planned" />
155+
</Text>
156+
)}
157+
<Flex flexDirection="column" gap={6}>
158+
<ButtonLink
159+
to="/discord/"
160+
gap={2}
161+
onClick={() => matomoEvent("discord")}
162+
>
163+
<Icon as={FaDiscord} fontSize={25} />
164+
Join Discord
165+
</ButtonLink>
166+
{upcomingEventData[0] && (
167+
<EventLink
168+
to={upcomingEventData[0].calendarLink}
169+
onClick={() => matomoEvent("Add to calendar")}
170+
>
171+
{t("community-events-add-to-calendar")}
172+
</EventLink>
173+
)}
174+
</Flex>
175+
</Box>
176+
)}
177+
</Flex>
178+
<Flex
179+
w={{ base: "100%", lg: "50%" }}
180+
bg="backgroundHighlight"
181+
p={8}
182+
flexDir="column"
183+
>
184+
<Text fontSize="lg" fontWeight="bold" mb={2}>
185+
<Translation id="community-events-upcoming-calls" />
186+
</Text>
187+
<Divider mb={4} />
188+
{loading ? (
189+
<Text>
190+
<Translation id="loading" />
191+
</Text>
192+
) : hasError ? (
193+
<Text color="error">
194+
<Translation id="loading-error-try-again-later" />
195+
</Text>
196+
) : upcomingEventData.slice(1).length ? (
197+
upcomingEventData.slice(1).map((item) => {
198+
return <Event event={item} language={language} type="upcoming" />
199+
})
200+
) : (
201+
<Text mx="auto">
202+
<Translation id="community-events-no-upcoming-calls" />
203+
</Text>
204+
)}
205+
<Text fontSize="lg" fontWeight="bold" mb={2}>
206+
<Translation id="community-events-previous-calls" />
207+
</Text>
208+
<Divider mb={4} />
209+
{loading ? (
210+
<Text>
211+
<Translation id="loading" />
212+
</Text>
213+
) : hasError ? (
214+
<Text color="error">
215+
<Translation id="loading-error-try-again-later" />
216+
</Text>
217+
) : pastEventData.length ? (
218+
pastEventData.map((item) => {
219+
return <Event event={item} language={language} type="past" />
220+
})
221+
) : (
222+
<Text mx="auto">
223+
<Translation id="community-events-there-are-no-past-calls" />
224+
</Text>
225+
)}
226+
</Flex>
227+
</Flex>
228+
</Flex>
229+
)
230+
}
231+
232+
export default CommunityEvents
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Libraries
2+
import { useEffect, useState } from "react"
3+
4+
// Constants
5+
import { GATSBY_FUNCTIONS_PATH } from "../../constants"
6+
7+
// Utils
8+
import { getData } from "../../utils/cache"
9+
10+
// Interface
11+
export interface Event {
12+
date: string
13+
title: string
14+
calendarLink: string
15+
pastEventLink: string | undefined
16+
}
17+
18+
interface State {
19+
pastEventData: Array<Event>
20+
upcomingEventData: Array<Event>
21+
loading: boolean
22+
hasError: boolean
23+
}
24+
25+
interface ReqEvent {
26+
start: { dateTime: string }
27+
summary: string
28+
htmlLink: string
29+
location: string
30+
}
31+
32+
interface ReqEvents {
33+
pastEvents: Array<ReqEvent>
34+
futureEvents: Array<ReqEvent>
35+
}
36+
37+
export const useCommunityEvents = () => {
38+
const [state, setState] = useState<State>({
39+
pastEventData: [],
40+
upcomingEventData: [],
41+
loading: true,
42+
hasError: false,
43+
})
44+
45+
useEffect(() => {
46+
const fetchCalendarData = async () => {
47+
let events: ReqEvents
48+
49+
try {
50+
events = await getData<ReqEvents>(
51+
`${GATSBY_FUNCTIONS_PATH}/calendarEvents`
52+
)
53+
} catch {
54+
setState({ ...state, loading: false, hasError: true })
55+
return
56+
}
57+
58+
const pastEventData = events.pastEvents.map((event) => {
59+
return {
60+
date: event.start.dateTime,
61+
title: event.summary,
62+
calendarLink: event.htmlLink,
63+
pastEventLink: event.location,
64+
}
65+
})
66+
const upcomingEventData = events.futureEvents.map((event) => {
67+
return {
68+
date: event.start.dateTime,
69+
title: event.summary,
70+
calendarLink: event.htmlLink,
71+
pastEventLink: event.location,
72+
}
73+
})
74+
75+
setState({
76+
...state,
77+
pastEventData,
78+
upcomingEventData,
79+
loading: false,
80+
hasError: false,
81+
})
82+
}
83+
fetchCalendarData()
84+
}, [])
85+
86+
return state
87+
}

src/content/contributing/translation-program/content-buckets/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Below is a breakdown of the website pages each content bucket contains.
7676
- [How to revoke smart contract access to your crypto funds](/guides/how-to-revoke-token-access/)
7777
- [How to bridge tokens to layer 2](/guides/how-to-use-a-bridge/)
7878
- [How to swap tokens](/guides/how-to-swap-tokens/)
79-
- Learning quizzes
79+
- [Learning quizzes](/quizzes/)
8080

8181
## 9) Upgrades {#upgrades}
8282

@@ -217,7 +217,7 @@ Below is a breakdown of the website pages each content bucket contains.
217217
- [ERC-1155](/developers/docs/standards/tokens/erc-1155/)
218218
- [ERC-4626](/developers/docs/standards/tokens/erc-4626/)
219219
- [Maximal extractable value (MEV)](/developers/docs/mev/)
220-
- [Orcles](/developers/docs/oracles/)
220+
- [Oracles](/developers/docs/oracles/)
221221
- [Bridges](/developers/docs/bridges/)
222222
- [Data availability](/developers/docs/data-availability/)
223223

@@ -282,7 +282,7 @@ Below is a breakdown of the website pages each content bucket contains.
282282
- [How to write & deploy an NFT (Part 1/3 of NFT tutorial series)](/developers/tutorials/how-to-write-and-deploy-an-nft/)
283283
- [How to mint an NFT (Part 2/3 of NFT tutorial series)](/developers/tutorials/how-to-mint-an-nft/)
284284
- [How to view your NFT in your wallet (Part 3/3 of NFT tutorial series)](/developers/tutorials/how-to-view-nft-in-metamask/)
285-
transfers-and-approval-of-erc-20-tokens-from-a-solidity-smart-contract/)
285+
- [Transfers and approval of ERC-20 tokens from a solidity smart contract](/developers/tutorials/transfers-and-approval-of-erc-20-tokens-from-a-solidity-smart-contract/)
286286
- [Understand the ERC-20 token smart contract](/developers/tutorials/understand-the-erc-20-token-smart-contract/)
287287
- [Uniswap-v2 contract walkthrough](/developers/tutorials/uniswap-v2-annotated-code/)
288288
- Submit a tutorial

src/content/developers/docs/accounts/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ An Ethereum account is an entity with an ether (ETH) balance that can send trans
88

99
## Prerequisites {#prerequisites}
1010

11-
Accounts are a very beginner-friendly topic. But to help you better understand this page, we recommend you first read through our [introduction to Ethereum](/developers/docs/intro-to-ethereum/).
11+
To help you better understand this page, we recommend you first read through our [introduction to Ethereum](/developers/docs/intro-to-ethereum/).
1212

1313
## Account types {#types-of-account}
1414

0 commit comments

Comments
 (0)