Skip to content

Commit edd1283

Browse files
authored
Merge pull request #13821 from ethereum/colors-1
Design system color theming updates
2 parents 70c1d2c + 594cddc commit edd1283

File tree

24 files changed

+286
-281
lines changed

24 files changed

+286
-281
lines changed

src/@chakra-ui/components/Button.ts

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,27 +11,40 @@ import { defineStyle, defineStyleConfig } from "@chakra-ui/react"
1111
const ICON_SELECTOR = "& svg"
1212

1313
const baseStyle = defineStyle({
14+
// Sizing and positioning classes:
1415
borderRadius: "base",
1516
border: "1px",
16-
color: "primary.base",
1717
fontWeight: "normal",
1818
lineHeight: "1.6",
1919
transitionProperty: "common",
2020
transitionDuration: "normal",
2121
whiteSpace: "normal",
2222
p: "unset",
23+
// Base default styling is "outline" pattern, primary color for text, border matches, no bg
24+
borderColor: "currentColor",
25+
color: "primary.base",
26+
// Hover: Default hover adds box-shadow, text (border) to --primary-hover
27+
_hover: {
28+
color: "primary.hover",
29+
boxShadow: "buttonHover",
30+
},
31+
// Focus: Add 4px outline to all buttons, --primary-hover
2332
_focusVisible: {
2433
outline: "4px solid",
2534
outlineColor: "primary.hover",
2635
outlineOffset: -1,
2736
},
37+
// Active: text (border) to --primary-hover instead of primary, hide shadow
38+
_active: {
39+
color: "primary.hover",
40+
boxShadow: "none",
41+
},
42+
// Disabled: Pointer events none, text (border) to --disabled
2843
_disabled: {
2944
color: "disabled",
3045
pointerEvents: "none",
3146
},
32-
_hover: {
33-
color: "primary.hover",
34-
},
47+
// isSecondary: Switch text (border) to --body instead of --primary
3548
"&[data-secondary='true']": {
3649
color: "body.base",
3750
},
@@ -41,42 +54,39 @@ const baseStyle = defineStyle({
4154
textDecoration: "none",
4255
},
4356
},
57+
[ICON_SELECTOR]: {
58+
flexShrink: 0,
59+
},
4460
})
4561

