Skip to content

Commit 72575b0

Browse files
committed
fix: palette hover text contrast
Replace inline platformColor styles with CSS custom properties and fix hover text color regression.
1 parent 6e7adbb commit 72575b0

3 files changed

Lines changed: 71 additions & 30 deletions

File tree

css/activities.css

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ table {
12101210
color: var(--color-text-inverse);
12111211
font-size: 1.1em;
12121212
text-align: center;
1213-
height: 55px;
12141213
}
12151214

12161215
.close-button {
@@ -2050,9 +2049,20 @@ table {
20502049
border: 0;
20512050
}
20522051

2053-
#palette th:hover,
2054-
#palette tr:hover {
2055-
background-color: rgba(211, 211, 211, 0.7);
2052+
#palette tr.palette-row {
2053+
background-color: var(--color-palette-bg);
2054+
}
2055+
2056+
#palette tr.palette-row .palette-row-label {
2057+
color: var(--color-palette-text);
2058+
}
2059+
2060+
#palette tr.palette-row.palette-row--hover {
2061+
background-color: var(--color-palette-hover-bg);
2062+
}
2063+
2064+
#palette tr.palette-row.palette-row--hover .palette-row-label {
2065+
color: var(--color-palette-text-hover);
20562066
}
20572067

20582068
#printText {

css/tokens.css

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
/* =========================================================================
88
Base Colors (Light Theme Default)
99
========================================================================= */
10+
--color-palette-bg: #ffffff;
11+
--color-palette-text: #666666;
12+
--color-palette-hover-bg: #e0e0e0;
13+
--color-palette-text-hover: #000000;
14+
1015
--color-bg-primary: #ffffff;
1116
--color-bg-secondary: #f3f4f6;
1217
--color-bg-tertiary: #e5e7eb;
@@ -41,12 +46,18 @@
4146
/* =========================================================================
4247
Spacing (Base 4px scale)
4348
========================================================================= */
44-
--spacing-xs: 0.25rem; /* 4px */
45-
--spacing-sm: 0.5rem; /* 8px */
46-
--spacing-md: 1rem; /* 16px */
47-
--spacing-lg: 1.5rem; /* 24px */
48-
--spacing-xl: 2rem; /* 32px */
49-
--spacing-2xl: 3rem; /* 48px */
49+
--spacing-xs: 0.25rem;
50+
/* 4px */
51+
--spacing-sm: 0.5rem;
52+
/* 8px */
53+
--spacing-md: 1rem;
54+
/* 16px */
55+
--spacing-lg: 1.5rem;
56+
/* 24px */
57+
--spacing-xl: 2rem;
58+
/* 32px */
59+
--spacing-2xl: 3rem;
60+
/* 48px */
5061

5162
/* =========================================================================
5263
Typography
@@ -58,12 +69,18 @@
5869
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New",
5970
monospace;
6071

61-
--font-size-xs: 0.75rem; /* 12px */
62-
--font-size-sm: 0.875rem; /* 14px */
63-
--font-size-md: 1rem; /* 16px */
64-
--font-size-lg: 1.125rem; /* 18px */
65-
--font-size-xl: 1.25rem; /* 20px */
66-
--font-size-2xl: 1.5rem; /* 24px */
72+
--font-size-xs: 0.75rem;
73+
/* 12px */
74+
--font-size-sm: 0.875rem;
75+
/* 14px */
76+
--font-size-md: 1rem;
77+
/* 16px */
78+
--font-size-lg: 1.125rem;
79+
/* 18px */
80+
--font-size-xl: 1.25rem;
81+
/* 20px */
82+
--font-size-2xl: 1.5rem;
83+
/* 24px */
6784

6885
--font-weight-normal: 400;
6986
--font-weight-medium: 500;
@@ -77,11 +94,16 @@
7794
/* =========================================================================
7895
Border Radius
7996
========================================================================= */
80-
--radius-sm: 0.25rem; /* 4px */
81-
--radius-md: 0.375rem; /* 6px */
82-
--radius-lg: 0.5rem; /* 8px */
83-
--radius-xl: 0.75rem; /* 12px */
84-
--radius-full: 9999px; /* Pill shape */
97+
--radius-sm: 0.25rem;
98+
/* 4px */
99+
--radius-md: 0.375rem;
100+
/* 6px */
101+
--radius-lg: 0.5rem;
102+
/* 8px */
103+
--radius-xl: 0.75rem;
104+
/* 12px */
105+
--radius-full: 9999px;
106+
/* Pill shape */
85107

