Skip to content

Commit 828525f

Browse files
Merge remote-tracking branch 'upstream/dev' into refactor/what-is-ethereum-shadcn
2 parents ecc1a23 + 6eed7bc commit 828525f

36 files changed

+1025
-992
lines changed

.eslintrc.json

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,7 @@
99
"env": {
1010
"es6": true
1111
},
12-
"plugins": [
13-
"simple-import-sort",
14-
"@typescript-eslint",
15-
"unused-imports"
16-
],
12+
"plugins": ["simple-import-sort", "@typescript-eslint", "unused-imports"],
1713
"parser": "@typescript-eslint/parser",
1814
"rules": {
1915
"simple-import-sort/imports": [
@@ -26,55 +22,29 @@
2622
],
2723
// Packages. `react` related packages come first.
2824
// Also, put `react-icons` in sorting order not with `react`
29-
[
30-
"^react(?!-.)$",
31-
"^\\w",
32-
"^@\\w"
33-
],
25+
["^react(?!-.)$", "^\\w", "^@\\w"],
3426
// The Chakra theme directory if imported to story file or other places
35-
[
36-
"^@/@chakra-ui"
37-
],
27+
["^@/@chakra-ui"],
3828
// From the `types` directory.
39-
[
40-
"^@/lib/types",
41-
"^@/lib/interfaces"
42-
],
29+
["^@/lib/types", "^@/lib/interfaces"],
4330
// From the `components` directory.
44-
[
45-
"^@/components"
46-
],
31+
["^@/components"],
4732
// From the `utils` directory.
48-
[
49-
"^@/lib/utils"
50-
],
33+
["^@/lib/utils"],
5134
// From the `data` directory.
52-
[
53-
"^@/data"
54-
],
35+
["^@/data"],
5536
// From the `constants` directory.
5637
["^@/lib/constants"],
5738
// From the `.storybook/utils` file
5839
["^@/storybook-utils"],
5940
// Parent imports. Put `..` last.
60-
[
61-
"^\\.\\.(?!/?$)",
62-
"^\\.\\./?$"
63-
],
41+
["^\\.\\.(?!/?$)", "^\\.\\./?$"],
6442
// Other relative imports. Put same-folder imports and `.` last.
65-
[
66-
"^\\./(?=.*/)(?!/?$)",
67-
"^\\.(?!/?$)",
68-
"^\\./?$"
69-
],
43+
["^\\./(?=.*/)(?!/?$)", "^\\.(?!/?$)", "^\\./?$"],
7044
// Style imports.
71-
[
72-
"^.+\\.s?css$"
73-
],
45+
["^.+s?css$"],
7446
// Side effect imports.
75-
[
76-
"^\\u0000"
77-
]
47+
["^\\u0000"]
7848
]
7949
}
8050
],
@@ -89,7 +59,7 @@
8959
],
9060
"unused-imports/no-unused-vars": [
9161
"error",
92-
{
62+
{
9363
"args": "all",
9464
"argsIgnorePattern": "^_$",
9565
"varsIgnorePattern": "^_$"
@@ -98,4 +68,3 @@
9868
"unused-imports/no-unused-imports-ts": "warn"
9969
}
10070
}
101-

.storybook/preview.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ import ThemeProvider from "@/components/ThemeProvider"
77

88
import i18n, { baseLocales } from "./i18next"
99

10+
import "@docsearch/css"
1011
import "../src/styles/global.css"
1112
import "../src/styles/fonts.css"
13+
import "../src/styles/docsearch.css"
1214

1315
MotionGlobalConfig.skipAnimations = isChromatic()
1416

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@
3737
"@next/bundle-analyzer": "^14.2.5",
3838
"@radix-ui/react-accordion": "^1.2.0",
3939
"@radix-ui/react-checkbox": "^1.1.1",
40+
"@radix-ui/react-compose-refs": "^1.1.0",
4041
"@radix-ui/react-dialog": "^1.1.1",
4142
"@radix-ui/react-navigation-menu": "^1.2.0",
4243
"@radix-ui/react-popover": "^1.1.1",
44+
"@radix-ui/react-portal": "^1.1.1",
45+
"@radix-ui/react-progress": "^1.1.0",
4346
"@radix-ui/react-radio-group": "^1.2.0",
4447
"@radix-ui/react-slot": "^1.1.0",
4548
"@radix-ui/react-switch": "^1.1.0",
@@ -50,6 +53,7 @@
5053
"chartjs-plugin-datalabels": "^2.2.0",
5154
"class-variance-authority": "^0.7.0",
5255
"clsx": "^2.1.1",
56+
"cmdk": "^1.0.0",
5357
"embla-carousel-react": "^7.0.0",
5458
"ethereum-blockies-base64": "^1.0.2",
5559
"framer-motion": "^10.13.0",

src/components/FeedbackCard.tsx

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
import { type ReactNode, useState } from "react"
22
import { useRouter } from "next/router"
33
import { useTranslation } from "next-i18next"
4-
import { Flex, type FlexProps, Heading } from "@chakra-ui/react"
54

65
import type { Lang } from "@/lib/types"
76

8-
import { Button } from "@/components/Buttons"
97
import { FeedbackThumbsUpIcon } from "@/components/icons"
108

119
import { trackCustomEvent } from "@/lib/utils/matomo"
1210
import { isLangRightToLeft } from "@/lib/utils/translations"
1311

12+
import { Button } from "./ui/buttons/Button"
1413
import Translation from "./Translation"
1514

1615
import { useSurvey } from "@/hooks/useSurvey"
1716

18-
type FeedbackCardProps = FlexProps & {
17+
type FeedbackCardProps = {
1918
prompt?: string
2019
isArticle?: boolean
2120
}
@@ -60,44 +59,34 @@ const FeedbackCard = ({ prompt, isArticle, ...props }: FeedbackCardProps) => {
6059
}
6160

6261
return (
63-
<Flex
64-
border="1px"
65-
borderColor="border"
66-
bg="feedbackGradient"
67-
borderRadius="base"
68-
p="6"
69-
direction="column"
70-
mb="4"
71-
mt="8"
72-
w="full"
62+
<div
63+
className="mb-4 mt-8 flex w-full flex-col rounded border border-body-light bg-feedback-gradient p-6"
7364
{...props}
7465
dir={dir}
7566
>
76-
<Flex direction="column" gap="4">
77-
<Heading as="h3" m="0" mb="2" fontSize="1.375rem" fontWeight="bold">
78-
{getTitle(feedbackSubmitted)}
79-
</Heading>
67+
<div className="flex flex-col gap-4">
68+
<h4 className="mb-2">{getTitle(feedbackSubmitted)}</h4>
8069
{feedbackSubmitted && (
8170
<p>
8271
{t("feedback-widget-thank-you-subtitle")}{" "}
8372
<Translation id="feedback-widget-thank-you-subtitle-ext" />
8473
</p>
8574
)}
86-
<Flex gap="4">
75+
<div className="flex gap-4">
8776
{!feedbackSubmitted ? (
8877
<>
8978
<Button
9079
variant="outline-color"
91-
leftIcon={<FeedbackThumbsUpIcon />}
9280
onClick={() => handleSubmit(true)}
9381
>
82+
<FeedbackThumbsUpIcon className="h-6 w-6" />
9483
{t("yes")}
9584
</Button>
9685
<Button
9786
variant="outline-color"
98-
leftIcon={<FeedbackThumbsUpIcon transform="scaleY(-1)" />}
9987
onClick={() => handleSubmit(false)}
10088
>
89+
<FeedbackThumbsUpIcon className="-scale-y-100" />
10190
{t("no")}
10291
</Button>
10392
</>
@@ -106,9 +95,9 @@ const FeedbackCard = ({ prompt, isArticle, ...props }: FeedbackCardProps) => {
10695
{t("feedback-widget-thank-you-cta")}
10796
</Button>
10897
)}
109-
</Flex>
110-
</Flex>
111-
</Flex>
98+
</div>
99+
</div>
100+
</div>
112101
)
113102
}
114103

src/components/Image.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,18 @@ const DefaultNextImage = (props: ImageProps) => {
4141
}
4242

4343
/**
44-
* TODO: replace this component with import { Image } from "@chakra-ui/next-js"
45-
* once https://github.com/vercel/next.js/issues/52216 is fixed
44+
* TODO: Rename this component to `Image` once all components are using Tailwind
45+
*/
46+
export const TwImage = (props: NextImageProps) => (
47+
<DefaultNextImage {...props} />
48+
)
49+
50+
/**
51+
* DEPRECATED: Use `TWImage` instead
52+
*
53+
* TODO: Remove this component once all components are using Tailwind
54+
*
55+
* @deprecated
4656
*/
4757
export const Image: ChakraComponent<"img", NextImageProps> = chakra(
4858
DefaultNextImage,
Lines changed: 36 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,22 @@
1+
import { ComponentPropsWithoutRef } from "react"
12
import { useRouter } from "next/router"
23
import { useTranslation } from "next-i18next"
34
import { BsCheck } from "react-icons/bs"
4-
import {
5-
Badge,
6-
Box,
7-
Flex,
8-
forwardRef,
9-
Icon,
10-
MenuItem as ChakraMenuItem,
11-
type MenuItemProps as ChakraMenuItemProps,
12-
Text,
13-
} from "@chakra-ui/react"
145

156
import type { LocaleDisplayInfo } from "@/lib/types"
167

17-
import { BaseLink } from "@/components/Link"
8+
import { cn } from "@/lib/utils/cn"
9+
10+
import { Badge } from "../ui/badge"
11+
import { CommandItem } from "../ui/command"
1812

1913
import ProgressBar from "./ProgressBar"
2014

21-
type ItemProps = ChakraMenuItemProps & {
15+
type ItemProps = ComponentPropsWithoutRef<typeof CommandItem> & {
2216
displayInfo: LocaleDisplayInfo
2317
}
2418

25-
const MenuItem = forwardRef(({ displayInfo, ...props }: ItemProps, ref) => {
19+
const MenuItem = ({ displayInfo, ...props }: ItemProps) => {
2620
const {
2721
localeOption,
2822
sourceName,
@@ -32,7 +26,7 @@ const MenuItem = forwardRef(({ displayInfo, ...props }: ItemProps, ref) => {
3226
isBrowserDefault,
3327
} = displayInfo
3428
const { t } = useTranslation("common")
35-
const { asPath, locale } = useRouter()
29+
const { locale } = useRouter()
3630
const isCurrent = localeOption === locale
3731

3832
const getProgressInfo = (approvalProgress: number, wordsApproved: number) => {
@@ -48,86 +42,49 @@ const MenuItem = forwardRef(({ displayInfo, ...props }: ItemProps, ref) => {
4842
const { progress, words } = getProgressInfo(approvalProgress, wordsApproved)
4943

5044
return (
51-
<ChakraMenuItem
52-
as={BaseLink}
53-
ref={ref}
54-
flexDir="column"
55-
w="full"
56-
mb="1"
57-
display="block"
58-
pt="2 !important"
59-
alignItems="start"
60-
borderRadius="base"
61-
bg={isCurrent ? "background.base" : "transparent"}
62-
color="body.base"
63-
textDecoration="none"
64-
onFocus={(e) => {
65-
e.target.scrollIntoView({ block: "nearest" })
66-
}}
67-
scrollMarginY="8"
68-
_hover={{
69-
bg: "primary.lowContrast",
70-
textDecoration: "none",
71-
"p.language-name": { color: "primary.base" },
72-
}}
73-
_focus={{ bg: "primary.lowContrast" }}
74-
sx={{
75-
p: {
76-
textDecoration: "none",
77-
overflow: "hidden",
78-
textOverflow: "ellipsis",
79-
whiteSpace: "nowrap",
80-
},
81-
}}
82-
href={asPath}
83-
locale={localeOption}
45+
<CommandItem
46+
value={localeOption}
47+
className={cn(
48+
"group mb-1 flex-col items-start rounded pt-2 text-body hover:bg-primary-low-contrast",
49+
isCurrent
50+
? "bg-background hover:bg-primary-low-contrast"
51+
: "bg-transparent"
52+
)}
8453
{...props}
8554
>
86-
<Flex alignItems="center" w="full">
87-
<Box flex={1}>
88-
<Flex alignItems="center" gap={2}>
89-
<Text
90-
className="language-name"
91-
fontSize="lg"
92-
color={isCurrent ? "primary.highContrast" : "body.base"}
55+
<div className="flex w-full items-center">
56+
<div className="flex-1">
57+
<div className="flex items-center gap-2">
58+
<p
59+
className={cn(
60+
"language-name text-lg group-aria-selected:text-primary",
61+
isCurrent ? "text-primary-high-contrast" : "text-body"
62+
)}
9363
>
9464
{targetName}
95-
</Text>
65+
</p>
9666
{isBrowserDefault && (
9767
<Badge
98-
border="1px"
99-
borderColor="body.medium"
100-
color="body.medium"
101-
lineHeight="none"
102-
fontSize="2xs"
103-
p="1"
104-
h="fit-content"
105-
bg="none"
68+
className="h-fit-content rounded border-body-medium p-1 text-2xs font-normal uppercase leading-none text-body-medium"
69+
variant="outline"
10670
>
10771
{t("page-languages-browser-default")}
10872
</Badge>
10973
)}
110-
</Flex>
111-
<Text textTransform="uppercase" fontSize="xs" color="body.base">
112-
{sourceName}
113-
</Text>
114-
</Box>
74+
</div>
75+
<p className="text-xs uppercase text-body">{sourceName}</p>
76+
</div>
11577
{isCurrent && (
116-
<Icon as={BsCheck} fontSize="2xl" color="primary.highContrast" />
78+
<BsCheck className="text-2xl text-primary-high-contrast" />
11779
)}
118-
</Flex>
119-
<Text
120-
textTransform="lowercase"
121-
fontSize="xs"
122-
color="body.medium"
123-
maxW="full"
124-
>
80+
</div>
81+
<p className="max-w-full text-xs lowercase text-body-medium">
12582
{progress} {t("page-languages-translated")}{words}{" "}
12683
{t("page-languages-words")}
127-
</Text>
84+
</p>
12885
<ProgressBar value={approvalProgress} />
129-
</ChakraMenuItem>
86+
</CommandItem>
13087
)
131-
})
88+
}
13289

13390
export default MenuItem

0 commit comments

Comments
 (0)