Skip to content

Commit 510d1a1

Browse files
authored
Merge pull request #13828 from ethereum/c1-pricecard
Migrate EthPriceCard, update associate color tokens
2 parents fe91618 + 6f724bd commit 510d1a1

File tree

9 files changed

+177
-197
lines changed

9 files changed

+177
-197
lines changed

src/components/EthPriceCard.tsx

Lines changed: 48 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,15 @@ import { useEffect, useState } from "react"
22
import { useRouter } from "next/router"
33
import { useTranslation } from "next-i18next"
44
import { MdInfoOutline } from "react-icons/md"
5-
import {
6-
Box,
7-
Flex,
8-
type FlexProps,
9-
Heading,
10-
Icon,
11-
Text,
12-
} from "@chakra-ui/react"
135

146
import type { LoadingState } from "@/lib/types"
157

16-
import InlineLink from "@/components/Link"
178
import Tooltip from "@/components/Tooltip"
9+
import InlineLink from "@/components/ui/Link"
10+
11+
import { cn } from "@/lib/utils/cn"
12+
13+
import { Flex } from "./ui/flex"
1814

1915
import { useRtlFlip } from "@/hooks/useRtlFlip"
2016

@@ -30,17 +26,16 @@ type EthPriceState = {
3026
percentChangeUSD: number
3127
}
3228