86108
/* =========================================================================
87109
Shadows
@@ -96,6 +118,11 @@
96118
Dark Theme
97119
========================================================================== */
98120
body.dark {
121+
--color-palette-bg: #1c1c1c;
122+
--color-palette-text: #bdbdbd;
123+
--color-palette-hover-bg: #808080;
124+
--color-palette-text-hover: #ffffff;
125+
99126
--color-bg-primary: #111827;
100127
--color-bg-secondary: #1f2937;
101128
--color-bg-tertiary: #374151;
@@ -132,6 +159,11 @@ body.dark {
132159
High-Contrast Theme
133160
========================================================================== */
134161
body.highcontrast {
162+
--color-palette-bg: #000000;
163+
--color-palette-text: #ffffff;
164+
--color-palette-hover-bg: #666666;
165+
--color-palette-text-hover: #ffffff;
166+
135167
--color-bg-primary: #000000;
136168
--color-bg-secondary: #000000;
137169
--color-bg-tertiary: #000000;

js/palette.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -888,33 +888,31 @@ class Palettes {
888888
const row = listBody.insertRow(-1);
889889
const img = row.insertCell(-1);
890890
const label = row.insertCell(-1);
891+
row.classList.add("palette-row");
892+
label.classList.add("palette-row-label");
891893
img.appendChild(icon);
892894
img.style.padding = "4px";
893895
img.style.boxSizing = "content-box";
894896
img.style.width = `${this.cellSize}px`;
895897
img.style.height = `${this.cellSize}px`;
896898
label.textContent = toTitleCase(_(name));
897-
label.style.color = platformColor.paletteText;
898899
row.style.borderBottom = "1px solid #0CAFFF";
899900
label.style.fontSize = localStorage.kanaPreference === "kana" ? "12px" : "16px";
900901
label.style.padding = "4px";
901902
row.style.display = "flex";
902903
row.style.flexDirection = "row";
903904
row.style.alignItems = "center";
904905
row.style.width = "126px";
905-
row.style.backgroundColor = platformColor.paletteBackground;
906906

907907
// Mouse hover - only work if not in keyboard navigation mode
908908
row.addEventListener("mouseover", () => {
909909
if (!this._keyboardNavActive && !row.dataset.keyboardFocus) {
910-
row.style.backgroundColor = platformColor.hoverColor;
911-
label.style.color = platformColor.hoverText;
910+
row.classList.add("palette-row--hover");
912911
}
913912
});
914913
row.addEventListener("mouseout", () => {
915914
if (!row.dataset.keyboardFocus) {
916-
row.style.backgroundColor = platformColor.paletteBackground;
917-
label.style.color = platformColor.paletteText;
915+
row.classList.remove("palette-row--hover");
918916
}
919917
});
920918

@@ -931,6 +929,8 @@ class Palettes {
931929
const row = listBody.insertRow(-1);
932930
const img = row.insertCell(-1);
933931
const label = row.insertCell(-1);
932+
row.classList.add("palette-row");
933+
label.classList.add("palette-row-label");
934934
img.appendChild(icon);
935935
img.style.padding = "4px";
936936
img.style.boxSizing = "content-box";
@@ -943,17 +943,16 @@ class Palettes {
943943
row.style.flexDirection = "row";
944944
row.style.alignItems = "center";
945945
row.style.width = "126px";
946-
row.style.backgroundColor = platformColor.paletteBackground;
947946

948947
// Mouse hover - only work if not in keyboard navigation mode
949948
row.addEventListener("mouseover", () => {
950949
if (!this._keyboardNavActive && !row.dataset.keyboardFocus) {
951-
row.style.backgroundColor = platformColor.hoverColor;
950+
row.classList.add("palette-row--hover");
952951
}
953952
});
954953
row.addEventListener("mouseout", () => {
955954
if (!row.dataset.keyboardFocus) {
956-
row.style.backgroundColor = platformColor.paletteBackground;
955+
row.classList.remove("palette-row--hover");
957956
}
958957
});
959958

0 commit comments

Comments
 (0)