Skip to content

Commit 36fe6f7

Browse files
committed
Merge branch 'dev' into shadcn-nav
2 parents 4153a1f + 6ec62c3 commit 36fe6f7

File tree

14 files changed

+61
-1267
lines changed

14 files changed

+61
-1267
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
// Other relative imports. Put same-folder imports and `.` last.
4343
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
4444
// Style imports.
45-
["^.+s?css$"],
45+
["^.+\\.s?css$"],
4646
// Side effect imports.
4747
["^\\u0000"]
4848
]

public/content/contributing/translation-program/translatathon/details/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ EthStaker
123123
- https://crowdin.com/project/ethstaker-website
124124
- https://crowdin.com/project/ethstaker-knowledge-base
125125

126+
Solidity Language Docs
127+
- https://crowdin.com/project/solidity-language-docs
128+
126129
### Evaluation process
127130

128131
All translations will be subject to QA and feedback, where professional linguists will evaluate submissions based on quality and accuracy.

src/components/AdoptionChart.tsx

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,45 @@
11
import { useTranslation } from "next-i18next"
22
import { useTheme } from "next-themes"
3-
import { Box, type BoxProps, Flex } from "@chakra-ui/react"
43

54
import type { ChildOnlyProp } from "@/lib/types"
65

6+
import { cn } from "@/lib/utils/cn"
7+
8+
import { Flex } from "./ui/flex"
9+
10+
type CellProps = ChildOnlyProp & {
11+
color?: string
12+
className?: string
13+
}
14+
715
const Column = ({ children }: ChildOnlyProp) => (
8-
<Flex
9-
flexDirection="column-reverse"
10-
ms={{ base: 2, md: 4 }}
11-
_first={{ ms: 0 }}
12-
>
13-
{children}
14-
</Flex>
16+
<Flex className="ms-2 flex-col-reverse first:ms-0 md:ms-4">{children}</Flex>
1517
)
1618