33-
export type EthPriceCardProps = FlexProps & {
34-
isLeftAlign?: boolean
35-
}
36-
37-
const EthPriceCard = ({ isLeftAlign = false, ...props }: EthPriceCardProps) => {
29+
const EthPriceCard = ({
30+
className,
31+
...props
32+
}: React.HTMLAttributes<HTMLDivElement>) => {
3833
const { locale } = useRouter()
3934
const { t } = useTranslation()
4035
const [state, setState] = useState<LoadingState<EthPriceState>>({
4136
loading: true,
4237
})
43-
const { flipForRtl } = useRtlFlip()
38+
const { isRtl } = useRtlFlip()
4439

4540
useEffect(() => {
4641
const fetchData = async () => {
@@ -100,93 +95,65 @@ const EthPriceCard = ({ isLeftAlign = false, ...props }: EthPriceCardProps) => {
10095
const change = hasData ? formatPercentage(state.data.percentChangeUSD) : ""
10196

10297
const tooltipContent = (
103-
<Box>
98+
<div>
10499
{t("data-provided-by")}{" "}
105100
<InlineLink href="https://www.coingecko.com/en/coins/ethereum">
106101
coingecko.com
107102
</InlineLink>
108-
</Box>
103+
</div>
109104
)
110105

111106
return (
112107
<Flex
113-
direction="column"
114-
align={isLeftAlign ? "flex-start" : "center"}
115-
justify="space-between"
116-
background={
108+
className={cn(
109+
"max-h-48 w-full max-w-[420px] flex-col items-center justify-between rounded border p-6",
117110
isNegativeChange
118-
? "priceCardBackgroundNegative"
119-
: "priceCardBackgroundPositive"
120-
}
121-
border="1px solid"
122-
borderColor={
123-
isNegativeChange ? "priceCardBorderNegative" : "priceCardBorder"
124-
}
125-
p={6}
126-
w="full"
127-
maxW="420px"
128-
maxH="192px"
129-
borderRadius="base"
111+
? "bg-gradient-to-b from-error/10 dark:border-error/50"
112+
: "bg-gradient-to-t from-success/20 dark:border-success/50",
113+
className
114+
)}
130115
{...props}
131116
>
132-
<Heading
133-
as="h4"
134-
color="text200"
135-
m={0}
136-
fontSize="sm"
137-
fontWeight="medium"
138-
lineHeight="140%"
139-
letterSpacing="0.04em"
140-
textTransform="uppercase"
141-
>
117+
<h4 className="m-0 flex items-center text-sm font-medium uppercase leading-xs tracking-wider">
142118
{t("eth-current-price")}
143119
<Tooltip content={tooltipContent}>
144-
<Box as="span" ms={2}>
145-
<Icon as={MdInfoOutline} boxSize="14px" />
146-
</Box>
120+
<MdInfoOutline className="ms-2 size-[14px]" />
147121
</Tooltip>
148-
</Heading>
122+
</h4>
149123

150-
<Box
151-
m={hasError ? "1rem 0" : 0}
152-
lineHeight="1.4"
153-
fontSize={hasError ? "md" : "5xl"}
154-
color={hasError ? "fail" : "text"}
124+
<div
125+
className={cn(
126+
"text-5xl leading-xs",
127+
hasError && "my-4 text-md text-error"
128+
)}
155129
>
156130
{price}
157-
</Box>
158-
<Flex
159-
w="full"
160-
align="center"
161-
justify={isLeftAlign ? "flex-start" : "center"}
162-
minH="33px" /* prevents jump when price loads*/
163-
>
164-
<Box
165-
fontSize="2xl"
166-
lineHeight="140%"
167-
me={4}
168-
color={isNegativeChange ? "fail300" : "success.base"}
131+
</div>
132+
133+
{/* min-h-[33px] prevents jump when price loads */}
134+
<Flex className="min-h-[33px] w-full items-center justify-center">
135+
<div
136+
className={cn(
137+
"me-4 text-2xl leading-xs",
138+
isNegativeChange ? "text-error" : "text-success"
139+
)}
169140
>
170-
<Text
171-
as="span"
172-
_after={{
173-
content: isNegativeChange ? '"↘"' : '"↗"',
174-
transform: flipForRtl,
175-
display: "inline-block",
176-
}}
141+
<span
142+
className={cn(
143+
isNegativeChange
144+
? "after:content-['↘']"
145+
: "after:content-['↗']",
146+
"after:inline-block",
147+
/* Cannot string-interpolate 'after:', using isRtl instead */
148+
isRtl ? "after:-scale-x-100" : ""
149+
)}
177150
>
178151
{change}
179-
</Text>
180-
</Box>
181-
<Box
182-
fontSize="sm"
183-
lineHeight="140%"
184-
letterSpacing="0.04em"
185-
textTransform="uppercase"
186-
color="text300"
187-
>
152+
</span>
153+
</div>
154+
<div className="text-sm uppercase leading-xs tracking-wider text-body-medium">
188155
({t("last-24-hrs")})
189-
</Box>
156+
</div>
190157
</Flex>
191158
</Flex>
192159
)

src/components/ui/alert.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const alertVariants = cva(
1717
success:
1818
"border-success bg-success-light [&_h6]:text-success [&_svg]:text-success text-gray-800",
1919
warning:
20-
"border-attention-outline bg-attention-light [&_h6]:text-attention [&_svg]:text-attention text-gray-800",
20+
"border-warning bg-warning-light [&_h6]:text-warning [&_svg]:text-warning text-gray-800",
2121
update:
2222
"bg-primary-low-contrast border-primary-high-contrast [&_h6]:text-primary-high-contrast [&_svg]:text-primary-high-contrast",
2323
},

src/pages/eth.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ const EthPage = () => {
393393
<Slogan>{t("page-eth-currency-for-future")}</Slogan>
394394
<Subtitle>{t("page-eth-is-money")}</Subtitle>
395395
<SubtitleTwo>{t("page-eth-currency-for-apps")}</SubtitleTwo>
396-
<EthPriceCard isLeftAlign={false} mb={8} />
396+
<EthPriceCard className="mb-8" />
397397
<ButtonLink href="/get-eth/">
398398
{t("page-eth-button-buy-eth")}
399399
</ButtonLink>

src/styles/colors.css

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
@layer base {
66
:root {
77
--white: 0, 0%, 100%; /* #FFFFFF */
8+
--black: 0, 0%, 0%; /* #000000 */
9+
810
--gray-50: 0, 0%, 97%; /* #F7F7F7 +1 */
911
--gray-100: 0, 0%, 93%; /* #EDEDED ±1 */ /* TODO: Confirm */
1012
--gray-150: 0, 0%, 87%; /* #DEDEDE ±1 */ /* TODO: Confirm */
@@ -17,7 +19,6 @@
1719
--gray-800: 0, 0%, 11%; /* #1B1B1B +2 */
1820
--gray-900: 0, 0%, 7%; /* #121212 ±1 */
1921
--gray-950: 0, 0%, 4%; /* #0A0A0A ±1 */
20-
--black: 0, 0%, 0%; /* #000000 */
2122

2223
--purple-50: 262, 100%, 96%; /* #F3ECFF */
2324
--purple-100: 263, 100%, 94%; /* #EDE2FF */
@@ -30,17 +31,6 @@
3031
--purple-800: 263, 77%, 31%; /* #41128B */
3132
--purple-900: 263, 86%, 15%; /* #1E0546 */
3233

33-
--pink-50: 325, 63%, 93%; /* #F8E0EE */
34-
--pink-100: 322, 78%, 87%; /* #F8C5E5 */
35-
--pink-200: 323, 100%, 85%; /* #FFB2E2 */
36-
--pink-300: 323, 100%, 83%; /* #FFA6DD */
37-
--pink-400: 323, 91%, 75%; /* #F986CD */
38-
--pink-500: 323, 100%, 66%; /* #FF51BC */
39-
--pink-600: 323, 93%, 51%; /* #F6109E */
40-
--pink-700: 323, 99%, 39%; /* #C7017B */
41-
--pink-800: 323, 87%, 29%; /* #8C0A5A */
42-
--pink-900: 323, 82%, 18%; /* #530836 */
43-
4434
--blue-50: 214, 100%, 99%; /* #F8FBFF */
4535
--blue-100: 217, 100%, 95%; /* #E8F1FF */
4636
--blue-200: 214, 86%, 89%; /* #CADFFB */
@@ -52,6 +42,17 @@
5242
--blue-800: 231, 53%, 29%; /* #232F71 */
5343
--blue-900: 217, 36%, 17%; /* #1B273A */
5444

45+
--pink-50: 325, 63%, 93%; /* #F8E0EE */
46+
--pink-100: 322, 78%, 87%; /* #F8C5E5 */
47+
--pink-200: 323, 100%, 85%; /* #FFB2E2 */
48+
--pink-300: 323, 100%, 83%; /* #FFA6DD */
49+
--pink-400: 323, 91%, 75%; /* #F986CD */
50+
--pink-500: 323, 100%, 66%; /* #FF51BC */
51+
--pink-600: 323, 93%, 51%; /* #F6109E */
52+
--pink-700: 323, 99%, 39%; /* #C7017B */
53+
--pink-800: 323, 87%, 29%; /* #8C0A5A */
54+
--pink-900: 323, 82%, 18%; /* #530836 */
55+
5556
--teal-50: 164, 100%, 98%; /* #F4FFFC */
5657
--teal-100: 164, 79%, 95%; /* #E6FCF6 */
5758
--teal-200: 163, 81%, 85%; /* #BBF8E7 */
@@ -63,24 +64,41 @@
6364
--teal-800: 163, 93%, 21%; /* #04674B */
6465
--teal-900: 162, 97%, 13%; /* #01422F */
6566

67+
--yellow-50: 48, 100%, 96%; /* #FFFBEB */
68+
--yellow-100: 48, 96%, 89%; /* #FEF3C7 */
69+
--yellow-200: 48, 97%, 77%; /* #FDE68A */
70+
--yellow-300: 46, 97%, 65%; /* #FCD34D */
71+
--yellow-400: 43, 96%, 56%; /* #FBBF24 */
72+
--yellow-500: 38, 92%, 50%; /* #F59E0B */
73+
--yellow-600: 32, 95%, 44%; /* #D97706 */
74+
--yellow-700: 26, 90%, 37%; /* #B45309 */
75+
--yellow-800: 23, 83%, 31%; /* #92400E */
76+
--yellow-900: 22, 78%, 26%; /* #78350F */
77+
78+
--red-50: 0, 86%, 97%; /* #fef2f2 */
79+
--red-100: 0, 93%, 94%; /* #fee2e2 */
80+
--red-200: 0, 96%, 89%; /* #fecaca */
81+
--red-300: 0, 94%, 82%; /* #fca5a5 */
82+
--red-400: 0, 91%, 71%; /* #f87171 */
83+
--red-500: 0, 84%, 60%; /* #ef4444 */
84+
--red-600: 0, 72%, 51%; /* #dc2626 */
85+
--red-700: 0, 74%, 42%; /* #b91c1c */
86+
--red-800: 0, 70%, 35%; /* #991b1b */
87+
--red-900: 0, 63%, 31%; /* #7f1d1d */
88+
89+
--green-50: 138, 76%, 97%; /* #F0FDF4 */
90+
--green-100: 141, 84%, 93%; /* #DCFCE7 */
91+
--green-200: 141, 79%, 85%; /* #BBF7D0 */
92+
--green-300: 142, 77%, 73%; /* #86EFAC */
93+
--green-400: 142, 69%, 58%; /* #4ADE80 */
94+
--green-500: 142, 71%, 45%; /* #22C55E */
95+
--green-600: 142, 76%, 36%; /* #16A34A */
96+
--green-700: 142, 72%, 29%; /* #15803D */
97+
--green-800: 143, 64%, 24%; /* #166534 */
98+
--green-900: 144, 61%, 20%; /* #14532D */
99+
66100
--orange-100: 30, 100%, 94%; /* #FFF0DB */
67-
--orange-200: 30, 100%, 82%; /* #FFD7A7 */
68-
--orange-300: 30, 98%, 70%; /* #FEB077 */
69-
--orange-400: 30, 97%, 58%; /* #FD8640 */
70-
--orange-500: 30, 95%, 51%; /* #FB610E */
71-
--orange-600: 20, 95%, 47%; /* #EC4A0A */
72-
--orange-700: 15, 90%, 39%; /* #C4350A */
73101
--orange-800: 10, 76%, 28%; /* #7D2711 */
74102
--orange-900: 20, 33%, 15%; /* #3A291D */
75-
76-
/* TODO: Update to new color theming */
77-
--red-100: 0, 75%, 88%; /* #f7c8c8 */
78-
--red-500: 0, 100%, 36%; /* #b80000 */
79-
--red-800: 0, 33%, 7%; /* #180c0c */
80-
--green-100: 138, 51%, 91%; /* #ddf4e4 */
81-
--green-500: 155, 84%, 24%; /* #0a7146 */
82-
--green-900: 140, 37%, 6%; /* #0a160e */
83-
--yellow-200: 47, 100%, 94%; /* #fff8df */
84-
--yellow-500: 42, 100%, 37%; /* #bd8400 */
85103
}
86104
}

src/styles/docsearch.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
.DocSearch-SearchBar form {
5959
--docsearch-searchbox-shadow: inset 0 0 0 1px
6060
theme(colors.primary.high-contrast);
61-
@apply bg-neutral py-3;
61+
@apply bg-body-inverse py-3;
6262
}
6363
.DocSearch-SearchBar label,
6464
.DocSearch-SearchBar input {

src/styles/global.css

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,26 +19,6 @@
1919
/* ! Deprecating primary-dark */
2020
--primary-dark: var(--blue-700);
2121

22-
--neutral: var(--white);
23-
24-
/* Complementary Set */
25-
--attention: var(--yellow-500);
26-
--attention-light: var(--yellow-200);
27-
--attention-outline: var(--attention);
28-
29-
/* ? Keep "error" or rename to "fail" ? */
30-
--error: var(--red-500);
31-
--error-light: var(--red-100);
32-
--error-outline: var(--error);
33-
/* ! Deprecating error-neutral */
34-
--error-neutral: var(--red-100);
35-
36-
--success: var(--green-500);
37-
--success-light: var(--green-100);
38-
--success-outline: var(--success);
39-
/* ! Deprecating success-neutral */
40-
--success-neutral: var(--green-100);
41-
4222
/* Misc sematics: light mode */
4323
--tooltip-shadow: rgba(0, 0, 0, 0.24);
4424
--switch-background: var(--gray-300);
@@ -78,22 +58,6 @@
7858
/* ! Deprecating primary-dark */
7959
--primary-dark: hsla(var(--orange-800));
8060

81-
/* ! Deprecating neutral */
82-
--neutral: var(--gray-900);
83-
84-
/* Complementary Set */
85-
--attention-outline: var(--attention-light);
86-
87-
--error: var(--red-500);
88-
--error-light: var(--red-100);
89-
--error-outline: var(--error);
90-
/* ! Deprecating error-neutral */
91-
--error-netural: var(--red-900);
92-
93-
--success-outline: var(--success-light);
94-
/* ! Deprecating success-neutral */
95-
--success-neutral: var(--green-900);
96-
9761
/* Misc sematics: dark mode */
9862
--tooltip-shadow: rgba(255, 255, 255, 0.24);
9963
--switch-background: rgba(255, 255, 255, 0.24);

0 commit comments

Comments
 (0)