4662
const variantSolid = defineStyle({
4763
color: "white",
4864
bg: "primary.action",
49-
borderColor: "transparent",
50-
_disabled: {
51-
bg: "disabled",
52-
color: "background.base",
53-
},
65+
borderColor: "transparent !important",
5466
_hover: {
55-
color: "white",
67+
color: "white !important",
5668
bg: "primary.actionHover",
57-
boxShadow: "buttonHover",
5869
},
5970
_active: {
60-
boxShadow: "none",
61-
},
62-
})
63-
64-
const variantOutline = defineStyle({
65-
_hover: {
66-
boxShadow: "buttonHover",
71+
bg: "primary.actionHover",
6772
},
68-
_active: {
69-
boxShadow: "none",
73+
_disabled: {
74+
bg: "disabled",
75+
color: "background.base",
7076
},
7177
})
7278

79+
const variantOutline = defineStyle({}) // "outline" is base styling above
80+
7381
const variantGhost = {
7482
borderColor: "transparent",
83+
_hover: { shadow: "none" },
7584
}
7685

7786
const variantLink = defineStyle({
7887
borderColor: "transparent",
79-
fontWeight: 700,
88+
// fontWeight: 700, // TODO: Not in DS; confirm then remove
89+
_hover: { shadow: "none" },
8090
textDecor: "underline",
8191
py: 0,
8292
px: 1,

src/@chakra-ui/foundations/shadows.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ const shadows = {
2020
gridBlueBowShadow: "8px 8px 0px 0px var(--eth-colors-gridBlue)",
2121

2222
// * Part of new DS
23-
// TODO: From current theme. Deprecate for 'buttonHover'
24-
primary: "4px 4px 0px 0px var(--eth-colors-primary-light)",
23+
// TODO: Deprecate buttonHover when all buttons migrated to tailwind
2524
buttonHover: "4px 4px 0 0 var(--eth-colors-primary-lowContrast)",
2625
tooltip: "0 0 16px var(--eth-colors-tooltipShadow)",
2726
}

src/@chakra-ui/semanticTokens.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const semanticTokens = {
4040
base: { _light: "purple.600", _dark: "purple.400" },
4141
highContrast: { _light: "purple.800", _dark: "purple.200" },
4242
lowContrast: { _light: "purple.100", _dark: "purple.900" },
43-
hover: { _light: "purple.500", _dark: "purple.500" },
43+
hover: { _light: "purple.500", _dark: "purple.300" },
4444
visited: { _light: "purple.700", _dark: "purple.300" },
4545
action: { _light: "purple.600", _dark: "purple.600" },
4646
actionHover: { _light: "purple.500", _dark: "purple.500" },
@@ -55,11 +55,9 @@ const semanticTokens = {
5555
base: { _light: "gray.800", _dark: "gray.100" },
5656
medium: { _light: "gray.500", _dark: "gray.400" },
5757
light: { _light: "gray.200", _dark: "gray.600" },
58-
// ! Deprecating body.inverted
59-
inverted: { _light: "gray.100", _dark: "gray.800" },
6058
},
6159
background: {
62-
base: { _light: "white", _dark: "gray.950" },
60+
base: { _light: "white", _dark: "black" },
6361
highlight: { _light: "gray.100", _dark: "gray.900" },
6462
},
6563
disabled: { _light: "gray.400", _dark: "gray.500" },

src/@chakra-ui/stories/Colors.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export const SemanticScheme: StoryObj = {
113113
] as const
114114
const deprecatedTokens: Record<(typeof tokenNames)[number], string[]> = {
115115
primary: ["light", "dark", "pressed"],
116-
body: ["inverted"],
116+
body: [],
117117
background: [],
118118
disabled: [],
119119
success: ["neutral", "outline"],

src/components/Banners/DismissableBanner/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { useEffect, useState } from "react"
2+
import { useTranslation } from "next-i18next"
23
import { MdClose } from "react-icons/md"
34

45
import { Button } from "@/components/ui/buttons/Button"
@@ -17,6 +18,7 @@ const DismissableBanner = ({
1718
storageKey,
1819
className,
1920
}: DismissableBannerProps) => {
21+
const { t } = useTranslation("common")
2022
const [show, setShow] = useState<boolean>(false)
2123

2224
useEffect(() => {
@@ -33,10 +35,10 @@ const DismissableBanner = ({
3335
<BannerNotification shouldShow={show} className={cn("gap-8", className)}>
3436
<Center className="ms-auto">{children}</Center>
3537
<Button
36-
className="ms-auto"
38+
className="ms-auto hover:shadow-none"
3739
onClick={onClose}
38-
aria-label="Close Banner"
39-
variant="ghost"
40+
aria-label={t("close")}
41+
size="sm"
4042
>
4143
<MdClose />
4244
</Button>

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/FeedbackCard.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,17 @@ const FeedbackCard = ({ prompt, isArticle, ...props }: FeedbackCardProps) => {
7575
<div className="flex gap-4">
7676
{!feedbackSubmitted ? (
7777
<>
78-
<Button
79-
variant="outline-color"
80-
onClick={() => handleSubmit(true)}
81-
>
78+
<Button variant="outline" onClick={() => handleSubmit(true)}>
8279
<FeedbackThumbsUpIcon className="h-6 w-6" />
8380
{t("yes")}
8481
</Button>
85-
<Button
86-
variant="outline-color"
87-
onClick={() => handleSubmit(false)}
88-
>
82+
<Button variant="outline" onClick={() => handleSubmit(false)}>
8983
<FeedbackThumbsUpIcon className="-scale-y-100" />
9084
{t("no")}
9185
</Button>
9286
</>
9387
) : (
94-
<Button variant="outline-color" onClick={handleSurveyOpen}>
88+
<Button variant="outline" onClick={handleSurveyOpen}>
9589
{t("feedback-widget-thank-you-cta")}
9690
</Button>
9791
)}

src/components/Homepage/BentoCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const BentoCard = ({
4343
{title}
4444
</CardTitle>
4545
<p className="mb-8 text-md">{children}</p>
46-
<ButtonLink href={href} variant="outline">
46+
<ButtonLink href={href} variant="outline" isSecondary>
4747
{action} <ChevronNext />
4848
</ButtonLink>
4949
</div>

0 commit comments

Comments
 (0)