17-
const Cell = ({ children, color, ...props }: BoxProps) => (
18-
<Box
19-
border="1px solid"
20-
borderColor={color || "text"}
21-
color={color || "text"}
22-
py="0.8rem"
23-
px={{ base: 2, md: "1.2rem" }}
24-
fontSize="0.9rem"
25-
fontWeight="bold"
26-
lineHeight="none"
27-
textAlign="center"
28-
_last={{
29-
borderTopStartRadius: "2xl",
30-
borderTopEndRadius: "2xl",
31-
}}
32-
sx={{
33-
"&:nth-child(-n + 2)": {
34-
borderBottomStartRadius: "2xl",
35-
borderBottomEndRadius: "2xl",
36-
},
19+
const Cell = ({ children, color, className, ...props }: CellProps) => (
20+
<div
21+
className={cn(
22+
"border border-solid px-2 py-[0.8rem] text-center text-[0.9rem] font-bold leading-none last:rounded-t-2xl md:px-[1.2rem] [&:nth-child(-n+2)]:rounded-bl-2xl [&:nth-child(-n+2)]:rounded-br-2xl",
23+
className
24+
)}
25+
style={{
26+
borderColor: color || "currentcolor",
27+
color: color || "currentcolor",
3728
}}
3829
{...props}
3930
>
4031
{children}
41-
</Box>
32+
</div>
4233
)
4334

4435
const ColumnName = ({ children }: ChildOnlyProp) => (
45-
<Cell border="none" pt={6}>
46-
{children}
47-
</Cell>
36+
<Cell className="border-none pt-6">{children}</Cell>
4837
)
4938

5039
const AdoptionChart = () => {
5140
const { t } = useTranslation("page-what-is-ethereum")
52-
const { theme } = useTheme()
53-
const isDark = theme === "dark"
41+
const { resolvedTheme } = useTheme()
42+
const isDark = resolvedTheme === "dark"
5443

5544
return (
5645
<Flex>

src/components/EnergyConsumptionChart/index.tsx

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ import ChartDataLabels from "chartjs-plugin-datalabels"
1212
import { useRouter } from "next/router"
1313
import { useTranslation } from "next-i18next"
1414
import { Bar } from "react-chartjs-2"
15-
import {
16-
Box,
17-
Center,
18-
Text,
19-
useBreakpointValue,
20-
useColorModeValue,
21-
} from "@chakra-ui/react"
15+
import { useBreakpointValue } from "@chakra-ui/react"
2216

2317
import type { Lang } from "@/lib/types"
2418

19+
import { Center } from "@/components/ui/flex"
20+
2521
import { wrapLabel } from "@/lib/utils/charts"
2622
import { isLangRightToLeft } from "@/lib/utils/translations"
2723

24+
import useColorModeValue from "@/hooks/useColorModeValue"
2825
import { useIsClient } from "@/hooks/useIsClient"
2926

3027
// ChartDataLabels required to display y-labels on top of bars
@@ -237,26 +234,19 @@ const EnergyConsumptionChart = () => {
237234
} satisfies ChartData
238235

239236
return (
240-
<Box my={16}>
241-
<Center w="full" mb={{ base: 4, md: 6 }}>
242-
<Box
243-
position="relative"
244-
maxW="500px"
245-
m="auto"
246-
w="80vw"
247-
h={{ base: "300px", md: "400px" }}
248-
mb={{ base: 4, md: 0 }}
249-
>
237+
<div className="my-16">
238+
<Center className="mb-4 w-full md:mb-6">
239+
<div className="relative m-auto mb-4 h-[300px] w-[80vw] max-w-[500px] md:mb-0 md:h-[400px]">
250240
{isClient && (
251241
<Bar options={chartOptions} data={chartData} updateMode="none" />
252242
)}
253-
</Box>
243+
</div>
254244
</Center>
255245

256-
<Text fontWeight="semibold" textAlign="center">
246+
<p className="text-center font-semibold">
257247
{t("page-what-is-ethereum-energy-consumption-chart-legend")}
258-
</Text>
259-
</Box>
248+
</p>
249+
</div>
260250
)
261251
}
262252

src/components/LanguagePicker/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const LanguagePicker = ({
4444
* @param {string} event - The keydown event.
4545
*/
4646
useEventListener("keydown", (e) => {
47-
if (e.key !== "\\") return
47+
if (e.key !== "\\" || e.metaKey || e.ctrlKey) return
4848
e.preventDefault()
4949
onOpen()
5050
})

src/components/Nav/Menu/useNavMenu.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const useNavMenu = (sections: NavSections) => {
1616

1717
// Focus corresponding nav section when number keys pressed
1818
useEventListener("keydown", (event) => {
19-
if (!document || !event.key.match(/[1-9]/) || isModified(event)) return
19+
if (!document || !event.key.match(/^[1-9]$/) || isModified(event)) return
2020
if (event.target instanceof HTMLInputElement) return
2121
if (event.target instanceof HTMLTextAreaElement) return
2222
if (event.target instanceof HTMLSelectElement) return

src/components/Nav/useNav.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import useColorModeValue from "@/hooks/useColorModeValue"
3030

3131
export const useNav = () => {
3232
const { t } = useTranslation("common")
33-
const { theme, setTheme } = useTheme()
33+
const { resolvedTheme, setTheme } = useTheme()
3434
const { setColorMode } = useColorMode()
3535

3636
const colorToggleEvent = useColorModeValue("dark mode", "light mode") // This will be inverted as the state is changing
@@ -466,8 +466,8 @@ export const useNav = () => {
466466
}
467467

468468
const toggleColorMode = () => {
469-
setTheme(theme === "dark" ? "light" : "dark")
470-
setColorMode(theme === "dark" ? "light" : "dark")
469+
setTheme(resolvedTheme === "dark" ? "light" : "dark")
470+
setColorMode(resolvedTheme === "dark" ? "light" : "dark")
471471
trackCustomEvent({
472472
eventCategory: "nav bar",
473473
eventAction: "click",

src/components/Quiz/QuizWidget/useQuizWidget.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useMemo, useState } from "react"
2+
import isChromatic from "chromatic"
23
import shuffle from "lodash/shuffle"
34
import { useTranslation } from "next-i18next"
45

@@ -51,7 +52,9 @@ export const useQuizWidget = ({
5152
const rawQuestion: RawQuestion = questionBank[id]
5253
return { id, ...rawQuestion }
5354
})
54-
const shuffledQuestions = shuffle(questions)
55+
56+
// ! Do not shuffle questions in Chromatic to keep the modal story snapshot stable
57+
const shuffledQuestions = isChromatic() ? questions : shuffle(questions)
5558
const quiz: Quiz = {
5659
title: t(rawQuiz.title),
5760
questions: shuffledQuestions,

0 commit comments

Comments
 (0)