Skip to content

Commit e67da93

Browse files
samejrclaude
andcommitted
fix(webapp): give the primary button and the switch one shared accent
The switch's checked track and the primary button were two different purples: the track had just moved onto the link token (lavender-400 on the dark themes) while the button was still a raw indigo-600, so they sat side by side on the account page visibly out of step. They can't both read --color-text-link, because a fill and a text color want opposite things. White button text needs 4.5:1 against the fill, which pins the fill dark; link text on a near-black page needs 4.5:1 against *that*, which pushes the link light. So this adds --color-accent-fill, in the same spirit as the existing error/success fill tokens, and points both at it. lavender-600 is a straight swap for indigo-600 - white on it measures 6.31:1 against the old 6.29:1 - and it's the value the light themes already use for link text, so link, button and switch all agree there. The switch's white thumb improves from 3.76:1 to 6.31:1 against the track. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 838c10f commit e67da93

3 files changed

Lines changed: 17 additions & 8 deletions

File tree

apps/webapp/app/components/primitives/Buttons.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ const theme = {
6161
primary: {
6262
textColor: "text-white transition group-disabled/button:text-white/60",
6363
button:
64-
"bg-indigo-600 border border-indigo-500 group-hover/button:bg-indigo-500 group-hover/button:border-indigo-400 group-disabled/button:opacity-50 group-disabled/button:bg-indigo-600 group-disabled/button:border-indigo-500 group-disabled/button:pointer-events-none",
64+
// Shares --color-accent-fill with the switch's checked track, so the two
65+
// accents can't drift. The border is a fixed bevel one stop up the ramp,
66+
// like the indigo pair it replaces.
67+
"bg-accent-fill border border-lavender-500 group-hover/button:bg-lavender-500 group-hover/button:border-lavender-400 group-disabled/button:opacity-50 group-disabled/button:bg-accent-fill group-disabled/button:border-lavender-500 group-disabled/button:pointer-events-none",
6568
shortcut:
6669
"border-white/40 text-white group-hover/button:border-white/60 group-hover/button:text-white",
6770
icon: "text-white",

apps/webapp/app/components/primitives/Switch.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,18 @@ export const Switch = React.forwardRef<React.ElementRef<typeof SwitchPrimitives.
9999
const switchElement = (
100100
<div
101101
className={cn(
102-
// The checked fill reads the link token, so the accent purple is the
103-
// same one links use and follows the theme - a single raw indigo can't
104-
// sit on both a near-black track and white.
105-
"inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors group-disabled:cursor-not-allowed group-disabled:opacity-50 group-data-[state=checked]:bg-text-link group-data-[state=unchecked]:bg-background-raised group-hover:group-data-[state=unchecked]:bg-surface-control-active/50",
102+
// The checked track shares --color-accent-fill with the primary
103+
// button, so the two accents are the same purple and can't drift.
104+
"inline-flex shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors group-disabled:cursor-not-allowed group-disabled:opacity-50 group-data-[state=checked]:bg-accent-fill group-data-[state=unchecked]:bg-background-raised group-hover:group-data-[state=unchecked]:bg-surface-control-active/50",
106105
root
107106
)}
108107
>
109108
<SwitchPrimitives.Thumb
110109
className={cn(
111110
thumb,
112-
/* White once checked, in every theme: the link token is lighter than
113-
the old indigo on the dark themes, so an off-white thumb would fall
114-
under 3:1 against the track and stop reading as a separate part. */
111+
/* White once checked, in every theme, matching the primary button's
112+
label on the same fill - an off-white thumb sat at 2.80:1 against
113+
the track, under the 3:1 a control's parts need. */
115114
"pointer-events-none block rounded-full bg-white transition dark:bg-charcoal-200 dark:group-data-[state=checked]:bg-white"
116115
)}
117116
/>

apps/webapp/app/tailwind.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,13 @@
150150
hover at all. This lands just under the largest hover step the app already
151151
uses (text-dimmed -> text-bright). */
152152
--color-text-link-hover: var(--color-lavender-300);
153+
/* The same brand purple as a *fill* under white content - the primary button
154+
and the switch's checked track, which must agree with each other. One value
155+
for every theme: white content needs 4.5:1, which pins it dark, while
156+
--color-text-link above has to travel the other way to stay legible as text
157+
on a near-black page. So the fill and the link color match on the light
158+
themes and can't on the dark ones. */
159+
--color-accent-fill: var(--color-lavender-600);
153160
--color-text-faint: var(--color-charcoal-500);
154161
--color-text-dimmed: var(--color-charcoal-400);
155162
--color-text-bright: var(--color-charcoal-200);

0 commit comments

Comments
 (0)