Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design system color theming updates #13821

Merged
merged 35 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
f12c471
deprecate: inverted token
wackerow Sep 6, 2024
9313c22
theme: update gray palette with lum margin
wackerow Sep 6, 2024
4f7b6e6
fix: contrast with lang picker menu selected bg
wackerow Sep 6, 2024
9255c63
fix: progress bar component and colors for quizzes
wackerow Sep 7, 2024
128a41d
chore: update button-hover color to DS
wackerow Sep 7, 2024
038eaad
feat: update all button variants to match DS
wackerow Sep 7, 2024
71d7b3c
fix: button variants to use latest updates
wackerow Sep 7, 2024
bbcf48c
feat: sync Chakra-UI button variant styles to DS
wackerow Sep 7, 2024
02d9a3f
patch: primary.hover _dark value
wackerow Sep 7, 2024
49d0a37
Merge branch 'colors-1' into colors-1-button-upgrade
wackerow Sep 7, 2024
5cdb1c0
fix: dark chakra background color
wackerow Sep 8, 2024
46cc6fb
feat: migrate nav element, add border-b
wackerow Sep 8, 2024
0e92088
fix: rm focus styling
wackerow Sep 8, 2024
5d551cb
fix: nav button styling consistency
wackerow Sep 8, 2024
1da596b
chore: use "warning" naming per design system
wackerow Sep 8, 2024
93a2e4e
theme: update color palettes to new theming
wackerow Sep 8, 2024
4e757d9
theme: update semantic tokens
wackerow Sep 8, 2024
0aa9f79
theme: update tailwind config with latest tokens
wackerow Sep 8, 2024
dea38fc
refactor: update use of deprecated tokens
wackerow Sep 8, 2024
c9e1ca6
chore: remove deprecated css variables from global
wackerow Sep 8, 2024
0a32fb6
refactor: EthPriceCard to tailwind
wackerow Sep 8, 2024
069f28c
theme: deprecate priceCard tokens from src/theme
wackerow Sep 8, 2024
8408561
fix: apply isSecondary to BentoCard button
wackerow Sep 9, 2024
cf38141
fix: button-hover shadow color
wackerow Sep 9, 2024
488f32e
deprecate: unused shadow tokens
wackerow Sep 9, 2024
6f724bd
chore: persist gradient for bg in dark mode
wackerow Sep 9, 2024
b335475
Merge pull request #13822 from ethereum/colors-1-button-upgrade
pettinarip Sep 10, 2024
5de36e8
Merge pull request #13825 from ethereum/colors-1-nav
pettinarip Sep 10, 2024
fe91618
Merge branch 'dev' into colors-1
pettinarip Sep 10, 2024
510d1a1
Merge pull request #13828 from ethereum/c1-pricecard
pettinarip Sep 10, 2024
9fe7aaa
fix: close button styling on DismissableBanner
wackerow Sep 10, 2024
508be8f
Merge branch 'dev' into colors-1
wackerow Sep 10, 2024
5636fb6
Merge branch 'dev' into colors-1
wackerow Sep 10, 2024
08b816b
rm: unused and unavaiable styling
wackerow Sep 10, 2024
594cddc
fix: declare group; align component name
wackerow Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 31 additions & 21 deletions src/@chakra-ui/components/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,40 @@ import { defineStyle, defineStyleConfig } from "@chakra-ui/react"
const ICON_SELECTOR = "& svg"

const baseStyle = defineStyle({
// Sizing and positioning classes:
borderRadius: "base",
border: "1px",
color: "primary.base",
fontWeight: "normal",
lineHeight: "1.6",
transitionProperty: "common",
transitionDuration: "normal",
whiteSpace: "normal",
p: "unset",
// Base default styling is "outline" pattern, primary color for text, border matches, no bg
borderColor: "currentColor",
color: "primary.base",
// Hover: Default hover adds box-shadow, text (border) to --primary-hover
_hover: {
color: "primary.hover",
boxShadow: "buttonHover",
},
// Focus: Add 4px outline to all buttons, --primary-hover
_focusVisible: {
outline: "4px solid",
outlineColor: "primary.hover",
outlineOffset: -1,
},
// Active: text (border) to --primary-hover instead of primary, hide shadow
_active: {
color: "primary.hover",
boxShadow: "none",
},
// Disabled: Pointer events none, text (border) to --disabled
_disabled: {
color: "disabled",
pointerEvents: "none",
},
_hover: {
color: "primary.hover",
},
// isSecondary: Switch text (border) to --body instead of --primary
"&[data-secondary='true']": {
color: "body.base",
},
Expand All @@ -41,42 +54,39 @@ const baseStyle = defineStyle({
textDecoration: "none",
},
},
[ICON_SELECTOR]: {
flexShrink: 0,
},
})

