Skip to content

Commit ff97053

Browse files
authored
Merge pull request #13975 from ethereum/migrateTrilemma
Migrate Trilemma Triangle to Shadcn
2 parents c254562 + 8c87c38 commit ff97053

File tree

3 files changed

+55
-47
lines changed

3 files changed

+55
-47
lines changed

src/components/Trilemma/Triangle.tsx

Lines changed: 47 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import React from "react"
12
import { useTranslation } from "next-i18next"
2-
import { chakra, forwardRef, HTMLChakraProps } from "@chakra-ui/react"
3+
4+
import { cn } from "@/lib/utils/cn"
35

46
import { HandleClickParam } from "./useTrilemma"
57

@@ -27,54 +29,58 @@ export const TriangleSVG = ({
2729
const { t } = useTranslation("page-roadmap-vision")
2830

2931
const Path = () => (
30-
<chakra.path
32+
<path
3133
d="M111.183 479.532L566.904 181.217L598.824 787.211L111.183 479.532Z"
32-
stroke="border"
33-
strokeWidth="2"
34+
className="stroke-border stroke-2"
3435
/>
3536
)
3637

37-
const CircleSelect = forwardRef((props, ref) => (
38-
<chakra.g
39-
ref={ref}
40-
cursor="pointer"
41-
sx={{
42-
"circle:first-of-type": {
43-
fill: "white",
44-
},
45-
}}
46-
{...props}
47-
/>
48-
))
38+
const CircleSelect: React.FC<React.ComponentPropsWithoutRef<"g">> = ({
39+
children,
40+
...props
41+
}) => (
42+
<g className="cursor-pointer" {...props}>
43+
{children}
44+
</g>
45+
)
4946

50-
const FillCircle = ({ isEthereum = false, isActive, ...rest }) => {
47+
const FillCircle: React.FC<
48+
{
49+
isEthereum?: boolean
50+
isActive: boolean
51+
} & React.ComponentPropsWithoutRef<"circle">
52+
> = ({ isEthereum = false, isActive, ...rest }) => {
5153
return (
52-
<chakra.circle
53-
fill={
54-
(isActive && (isEthereum ? "primary300" : "primary.base")) ||
55-
"background.base"
56-
}
57-
_hover={{
58-
fill: isActive ? "primary.base" : "primary100",
59-
}}
54+
<circle
55+
className={cn(
56+
"transition-colors",
57+
isActive
58+
? isEthereum
59+
? "fill-primary opacity-50"
60+
: "fill-primary"
61+
: "fill-background",
62+
"hover:fill-primary"
63+
)}
6064
{...rest}
6165
/>
6266
)
6367
}
6468

65-
const Text = ({
66-
isActive,
67-
...rest
68-
}: { isActive: boolean } & HTMLChakraProps<"text">) => (
69-
<chakra.text
70-
fill={isActive ? "primary400" : "text200"}
71-
fontWeight={isActive ? 700 : 500}
72-
opacity={isActive ? 1.0 : 0.6}
73-
fontSize={{ base: "2rem", sm: "1.4rem" }}
74-
textTransform="uppercase"
75-
transform={{ base: "translate(-80px, 0px)", sm: "none" }}
69+
const Text: React.FC<
70+
{ isActive: boolean } & React.ComponentPropsWithoutRef<"text">
71+
> = ({ isActive, children, ...rest }) => (
72+
<text
73+
className={cn(
74+
"uppercase",
75+
isActive ? "fill-primary font-bold" : "fill-body-menu-high font-medium",
76+
isActive ? "opacity-100" : "opacity-60",
77+
"text-[2rem] sm:text-[1.4rem]",
78+
"-translate-x-20 transform sm:translate-x-0"
79+
)}
7680
{...rest}
77-
/>
81+
>
82+
{children}
83+
</text>
7884
)
7985

8086
const commonCircleStyles = {
@@ -106,14 +112,11 @@ export const TriangleSVG = ({
106112
const INNER_CIRCLE_RADIUS = "21"
107113

108114
return (
109-
<chakra.svg
115+
<svg
110116
xmlns="http://www.w3.org/2000/svg"
111-
height="620px"
117+
height="620"
112118
viewBox="-100 100 850 915"
113-
fill="background.base"
114-
width={{ base: "full", lg: "auto" }}
115-
mt={{ lg: 32 }}
116-
me={{ lg: 32 }}
119+
className="w-full fill-background lg:mr-32 lg:mt-32 lg:w-auto"
117120
>
118121
<Path />
119122
<Path />
@@ -165,6 +168,6 @@ export const TriangleSVG = ({
165168
<Text x="540" y="835" isActive={isScalable}>
166169
{t("page-roadmap-vision-trilemma-text-3")}
167170
</Text>
168-
</chakra.svg>
171+
</svg>
169172
)
170173
}

src/styles/semantic-tokens.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
--background-medium: var(--gray-200);
2424
--background-high: var(--gray-300);
2525

26-
/* TODO: Add border color tokens to match DS */
26+
/* TODO: Add all border color tokens to match DS */
27+
--border: var(--gray-200);
2728

2829
--primary: var(--purple-600);
2930
--primary-high-contrast: var(--purple-800);
@@ -129,7 +130,8 @@
129130
--background-medium: var(--gray-600);
130131
--background-high: var(--gray-800);
131132

132-
/* TODO: Add border color tokens to match DS */
133+
/* TODO: Add all border color tokens to match DS */
134+
--border: var(--gray-600);
133135

134136
--primary: var(--purple-400);
135137
--primary-high-contrast: var(--purple-200);

tailwind.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,10 @@ const config = {
154154
high: "hsla(var(--background-high))",
155155
},
156156

157-
// TODO: Add border color tokens to match DS
157+
// TODO: Add all border color tokens to match DS
158+
border: {
159+
DEFAULT: "hsla(var(--border))",
160+
},
158161

159162
primary: {
160163
DEFAULT: "hsla(var(--primary))",

0 commit comments

Comments
 (0)