Skip to content

Commit e204373

Browse files
committed
Merge branch 'dev' into tag-migration
2 parents 976e666 + 7217b9c commit e204373

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1127
-1414
lines changed

src/components/CardList.tsx

Lines changed: 51 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
1-
import Image, { type ImageProps } from "next/image"
1+
import TwImage, { type ImageProps } from "next/image"
22
import type { ReactNode } from "react"
3-
import {
4-
Box,
5-
type BoxProps,
6-
Flex,
7-
HStack,
8-
LinkBox,
9-
LinkOverlay,
10-
type StackProps,
11-
useColorModeValue,
12-
} from "@chakra-ui/react"
133

14-
import { BaseLink } from "@/components/Link"
4+
import { LinkBox, LinkOverlay } from "@/components/ui/link-box"
155

6+
import { cn } from "@/lib/utils/cn"
167
import { MatomoEventOptions, trackCustomEvent } from "@/lib/utils/matomo"
178
import * as url from "@/lib/utils/url"
189

10+
import { BaseLink } from "./ui/Link"
11+
1912
import { useRtlFlip } from "@/hooks/useRtlFlip"
2013

21-
export type CardListItem = {
14+
export type CardProps = {
2215
title?: ReactNode
2316
description?: ReactNode
2417
caption?: ReactNode
@@ -27,93 +20,77 @@ export type CardListItem = {
2720
image?: ImageProps["src"]
2821
imageWidth?: number
2922
alt?: string
23+
className?: string
24+
onClick?: () => void
3025
}
3126

32-
const CardContainer = (props: StackProps) => (
33-
<HStack
34-
spacing={4}
35-
p={4}
36-
color="text"
37-
border="1px solid"
38-
borderColor="border"
39-
_hover={{
40-
borderRadius: "base",
41-
boxShadow: "0 0 1px var(--eth-colors-primary)",
42-
background: "tableBackgroundHover",
43-
}}
44-
{...props}
45-
/>
46-
)
47-
48-
type CardProps = CardListItem & Omit<StackProps, "title" | "id">
49-
5027
const Card = ({
5128
title,
5229
description,
5330
caption,
5431
link,
5532
image,
56-
imageWidth = 20, // Set 20px as default image width, can be overridden if needed
33+
className,
5734
alt,
35+
onClick,
36+
imageWidth = 20,
5837
...props
5938
}: CardProps) => {
60-
const { flipForRtl } = useRtlFlip()
39+
const { twFlipForRtl } = useRtlFlip()
6140
const isLink = !!link
6241
const isExternal = url.isExternal(link || "")
6342

64-
const descriptionColor = useColorModeValue("gray.500", "gray.400")
65-
6643
return (
67-
<CardContainer {...props}>
68-
{image && <Image src={image} alt={alt ?? ""} width={imageWidth} />}
69-
<Flex flex="1 1 75%" direction="column">
44+
<div
45+
className={cn(
46+
"text-text flex flex-row items-center gap-4 border p-4",
47+
"transition-all duration-200",
48+
"hover:bg-background-highlight",
49+
className
50+
)}
51+
onClick={onClick}
52+
{...props}
53+
>
54+
{image && <TwImage src={image} alt={alt ?? ""} width={imageWidth} />}
55+
<div className="flex flex-1 basis-3/4 flex-col">
7056
{isLink ? (
71-
<LinkOverlay
72-
as={BaseLink}
73-
href={link}
74-
isExternal={isExternal}
75-
hideArrow
76-
color="text"
77-
textDecoration="none"
78-
_hover={{ textDecoration: "none" }}
79-
>
80-
{title}
57+
<LinkOverlay asChild>
58+
<BaseLink href={link} hideArrow className="text-body no-underline">
59+
{title}
60+
</BaseLink>
8161
</LinkOverlay>
8262
) : (
83-
<Box>{title}</Box>
63+
<div>{title}</div>
8464
)}
8565

86-
<Box fontSize="sm" mb={0} color={descriptionColor}>
87-
{description}
88-
</Box>
89-
</Flex>
66+
<div className="mb-0 text-sm text-body-medium">{description}</div>
67+
</div>
9068
{caption && (
91-
<Flex flex="1 0 25%" align="center" wrap="wrap" me={4}>
92-
<Box fontSize="sm" mb={0} opacity={0.6}>
93-
{caption}
94-
</Box>
95-
</Flex>
69+
<div className="me-4 flex flex-[1_0_25%] flex-wrap items-center">
70+
<div className="mb-0 text-sm opacity-60">{caption}</div>
71+
</div>
9672
)}
97-
{isExternal && <Box transform={flipForRtl}></Box>}
98-
</CardContainer>
73+
{isExternal && <span className={twFlipForRtl}></span>}
74+
</div>
9975
)
10076
}
10177

102-
export type CardListProps = BoxProps & {
78+
export type CardListProps = {
10379
items: CardProps[]
10480
imageWidth?: number
10581
clickHandler?: (idx: string | number) => void
10682
customEventOptions?: MatomoEventOptions
83+
className?: string
10784
}
10885

10986
const CardList = ({
11087
items,
11188
imageWidth,
11289
clickHandler = () => null,
11390
customEventOptions,
114-
...props
91+
className,
11592
}: CardListProps) => (
116-
<Box bg="background.base" w="full" {...props}>
93+
<div className={cn("w-full bg-background", className)}>
11794
{items.map((listItem, idx) => {
11895
const { link, id } = listItem
11996
const isLink = !!link
@@ -123,18 +100,19 @@ const CardList = ({
123100
<Card {...listItem} imageWidth={imageWidth} />
124101
</LinkBox>
125102
) : (
126-
<Card
127-
key={idx}
128-
onClick={() => {
129-
customEventOptions && trackCustomEvent(customEventOptions)
130-
clickHandler(idx)
131-
}}
132-
mb={4}
133-
{...listItem}
134-
/>
103+
<div key={idx}>
104+
<Card
105+
onClick={() => {
106+
customEventOptions && trackCustomEvent(customEventOptions)
107+
clickHandler(idx)
108+
}}
109+
className="mb-4"
110+
{...listItem}
111+
/>
112+
</div>
135113
)
136114
})}
137-
</Box>
115+
</div>
138116
)
139117

140118
export default CardList

src/components/MergeArticleList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { useTranslation } from "next-i18next"
22

3-
import CardList, { type CardListItem } from "@/components/CardList"
3+
import CardList, { type CardProps } from "@/components/CardList"
44

55
const MergeArticleList = () => {
66
const { t } = useTranslation(["page-upgrades", "page-upgrades-index"])
77

8-
const reads: CardListItem[] = [
8+
const reads: CardProps[] = [
99
{
1010
title: t("page-upgrades-index:page-upgrade-article-title-ethmerge"),
1111
description: t(

src/components/Simulator/ClickAnimation.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
import React, { useEffect, useState } from "react"
1+
import { type ReactNode, useEffect, useState } from "react"
22
import { motion, type Transition } from "framer-motion"
3-
import { createIcon, Flex, Text, TextProps } from "@chakra-ui/react"
3+
4+
import { cn } from "@/lib/utils/cn"
5+
6+
import { createIconBase } from "../icons/icon-base"
7+
import { Flex } from "../ui/flex"
48

59
const MotionFlex = motion(Flex)
610

711
const DownArrowLong = motion(
8-
createIcon({
12+
createIconBase({
913
displayName: "DownArrowLong",
1014
viewBox: "0 0 8 24",
11-
defaultProps: { fill: "currentColor" },
12-
path: (
15+
className: "fill-current",
16+
children: (
1317
<path d="M3.64645 23.3536C3.84171 23.5488 4.15829 23.5488 4.35355 23.3536L7.53553 20.1716C7.7308 19.9763 7.7308 19.6597 7.53553 19.4645C7.34027 19.2692 7.02369 19.2692 6.82843 19.4645L4 22.2929L1.17157 19.4645C0.976312 19.2692 0.659729 19.2692 0.464467 19.4645C0.269205 19.6597 0.269205 19.9763 0.464467 20.1716L3.64645 23.3536ZM3.5 2.18557e-08L3.5 23L4.5 23L4.5 -2.18557e-08L3.5 2.18557e-08Z" />
1418
),
1519
})
1620
)
1721

18-
type ClickAnimationProps = Pick<TextProps, "children"> & {
22+
type ClickAnimationProps = {
23+
children: ReactNode
1924
below?: boolean
2025
delay?: number
2126
}
@@ -34,33 +39,28 @@ export const ClickAnimation = ({
3439
times: [0, 0.25, 0.5],
3540
repeat: Infinity,
3641
}
37-
const top = below ? "calc(100% + 0.5rem)" : "auto"
38-
const bottom = below ? "auto" : "calc(100% + 1rem)"
42+
const topClass = below ? "top-[calc(100%_+_0.5rem)]" : "top-auto"
43+
const bottomClass = below ? "bottom-auto" : "bottom-[calc(100%_+_1rem)]"
3944
const y = below ? [0, 20, 0] : [0, -20, 0]
40-
const direction = below ? "column-reverse" : "column"
41-
const transformOrigin = below ? { bottom: 0 } : { top: 0 }
45+
const directionClass = below ? "flex-col-reverse" : "flex-col"
4246
const rotate = below ? 180 : 0
4347
return visible ? (
4448
<MotionFlex
49+
className={cn(
50+
"absolute inset-x-0 justify-center text-primary",
51+
topClass,
52+
bottomClass
53+
)}
4554
animate={{ opacity: [0, 1] }} // Fade in once
46-
position="absolute"
47-
top={top}
48-
justify="center"
49-
bottom={bottom}
50-
insetInline={0}
51-
color="primary.base"
55+
data-testid="click-animation-el"
5256
>
5357
<MotionFlex
54-
direction={direction}
55-
alignItems="center"
58+
className={cn("items-center", directionClass)}
5659
animate={{ y }} // Slide up and down
5760
transition={transition}
5861
>
59-
<Text fontSize="xs" fontStyle="italic" textTransform="lowercase" m={0}>
60-
{children}
61-
</Text>
62+
<p className="m-0 text-xs lowercase italic">{children}</p>
6263
<DownArrowLong
63-
transformOrigin={transformOrigin}
6464
initial={{ scaleY: 1, rotate }}
6565
animate={{ scaleY: [1, 1.25, 1] }} // Arrow scales up and down
6666
transition={transition}

src/components/Simulator/Explanation.tsx

Lines changed: 32 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React from "react"
22
import { motion } from "framer-motion"
33
import { MdArrowBack } from "react-icons/md"
4-
import { Box, Flex, Grid, Heading, Text } from "@chakra-ui/react"
54

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

8-
import { Button, ButtonLink } from "../Buttons"
7+
import { cn } from "@/lib/utils/cn"
8+
9+
import { Button, ButtonLink } from "../ui/buttons/Button"
10+
import { Flex } from "../ui/flex"
911

1012
import type {
1113
LabelHref,
@@ -43,74 +45,51 @@ export const Explanation = ({
4345
hidden: { opacity: 0 },
4446
}
4547
return (
46-
<Flex direction="column" flex={1} zIndex={1}>
48+
<Flex className="z-[1] flex-1 flex-col">
4749
{/* Back button */}
4850
<Button
49-
as={motion.button}
5051
variant="ghost"
51-
leftIcon={<MdArrowBack size="18px" />}
52-
sx={{ paddingInlineStart: 0 }}
53-
mt={{ base: -6, md: 0 }}
54-
mb={{ base: 2, md: 8 }}
52+
className={cn(
53+
"-mt-6 mb-2 w-fit ps-0 [transition-duration:10ms] md:mb-8 md:mt-0",
54+
step === 0 ? "pointer-events-none" : "pointer-events-auto"
55+
)}
5556
onClick={regressStepper}
56-
pointerEvents={step === 0 ? "none" : "all"}
57-
variants={backButtonVariants}
58-
initial="hidden"
59-
animate={step === 0 ? "hidden" : "visible"}
60-
transitionDuration="10ms"
61-
w="fit-content"
57+
asChild
6258
>
63-
Back
59+
<motion.button
60+
initial="hidden"
61+
variants={backButtonVariants}
62+
animate={step === 0 ? "hidden" : "visible"}
63+
>
64+
<MdArrowBack size="18px" />
65+
Back
66+
</motion.button>
6467
</Button>
65-
<Flex direction={{ base: "row", md: "column" }} gap={{ base: 3, md: 2 }}>
68+
<Flex className="gap-3 md:flex-col md:gap-2">
6669
{/* Step counter */}
67-
<Grid
68-
placeItems="center"
69-
bg="body.light"
70-
borderRadius="lg"
71-
p={2}
72-
w={9}
73-
h={8}
74-
fontSize="xs"
75-
>
76-
<Text as="span" lineHeight={1} fontWeight="bold" m={0}>
70+
<div className="grid h-8 w-9 place-items-center rounded-lg bg-body-light p-2 text-xs">
71+
<span className="font-bold leading-none">
7772
{step + 1}/{totalSteps}
78-
</Text>
79-
</Grid>
73+
</span>
74+
</div>
8075
{/* Header and description */}
81-
<Box>
82-
<Heading
83-
as="h3"
84-
fontSize={{ base: "xl", sm: "2xl", md: "3xl", lg: "4xl" }}
85-
lineHeight={{ base: 8, md: 10 }}
86-
mt={0}
87-
mb={{ base: 4, md: 8 }}
88-
>
76+
<div>
77+
<h3 className="mb-4 mt-0 text-xl leading-8 sm:text-2xl md:mb-8 md:text-3xl md:leading-10 lg:text-4xl">
8978
{header}
90-
</Heading>
79+
</h3>
9180
{description && (
92-
<Box display={{ base: "block", md: "none" }} position="relative">
81+
<div className="relative md:hidden">
9382
<MoreInfoPopover isFirstStep={nav.step === 0}>
94-
<Box>{description}</Box>
83+
<div>{description}</div>
9584
</MoreInfoPopover>
96-
</Box>
85+
</div>
9786
)}
98-
</Box>
87+
</div>
9988
</Flex>
100-
{description && (
101-
<Box display={{ base: "none", md: "block" }}>{description}</Box>
102-
)}
89+
{description && <div className="max-md:hidden">{description}</div>}
10390
{/* Last step navigation buttons */}
10491
{isLastStep && (
105-
<Flex
106-
direction="column"
107-
gap={4}
108-
maxW="300px"
109-
w="full"
110-
mx={{ base: "auto", md: 0 }}
111-
mt={4}
112-
zIndex={-1}
113-
>
92+
<Flex className="z-[-1] mx-auto mt-4 w-full max-w-[300px] flex-col gap-4 md:mx-0">
11493
{nextPathSummary && openPath && nextPathId && (
11594
<PathButton
11695
pathSummary={nextPathSummary}

0 commit comments

Comments
 (0)