Skip to content

Commit 0246a35

Browse files
authored
Merge pull request #13926 from ethereum/refactor-menu-colors
refactor: menu color tokens
2 parents 4148782 + d589a91 commit 0246a35

File tree

5 files changed

+48
-88
lines changed

5 files changed

+48
-88
lines changed

src/components/Nav/Menu/MenuContent.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,35 @@ export const navMenuVariants = tv({
1313
slots: {
1414
base: "text-body",
1515
item: "has-[button[data-state=open]]:rounded-s-md has-[button[data-state=open]]:rounded-e-none has-[button[data-state=open]]:-me-2 has-[button[data-state=open]]:pe-2",
16-
link: "group w-full relative py-4 hover:text-menu-active [&:hover_p]:text-menu-active focus-visible:text-menu-active [&:focus-visible_p]:text-menu-active hover:outline-0 rounded-md hover:shadow-none focus-visible:outline-0 focus-visible:rounded-md focus-visible:shadow-none",
16+
link: "group w-full relative py-4 hover:text-primary [&:hover_p]:text-primary focus-visible:text-primary [&:focus-visible_p]:text-primary hover:outline-0 rounded-md hover:shadow-none focus-visible:outline-0 focus-visible:rounded-md focus-visible:shadow-none",
1717
linkSubtext: "text-sm",
1818
submenu: "grid h-full w-full grid-cols-1",
1919
},
2020
variants: {
2121
level: {
2222
1: {
23-
submenu: "grid-cols-3 bg-menu-1-background",
24-
item: "has-[button[data-state=open]]:bg-menu-1-active-background",
25-
link: "data-[active=true]:bg-menu-1-active-background hover:bg-menu-1-active-background focus-visible:bg-menu-1-active-background",
26-
linkSubtext: "group-[data-active=true]:text-menu-1-subtext",
23+
submenu: "grid-cols-3 bg-background",
24+
item: "has-[button[data-state=open]]:bg-background-low",
25+
link: "data-[active=true]:bg-background-low hover:bg-background-low focus-visible:bg-background-low",
26+
linkSubtext: "group-[data-active=true]:text-body-menu",
2727
},
2828
2: {
29-
submenu: "grid-cols-2 bg-menu-2-background",
30-
item: "has-[button[data-state=open]]:bg-menu-2-active-background",
31-
link: "hover:bg-menu-2-active-background focus-visible:bg-menu-2-active-background data-[active=true]:bg-menu-2-active-background",
32-
linkSubtext: "group-[data-active=true]:text-menu-2-subtext",
29+
submenu: "grid-cols-2 bg-background-low",
30+
item: "has-[button[data-state=open]]:bg-background-medium",
31+
link: "hover:bg-background-medium focus-visible:bg-background-medium data-[active=true]:bg-background-medium",
32+
linkSubtext: "group-[data-active=true]:text-body-menu-low",
3333
},
3434
3: {
35-
submenu: "grid-cols-1 bg-menu-3-background",
36-
item: "has-[button[data-state=open]]:bg-menu-3-active-background",
37-
link: "data-[active=true]:bg-menu-3-active-background hover:bg-menu-3-active-background",
38-
linkSubtext: "group-[data-active=true]:text-menu-3-subtext",
35+
submenu: "grid-cols-1 bg-background-medium",
36+
item: "has-[button[data-state=open]]:bg-background-low`",
37+
link: "data-[active=true]:bg-background-low hover:bg-background-low",
38+
linkSubtext: "group-[data-active=true]:text-body-menu-medium",
3939
},
4040
4: {
41-
submenu: "grid-cols-1 bg-menu-4-background",
42-
item: "has-[button[data-state=open]]:bg-menu-4-active-background",
43-
link: "data-[active=true]:bg-menu-4-active-background hover:bg-menu-4-active-background",
44-
linkSubtext: "group-[data-active=true]:text-menu-4-subtext",
41+
submenu: "grid-cols-1 bg-background-high",
42+
item: "has-[button[data-state=open]]:bg-background-medium",
43+
link: "data-[active=true]:bg-background-medium hover:bg-background-medium",
44+
linkSubtext: "group-[data-active=true]:text-body-menu-high",
4545
},
4646
},
4747
},
@@ -62,7 +62,7 @@ const MenuContent = ({ items, isOpen, sections }: MenuContentProps) => {
6262
<Content asChild>
6363
<motion.div
6464
className={cn(
65-
"absolute inset-x-0 top-19 border border-body-light bg-menu-1-background shadow-md",
65+
"absolute inset-x-0 top-19 border border-body-light bg-background shadow-md",
6666
base()
6767
)}
6868
variants={containerVariants}

src/components/Nav/Mobile/LvlAccordion.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ const subtextColorPerLevel = {
3333
}
3434

3535
const backgroundColorPerLevel = {
36-
1: "bg-menu-1-background",
37-
2: "bg-menu-2-background",
38-
3: "bg-menu-3-background",
39-
4: "bg-menu-4-background",
36+
1: "bg-background",
37+
2: "bg-background-low",
38+
3: "bg-background-medium",
39+
4: "bg-background-high",
4040
}
4141

4242
const LvlAccordion = ({

src/components/Nav/Mobile/MenuBody.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ const MenuBody = ({ linkSections, onToggle }: MenuBodyProps) => {
6464

6565
<AccordionContent
6666
className={cn(
67-
"mt-0 bg-menu-2-background p-0",
67+
"mt-0 bg-background-low p-0",
6868
isExpanded && "border-t border-disabled"
6969
)}
7070
>

src/styles/semantic-tokens.css

Lines changed: 16 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,18 @@
1010
--body-light: var(--gray-200);
1111
--body-inverse: var(--white);
1212

13+
--body-menu: var(--gray-400);
14+
--body-menu-low: var(--gray-400);
15+
--body-menu-medium: var(--gray-500);
16+
--body-menu-high: var(--gray-700);
17+
1318
--disabled: var(--gray-400);
1419

1520
--background: var(--white);
1621
--background-highlight: var(--gray-50);
17-
--background-medium: var(--gray-200); /* TODO: VERIFY */
22+
--background-low: var(--gray-100);
23+
--background-medium: var(--gray-200);
24+
--background-high: var(--gray-300);
1825

1926
/* TODO: Add border color tokens to match DS */
2027

@@ -101,24 +108,6 @@
101108
--shadow-window-box-3: 0px 32px 24px -6px hsla(var(--purple-800), var(--shadow-window-box-3-opacity));
102109
--shadow-window-box-4: 0px 40px 40px -12px hsla(var(--purple-700), var(--shadow-window-box-4-opacity));
103110
--shadow-window-box-5: 0px -64px 120px 80px hsla(var(--purple-100), var(--shadow-window-box-5-opacity));
104-
105-
/* Menu colors */
106-
--menu: var(--body);
107-
--menu-hover: var(--gray-200);
108-
--menu-active: var(--primary);
109-
--menu-active-background: var(--primary-high-contrast);
110-
--menu-1-subtext: var(--gray-400);
111-
--menu-1-background: var(--white);
112-
--menu-1-active-background: var(--gray-150);
113-
--menu-2-subtext: var(--gray-400);
114-
--menu-2-background: var(--gray-150);
115-
--menu-2-active-background: var(--gray-200);
116-
--menu-3-subtext: var(--gray-500);
117-
--menu-3-background: var(--gray-200);
118-
--menu-3-active-background: var(--gray-100);
119-
--menu-4-subtext: var(--gray-700);
120-
--menu-4-background: var(--gray-300);
121-
--menu-4-active-background: var(--gray-200);
122111
}
123112

124113
/* Dark mode token declarations */
@@ -128,11 +117,18 @@
128117
--body-light: var(--gray-600);
129118
--body-inverse: var(--black);
130119

120+
--body-menu: var(--gray-400);
121+
--body-menu-low: var(--gray-300);
122+
--body-menu-medium: var(--gray-300);
123+
--body-menu-high: var(--gray-300);
124+
131125
--disabled: var(--gray-500);
132126

133127
--background: var(--black);
134128
--background-highlight: var(--gray-900);
135-
--background-medium: var(--gray-950); /* TODO: VERIFY */
129+
--background-low: var(--gray-700);
130+
--background-medium: var(--gray-600);
131+
--background-high: var(--gray-800);
136132

137133
/* TODO: Add border color tokens to match DS */
138134

@@ -186,23 +182,5 @@
186182
--shadow-window-box-3-opacity: 0.16;
187183
--shadow-window-box-4-opacity: 0.06;
188184
--shadow-window-box-5-opacity: 0.06;
189-
190-
/* Menu colors */
191-
--menu: var(--body);
192-
--menu-hover: var(--gray-200);
193-
--menu-active: var(--primary);
194-
--menu-active-background: var(--primary-high-contrast);
195-
--menu-1-subtext: var(--gray-400);
196-
--menu-1-background: var(--black);
197-
--menu-1-active-background: var(--gray-700);
198-
--menu-2-subtext: var(--gray-300);
199-
--menu-2-background: var(--gray-700);
200-
--menu-2-active-background: var(--gray-600);
201-
--menu-3-subtext: var(--gray-300);
202-
--menu-3-background: var(--gray-600);
203-
--menu-3-active-background: var(--gray-700);
204-
--menu-4-subtext: var(--gray-300);
205-
--menu-4-background: var(--gray-700);
206-
--menu-4-active-background: var(--gray-800);
207185
}
208186
}

tailwind.config.ts

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,22 @@ const config = {
136136
medium: "hsla(var(--body-medium))",
137137
light: "hsla(var(--body-light))",
138138
inverse: "hsla(var(--body-inverse))",
139+
menu: {
140+
DEFAULT: "hsla(var(--body-menu))",
141+
low: "hsla(var(--body-menu-low))",
142+
medium: "hsla(var(--body-menu-medium))",
143+
high: "hsla(var(--body-menu-high))",
144+
},
139145
},
140146

141147
disabled: "hsla(var(--disabled))",
142148

143149
background: {
144150
DEFAULT: "hsla(var(--background))",
145151
highlight: "hsla(var(--background-highlight))",
152+
low: "hsla(var(--background-low))",
153+
medium: "hsla(var(--background-medium))",
154+
high: "hsla(var(--background-high))",
146155
},
147156

148157
// TODO: Add border color tokens to match DS
@@ -188,33 +197,6 @@ const config = {
188197
light: "hsla(var(--warning-light))",
189198
},
190199

191-
menu: {
192-
DEFAULT: "hsla(var(--menu))",
193-
hover: "hsla(var(--menu-hover))",
194-
active: "hsla(var(--menu-active))",
195-
"active-background": "hsla(var(--menu-active-background))",
196-
1: {
197-
subtext: "hsla(var(--menu-1-subtext))",
198-
background: "hsla(var(--menu-1-background))",
199-
"active-background": "hsla(var(--menu-1-active-background))",
200-
},
201-
2: {
202-
subtext: "hsla(var(--menu-2-subtext))",
203-
background: "hsla(var(--menu-2-background))",
204-
"active-background": "hsla(var(--menu-2-active-background))",
205-
},
206-
3: {
207-
subtext: "hsla(var(--menu-3-subtext))",
208-
background: "hsla(var(--menu-3-background))",
209-
"active-background": "hsla(var(--menu-3-active-background))",
210-
},
211-
4: {
212-
subtext: "hsla(var(--menu-4-subtext))",
213-
background: "hsla(var(--menu-4-background))",
214-
"active-background": "hsla(var(--menu-4-active-background))",
215-
},
216-
},
217-
218200
/** @deprecated */
219201
"switch-background": "hsla(var(--switch-background))", // TODO: Migrate
220202
"tooltip-shadow": "var(--tooltip-shadow)",

0 commit comments

Comments
 (0)