|
1 | 1 | import { useTranslation } from "next-i18next" |
2 | | -import { AspectRatio, Box, chakra, Icon } from "@chakra-ui/react" |
| 2 | +import type { SVGTextElementAttributes } from "react" |
3 | 3 |
|
4 | 4 | import Translation from "@/components/Translation" |
5 | 5 |
|
| 6 | +import { cn } from "@/lib/utils/cn" |
| 7 | + |
| 8 | +import { createIconBase } from "../icons/icon-base" |
| 9 | +import { HStack } from "../ui/flex" |
| 10 | + |
6 | 11 | import { Background } from "./Background" |
7 | 12 |
|
8 | | -const Text = chakra("text", { |
9 | | - baseStyle: { |
10 | | - textAnchor: "start", |
11 | | - fill: "currentColor", |
12 | | - }, |
13 | | -}) |
| 13 | +const Text = ({ |
| 14 | + className, |
| 15 | + ...rest |
| 16 | +}: SVGTextElementAttributes<SVGTextElement>) => ( |
| 17 | + <text |
| 18 | + className={cn("fill-current [text-anchor:start]", className)} |
| 19 | + {...rest} |
| 20 | + /> |
| 21 | +) |
14 | 22 |
|
15 | | -const SvgText = () => { |
| 23 | +const SvgTextInternal = () => { |
16 | 24 | const { t } = useTranslation(["page-upgrades-index"]) |
17 | | - const [sm, lg] = ["7px", "8px"] |
| 25 | + const [sm, lg] = ["text-[7px]", "text-[8px]"] |
18 | 26 |
|
19 | 27 | return ( |
20 | | - <Icon |
21 | | - position="absolute" |
22 | | - zIndex={1} |
23 | | - width="100%" |
24 | | - height="100%" |
25 | | - viewBox="0 0 250 110" |
26 | | - version="1.1" |
27 | | - xmlns="http://www.w3.org/2000/svg" |
28 | | - xmlnsXlink="http://www.w3.org/1999/xlink" |
29 | | - aria-hidden="true" |
30 | | - > |
31 | | - <Text x="2%" y="35%" fontSize={lg}> |
| 28 | + <> |
| 29 | + <Text className={lg} x="2%" y="35%"> |
32 | 30 | ⛏ {t("page-upgrades-index:docs-nav-proof-of-work")} |
33 | 31 | </Text> |
34 | | - <Text x="47%" y="35%" fontSize={lg}> |
| 32 | + <Text className={lg} x="47%" y="35%"> |
35 | 33 | 🌱 {t("page-upgrades-index:docs-nav-proof-of-stake")} |
36 | 34 | </Text> |
37 | | - <Text x="11%" y="70%" fontSize={sm}> |
| 35 | + <Text className={sm} x="11%" y="70%"> |
38 | 36 | 🚀 {t("common:beacon-chain")} |
39 | 37 | </Text> |
40 | | - <Text x="43%" y="12.5%" fontSize={sm}> |
| 38 | + <Text className={sm} x="43%" y="12.5%"> |
41 | 39 | 🐼 {t("page-upgrades-index:page-upgrades-get-involved-ethresearch-2")} |
42 | 40 | </Text> |
43 | | - <Text x="63%" y="95%" fontSize={sm}> |
| 41 | + <Text className={sm} x="63%" y="95%"> |
44 | 42 | 🌳 {t("page-upgrades-index:page-upgrades-get-involved-ethresearch-1")} |
45 | 43 | </Text> |
46 | | - </Icon> |
| 44 | + </> |
47 | 45 | ) |
48 | 46 | } |
49 | 47 |
|
| 48 | +const SvgText = createIconBase({ |
| 49 | + displayName: "SvgText", |
| 50 | + viewBox: "0 0 250 110", |
| 51 | + version: "1.1", |
| 52 | + xmlns: "http://www.w3.org/2000/svg", |
| 53 | + xmlnsXlink: "http://www.w3.org/1999/xlink", |
| 54 | + "aria-hidden": true, |
| 55 | + className: "absolute size-full z-[1]", |
| 56 | + children: <SvgTextInternal />, |
| 57 | +}) |
| 58 | + |
50 | 59 | const MergeInfographic = () => { |
51 | 60 | const { t } = useTranslation() |
52 | 61 |
|
53 | 62 | return ( |
54 | | - <AspectRatio |
| 63 | + <div |
| 64 | + className="relative isolate aspect-[25/11] w-full" |
55 | 65 | role="img" |
56 | 66 | aria-label={t( |
57 | 67 | "page-upgrades-index:page-upgrades-merge-infographic-alt-text" |
58 | 68 | )} |
59 | | - position="relative" |
60 | | - width="100%" |
61 | | - ratio={25 / 11} |
62 | | - sx={{ |
63 | | - isolation: "isolate", |
64 | | - }} |
65 | 69 | > |
66 | | - <Box> |
67 | | - <Box |
68 | | - position="absolute" |
69 | | - top="40%" |
70 | | - insetInlineStart="2%" |
71 | | - width="81%" |
72 | | - height="18%" |
73 | | - margin={0} |
74 | | - padding={0} |
75 | | - zIndex={2} |
76 | | - display="flex" |
77 | | - justifyContent="center" |
78 | | - alignItems="center" |
79 | | - lineHeight="1em" |
80 | | - textAlign="center" |
81 | | - maxHeight="2em" |
82 | | - color="background.base" |
83 | | - fontSize={{ |
84 | | - base: "0.625em", |
85 | | - sm: "0.875em", |
86 | | - md: "1.125em", |
87 | | - lg: "1.375em", |
88 | | - }} |
| 70 | + <div> |
| 71 | + <HStack |
| 72 | + className="absolute left-[2%] top-[40%] z-[2] h-[18%] max-h-[2em] w-[81%] justify-center text-center text-[0.625em] leading-[1em] text-background sm:text-[0.875em] md:text-[1.125em] lg:text-[1.375em]" |
89 | 73 | aria-hidden="true" |
90 | 74 | > |
91 | 75 | <Translation id="page-upgrades:page-upgrades-merge-infographic-el" /> |
92 | | - </Box> |
| 76 | + </HStack> |
93 | 77 | <SvgText /> |
94 | 78 | <Background className="absolute z-0 size-full" aria-hidden="true" /> |
95 | | - </Box> |
96 | | - </AspectRatio> |
| 79 | + </div> |
| 80 | + </div> |
97 | 81 | ) |
98 | 82 | } |
99 | 83 |
|
|
0 commit comments