const variantSolid = defineStyle({
color: "white",
bg: "primary.action",
borderColor: "transparent",
_disabled: {
bg: "disabled",
color: "background.base",
},
borderColor: "transparent !important",
_hover: {
color: "white",
color: "white !important",
bg: "primary.actionHover",
boxShadow: "buttonHover",
},
_active: {
boxShadow: "none",
},
})

const variantOutline = defineStyle({
_hover: {
boxShadow: "buttonHover",
bg: "primary.actionHover",
},
_active: {
boxShadow: "none",
_disabled: {
bg: "disabled",
color: "background.base",
},
})

const variantOutline = defineStyle({}) // "outline" is base styling above

const variantGhost = {
borderColor: "transparent",
_hover: { shadow: "none" },
}

const variantLink = defineStyle({
borderColor: "transparent",
fontWeight: 700,
// fontWeight: 700, // TODO: Not in DS; confirm then remove
_hover: { shadow: "none" },
textDecor: "underline",
py: 0,
px: 1,
Expand Down
3 changes: 1 addition & 2 deletions src/@chakra-ui/foundations/shadows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ const shadows = {
gridBlueBowShadow: "8px 8px 0px 0px var(--eth-colors-gridBlue)",

// * Part of new DS
// TODO: From current theme. Deprecate for 'buttonHover'
primary: "4px 4px 0px 0px var(--eth-colors-primary-light)",
// TODO: Deprecate buttonHover when all buttons migrated to tailwind
buttonHover: "4px 4px 0 0 var(--eth-colors-primary-lowContrast)",
tooltip: "0 0 16px var(--eth-colors-tooltipShadow)",
}
Expand Down
6 changes: 2 additions & 4 deletions src/@chakra-ui/semanticTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const semanticTokens = {
base: { _light: "purple.600", _dark: "purple.400" },
highContrast: { _light: "purple.800", _dark: "purple.200" },
lowContrast: { _light: "purple.100", _dark: "purple.900" },
hover: { _light: "purple.500", _dark: "purple.500" },
hover: { _light: "purple.500", _dark: "purple.300" },
visited: { _light: "purple.700", _dark: "purple.300" },
action: { _light: "purple.600", _dark: "purple.600" },
actionHover: { _light: "purple.500", _dark: "purple.500" },
Expand All @@ -55,11 +55,9 @@ const semanticTokens = {
base: { _light: "gray.800", _dark: "gray.100" },
medium: { _light: "gray.500", _dark: "gray.400" },
light: { _light: "gray.200", _dark: "gray.600" },
// ! Deprecating body.inverted
inverted: { _light: "gray.100", _dark: "gray.800" },
},
background: {
base: { _light: "white", _dark: "gray.950" },
base: { _light: "white", _dark: "black" },
highlight: { _light: "gray.100", _dark: "gray.900" },
},
disabled: { _light: "gray.400", _dark: "gray.500" },
Expand Down
2 changes: 1 addition & 1 deletion src/@chakra-ui/stories/Colors.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export const SemanticScheme: StoryObj = {
] as const
const deprecatedTokens: Record<(typeof tokenNames)[number], string[]> = {
primary: ["light", "dark", "pressed"],
body: ["inverted"],
body: [],
background: [],
disabled: [],
success: ["neutral", "outline"],
Expand Down
8 changes: 5 additions & 3 deletions src/components/Banners/DismissableBanner/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { useEffect, useState } from "react"
import { useTranslation } from "next-i18next"
import { MdClose } from "react-icons/md"

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

useEffect(() => {
Expand All @@ -33,10 +35,10 @@ const DismissableBanner = ({
<BannerNotification shouldShow={show} className={cn("gap-8", className)}>
<Center className="ms-auto">{children}</Center>
<Button
className="ms-auto"
className="ms-auto hover:shadow-none"
onClick={onClose}
aria-label="Close Banner"
variant="ghost"
aria-label={t("close")}
size="sm"
>
<MdClose />
</Button>
Expand Down
129 changes: 48 additions & 81 deletions src/components/EthPriceCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ import { useEffect, useState } from "react"
import { useRouter } from "next/router"
import { useTranslation } from "next-i18next"
import { MdInfoOutline } from "react-icons/md"
import {
Box,
Flex,
type FlexProps,
Heading,
Icon,
Text,
} from "@chakra-ui/react"

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

import InlineLink from "@/components/Link"
import Tooltip from "@/components/Tooltip"
import InlineLink from "@/components/ui/Link"

import { cn } from "@/lib/utils/cn"

import { Flex } from "./ui/flex"

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

Expand All @@ -30,17 +26,16 @@ type EthPriceState = {
percentChangeUSD: number
}

export type EthPriceCardProps = FlexProps & {
isLeftAlign?: boolean
}

const EthPriceCard = ({ isLeftAlign = false, ...props }: EthPriceCardProps) => {
const EthPriceCard = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => {
const { locale } = useRouter()
const { t } = useTranslation()
const [state, setState] = useState<LoadingState<EthPriceState>>({
loading: true,
})
const { flipForRtl } = useRtlFlip()
const { isRtl } = useRtlFlip()

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

const tooltipContent = (
<Box>
<div>
{t("data-provided-by")}{" "}
<InlineLink href="https://www.coingecko.com/en/coins/ethereum">
coingecko.com
</InlineLink>
</Box>
</div>
)

return (
<Flex
direction="column"
align={isLeftAlign ? "flex-start" : "center"}
justify="space-between"
background={
className={cn(
"max-h-48 w-full max-w-[420px] flex-col items-center justify-between rounded border p-6",
isNegativeChange
? "priceCardBackgroundNegative"
: "priceCardBackgroundPositive"
}
border="1px solid"
borderColor={
isNegativeChange ? "priceCardBorderNegative" : "priceCardBorder"
}
p={6}
w="full"
maxW="420px"
maxH="192px"
borderRadius="base"
? "bg-gradient-to-b from-error/10 dark:border-error/50"
: "bg-gradient-to-t from-success/20 dark:border-success/50",
className
)}
{...props}
>
<Heading
as="h4"
color="text200"
m={0}
fontSize="sm"
fontWeight="medium"
lineHeight="140%"
letterSpacing="0.04em"
textTransform="uppercase"
>
<h4 className="m-0 flex items-center text-sm font-medium uppercase leading-xs tracking-wider">
{t("eth-current-price")}
<Tooltip content={tooltipContent}>
<Box as="span" ms={2}>
<Icon as={MdInfoOutline} boxSize="14px" />
</Box>
<MdInfoOutline className="ms-2 size-[14px]" />
</Tooltip>
</Heading>
</h4>

<Box
m={hasError ? "1rem 0" : 0}
lineHeight="1.4"
fontSize={hasError ? "md" : "5xl"}
color={hasError ? "fail" : "text"}
<div
className={cn(
"text-5xl leading-xs",
hasError && "my-4 text-md text-error"
)}
>
{price}
</Box>
<Flex
w="full"
align="center"
justify={isLeftAlign ? "flex-start" : "center"}
minH="33px" /* prevents jump when price loads*/
>
<Box
fontSize="2xl"
lineHeight="140%"
me={4}
color={isNegativeChange ? "fail300" : "success.base"}
</div>

{/* min-h-[33px] prevents jump when price loads */}
<Flex className="min-h-[33px] w-full items-center justify-center">
<div
className={cn(
"me-4 text-2xl leading-xs",
isNegativeChange ? "text-error" : "text-success"
)}
>
<Text
as="span"
_after={{
content: isNegativeChange ? '"↘"' : '"↗"',
transform: flipForRtl,
display: "inline-block",
}}
<span
className={cn(
isNegativeChange
? "after:content-['↘']"
: "after:content-['↗']",
"after:inline-block",
/* Cannot string-interpolate 'after:', using isRtl instead */
isRtl ? "after:-scale-x-100" : ""
)}
>
{change}
</Text>
</Box>
<Box
fontSize="sm"
lineHeight="140%"
letterSpacing="0.04em"
textTransform="uppercase"
color="text300"
>
</span>
</div>
<div className="text-sm uppercase leading-xs tracking-wider text-body-medium">
({t("last-24-hrs")})
</Box>
</div>
</Flex>
</Flex>
)
Expand Down
12 changes: 3 additions & 9 deletions src/components/FeedbackCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,23 +75,17 @@ const FeedbackCard = ({ prompt, isArticle, ...props }: FeedbackCardProps) => {
<div className="flex gap-4">
{!feedbackSubmitted ? (
<>
<Button
variant="outline-color"
onClick={() => handleSubmit(true)}
>
<Button variant="outline" onClick={() => handleSubmit(true)}>
<FeedbackThumbsUpIcon className="h-6 w-6" />
{t("yes")}
</Button>
<Button
variant="outline-color"
onClick={() => handleSubmit(false)}
>
<Button variant="outline" onClick={() => handleSubmit(false)}>
<FeedbackThumbsUpIcon className="-scale-y-100" />
{t("no")}
</Button>
</>
) : (
<Button variant="outline-color" onClick={handleSurveyOpen}>
<Button variant="outline" onClick={handleSurveyOpen}>
{t("feedback-widget-thank-you-cta")}
</Button>
)}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Homepage/BentoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const BentoCard = ({
{title}
</CardTitle>
<p className="mb-8 text-md">{children}</p>
<ButtonLink href={href} variant="outline">
<ButtonLink href={href} variant="outline" isSecondary>
{action} <ChevronNext />
</ButtonLink>
</div>
Expand Down
Loading
Loading