From e34e24a497a06cf203e58d2aa838c4b1f134b93f Mon Sep 17 00:00:00 2001 From: Siddharth Gupta Date: Mon, 23 Nov 2026 20:39:07 -0500 Subject: [PATCH 1/6] (feat) apply Lucy's color gradients to the new planner (TIG-330) Adds new-planner gradient tokens to every theme in TIGERPATH_THEME_OPTIONS (courseCard, courseCardHover, searchCard, searchCode, reqChip fills plus text, plan tab and requirement panel colors) and emits them as --tp-* CSS variables. Existing tokens are untouched so the classic UI is unchanged. - Course cards, hover, search cards, code pills and requirement chips use vertical gradients from the Figma; orange/blue are extrapolated. - Text colors darkened to pass WCAG AA on every stop (tested per theme). - new/styles.css no longer redefines base colors; they come from theme.js. - Theme is applied before first render (last theme kept in localStorage). - Print falls back to flat fills. Decision log: docs/decisions/TIG-330-gradient-ui.md Co-Authored-By: Claude Opus 5.5 --- docs/decisions/TIG-330-gradient-ui.md | 105 +++++++++++++++++ frontend/src/new/App.jsx | 6 +- frontend/src/new/main.jsx | 5 + frontend/src/new/styles.css | 79 ++++++++----- frontend/src/styles/theme.js | 159 +++++++++++++++++++++++--- frontend/src/styles/theme.test.js | 76 ++++++++++++ 6 files changed, 383 insertions(+), 47 deletions(-) create mode 100644 docs/decisions/TIG-330-gradient-ui.md create mode 100644 frontend/src/styles/theme.test.js diff --git a/docs/decisions/TIG-330-gradient-ui.md b/docs/decisions/TIG-330-gradient-ui.md new file mode 100644 index 00000000..aee49204 --- /dev/null +++ b/docs/decisions/TIG-330-gradient-ui.md @@ -0,0 +1,105 @@ +# TIG-330: color-gradient UI on the new planner (decision log) + +Issues: TIG-330 (parent), TIG-335 (audit), TIG-336 (implementation). +Design source: Figma file `parallel`. Purple is Anna › `purple (default)` (node `2027:3157`) and pink is +Angelina › node `447:2`, both confirmed by Helen. + +Each decision below records the options, what this branch does, and which branch holds the other +option, so you can switch with `git switch `. + +| Branch | What it changes | +|---|---| +| `tig-330-tigerpath-implement-lucys-color-gradient-ui-on-the` | **Main branch.** Every decision uses its default (D1–D9). | +| `tig-330-alt-figma-exact-text` | D4 alternative: Lucy's exact text colors, which fail WCAG AA. | +| `tig-330-alt-shared-tokens` | D1 alternative: the classic UI adopts the new palette too. | + +## D1. Classic UI isolation: new tokens, not edited ones + +**Blocker:** TIG-336 says the classic UI must stay visually unchanged. Every existing CSS variable +(`--tp-course-*`, `--tp-search-*`, `--tp-requirement-*`, `--tp-active-plan-*`, `--tp-accent`) is also +read by the classic UI (`styles/Courses.css`, `styles/Requirements.css`, `components/PlanHeader.jsx`). +Changing their values would recolor the classic UI. + +**Decision:** leave every existing key and value alone, and add new keys to each theme in +`TIGERPATH_THEME_OPTIONS`, named `FillStart/End` as TIG-336 asks. `getTigerPathThemeVariables()` +emits them as `--tp--fill-start/end`. +`theme.test.js` pins the classic purple values so they can't drift by accident. + +New tokens: `courseCardFill*`, `courseCardHoverFill*`, `searchCardFill*`, `searchCodeFill*`, +`reqChipFill*`, `courseCardText`, `reqChipText`, `planTabActiveFill`, `planTabsFill`, `reqPanelFill`. + +**Other option:** `tig-330-alt-shared-tokens` points the existing keys at the new values too. That +gives one palette for both UIs, but the classic UI changes. + +## D2. Orange and blue have no Figma + +**Blocker:** the Figma only has purple and pink. + +**Decision (Helen: "extrapolate from existing"):** each themed color uses that theme's existing hue in +`theme.js`, with saturation and lightness averaged from Figma's purple and pink. Green and neutral surfaces +(requirement chip, active plan tab, tab bar, requirement panel) follow warm and cool: orange copies +pink and blue copies purple. Blue's requirement panel gets a blue tint (`#f8feff`). + +## D3. The darker course card in the Figma is the hover state + +**Blocker:** the Figma doesn't say what the darker ECO100 card (with the ×) represents. + +**Decision (Helen):** it's hover. `.tp-course:hover` and `:focus-visible` switch to the +`courseCardHoverFill*` gradient. The existing × still shows on hover. + +## D4. WCAG AA beats exact Figma text colors + +**Blocker:** TIG-330 requires text on gradients to meet WCAG AA (4.5:1). Lucy's text colors fail on +the hover card (purple 3.78, pink 3.68), the search course-code pill (purple 4.45, pink 3.68) and the +requirement chip (purple 2.65, pink 3.28). + +**Decision:** keep every gradient as designed and darken only the two text colors. Each keeps its hue +and saturation, with lightness lowered to the lightest value that clears 4.5:1 on every stop it sits on. + +| Token | Purple | Orange | Blue | Pink | +|---|---|---|---|---| +| `courseCardText` | `#42116f` (Figma `#54168e`) | `#922310` | `#0b6875` | `#970c48` (Figma `#b30e55`) | +| `reqChipText` | `#0b7a2c` (Figma `#0fa93d`) | `#597112` | `#0b7a2c` | `#597112` (Figma `#6e8b16`) | + +`theme.test.js` checks every text/stop pair for every theme. + +**Other option:** `tig-330-alt-figma-exact-text` uses Lucy's exact colors (its AA test is marked as +an expected failure). Use it if Lucy would rather fix contrast in the design. + +## D5. Requirement chip direction: `to bottom` + +The Figma gradients are all vertical. The existing chip was drawn `to right`. It's now `to bottom`. + +## D6. Active plan tab keeps its theme-colored border + +The Figma active tab is lime (`#dcfdad` purple, `#ecf9a5` pink) with no border. TIG-336 also says the +active tab must stay easy to tell apart. **Decision:** lime fill from the Figma, and keep the existing +`--tp-active-plan-border` outline, so the active tab still reads clearly against the grey bar and +still shows the theme. + +## D7. Duplicate color tokens removed from `new/styles.css` + +`new/styles.css :root` had its own copies of `--tp-text`, `--tp-border`, `--tp-muted`, +`--tp-drop-ok`, `--tp-drop-warn` and `--tp-incomplete`. They now come from `BASE_THEME` through +`getTigerPathThemeVariables()`, and `:root` keeps only the layout tokens (`--tp-header-h`, `--tp-radius`). +`app-style.css :root` (the classic fallback) is **left alone** to keep the classic first paint unchanged. + +## D8. No unthemed first paint + +Every new-planner color is now a runtime variable, so `new/main.jsx` calls +`applyTigerPathTheme(getStoredTigerPathTheme())` before the first render. The last theme is kept in +`localStorage` (`tigerpath-theme`) and falls back to purple. `App` re-applies the profile's theme once +it loads. + +## D9. Print uses flat fills + +`@media print` swaps every gradient for its end stop (course card, search card, code pill, requirement +chip) and keeps the requirement panel white. Print text stays black via the existing `* { color: #000 }`. + +## Not changed (out of scope, recorded for follow-up) + +- Semester and year headers: no fill in the Figma, so no tokens. +- `.tp-chip` (blue, `#e2f1ff`/`#10508a`), `.tp-btn-save`, `.tp-btn-danger`, notice yellows: off-palette + but not part of the gradient design. +- The settings-modal theme swatches still use the classic `courseFill`, `fallSemHeaderColor` and `accent`. +- The landing-page gradient: a single design, outside the theme system. diff --git a/frontend/src/new/App.jsx b/frontend/src/new/App.jsx index b70d0fca..54015e3a 100644 --- a/frontend/src/new/App.jsx +++ b/frontend/src/new/App.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { DragDropContext } from '@hello-pangea/dnd'; -import { getTigerPathThemeVariables } from 'styles/theme'; +import { applyTigerPathTheme } from 'styles/theme'; import usePlanner from './usePlanner'; import { getRequirementCourses, setUiVersion } from './api'; import startTutorial from './tutorial'; @@ -31,9 +31,7 @@ export default function App() { const themeName = profile?.theme || 'purple'; useEffect(() => { - const root = document.documentElement; - Object.entries(getTigerPathThemeVariables(themeName)).forEach(([k, v]) => root.style.setProperty(k, v)); - root.dataset.tigerpathTheme = themeName; + applyTigerPathTheme(themeName); }, [themeName]); useEffect(() => { diff --git a/frontend/src/new/main.jsx b/frontend/src/new/main.jsx index 39a9dfc0..551b2fa6 100644 --- a/frontend/src/new/main.jsx +++ b/frontend/src/new/main.jsx @@ -1,5 +1,10 @@ import React from 'react'; import { createRoot } from 'react-dom/client'; +import { applyTigerPathTheme, getStoredTigerPathTheme } from 'styles/theme'; import App from './App'; +// Every color comes from theme CSS variables, so set them before the first paint. +// App re-applies the profile's theme once it loads. +applyTigerPathTheme(getStoredTigerPathTheme()); + createRoot(document.getElementById('app')).render(); diff --git a/frontend/src/new/styles.css b/frontend/src/new/styles.css index 64fbf450..75e61b10 100644 --- a/frontend/src/new/styles.css +++ b/frontend/src/new/styles.css @@ -1,12 +1,7 @@ -/* TigerPath new UI. Colors come from the classic theme variables (styles/theme.js). */ +/* TigerPath new UI. Every color variable (--tp-*) is written at runtime by + applyTigerPathTheme() in styles/theme.js; only layout tokens live here. */ :root { - --tp-border: #d9d9d9; - --tp-muted: #767676; - --tp-text: #181818; - --tp-incomplete: #e5372c; - --tp-drop-ok: #eaffb8; - --tp-drop-warn: #ffe9e4; --tp-header-h: 74px; --tp-radius: 6px; } @@ -276,7 +271,7 @@ button:disabled { .tp-search-card { padding: 10px; border-radius: var(--tp-radius); - background: linear-gradient(to bottom, var(--tp-search-fill-start), var(--tp-search-fill-end)); + background: linear-gradient(to bottom, var(--tp-search-card-fill-start), var(--tp-search-card-fill-end)); cursor: grab; user-select: none; border: 2px solid transparent; @@ -298,8 +293,8 @@ button:disabled { height: 38px; padding: 0 9px; border-radius: var(--tp-radius); - background: var(--tp-search-pill-fill); - color: var(--tp-search-text); + background: linear-gradient(to bottom, var(--tp-search-code-fill-start), var(--tp-search-code-fill-end)); + color: var(--tp-course-card-text); font-weight: 700; font-size: 16px; white-space: nowrap; @@ -313,7 +308,7 @@ button:disabled { gap: 2px; margin-top: 8px; font-size: 11px; - color: var(--tp-search-text); + color: var(--tp-course-card-text); line-height: 1.35; } @@ -329,7 +324,7 @@ button:disabled { gap: 4px; height: 38px; padding: 5px; - background: #eee; + background: var(--tp-plan-tabs-fill); border-radius: 19px; max-width: 100%; overflow-x: auto; @@ -348,7 +343,7 @@ button:disabled { } .tp-plan-tab.active { - background: var(--tp-active-plan-fill); + background: var(--tp-plan-tab-active-fill); border-color: var(--tp-active-plan-border); } @@ -501,9 +496,9 @@ button:disabled { min-height: 38px; padding: 0 6px 0 10px; border-radius: var(--tp-radius); - background: var(--tp-course-fill); + background: linear-gradient(to bottom, var(--tp-course-card-fill-start), var(--tp-course-card-fill-end)); border: 1.5px solid transparent; - color: var(--tp-course-text); + color: var(--tp-course-card-text); font-weight: 700; font-size: 15px; cursor: grab; @@ -512,7 +507,11 @@ button:disabled { .tp-course:hover, .tp-course:focus-visible { - border-color: var(--tp-course-border); + background: linear-gradient( + to bottom, + var(--tp-course-card-hover-fill-start), + var(--tp-course-card-hover-fill-end) + ); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); } @@ -606,7 +605,7 @@ button:disabled { display: flex; flex-direction: column; min-height: 0; - background: #fff; + background: var(--tp-req-panel-fill); border-radius: 12px; box-shadow: 0 0 6px rgba(0, 0, 0, 0.16); } @@ -767,8 +766,8 @@ button:disabled { } .tp-req-chip.settled { - background: linear-gradient(to right, var(--tp-requirement-fill-start), var(--tp-requirement-fill-end)); - color: var(--tp-requirement-text); + background: linear-gradient(to bottom, var(--tp-req-chip-fill-start), var(--tp-req-chip-fill-end)); + color: var(--tp-req-chip-text); } .tp-req-chip.unsettled { @@ -778,8 +777,8 @@ button:disabled { } .tp-req-chip.unsettled:hover { - border-color: var(--tp-requirement-text); - color: var(--tp-requirement-text); + border-color: var(--tp-req-chip-text); + color: var(--tp-req-chip-text); } .tp-req-chip .tp-badge { @@ -1096,7 +1095,7 @@ button:disabled { } .tp-btn-copy { - background: #d6c6fd; + background: var(--tp-course-card-hover-fill-start); } .tp-btn:hover:not(:disabled) { @@ -1218,16 +1217,15 @@ button:disabled { gap: 4px; padding: 4px 10px; border-radius: 8px; - background: #f1e9ff; - color: #54168e; + background: var(--tp-course-card-fill-start); + color: var(--tp-course-card-text); font-size: 13px; font-weight: 700; text-decoration: none; } .tp-tag.code { - background: var(--tp-course-fill); - color: var(--tp-course-text); + background: linear-gradient(to bottom, var(--tp-course-card-fill-start), var(--tp-course-card-fill-end)); } .tp-tag.link { @@ -1390,16 +1388,41 @@ button:disabled { break-inside: avoid; } - .tp-course { + /* Print uses flat fills: gradients print unevenly and the hover state never applies. */ + .tp-course, + .tp-course:hover, + .tp-course:focus-visible { break-inside: avoid; flex-direction: column; align-items: flex-start; padding: 4px 8px; margin-bottom: 6px; + background: var(--tp-course-card-fill-end); + box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; } + .tp-search-card, + .tp-search-card-code { + background: var(--tp-search-card-fill-end); + } + + .tp-tag.code { + background: var(--tp-course-card-fill-end); + } + + .tp-req-chip.settled { + background: var(--tp-req-chip-fill-end); + -webkit-print-color-adjust: exact; + print-color-adjust: exact; + } + + .tp-card { + background: #fff; + box-shadow: none; + } + .tp-course-title { font-weight: 400; font-size: 11px; @@ -1420,7 +1443,7 @@ button:disabled { .tp-chip.primary { background: var(--tp-active-plan-fill); - color: var(--tp-course-text); + color: var(--tp-course-card-text); } .tp-chip-tag { diff --git a/frontend/src/styles/theme.js b/frontend/src/styles/theme.js index c566086b..1d1b521b 100644 --- a/frontend/src/styles/theme.js +++ b/frontend/src/styles/theme.js @@ -5,6 +5,7 @@ const BASE_THEME = { greySemBody: '#f5f5f5', greenSemBody: '#eaffb8', redSemBody: '#ffe9e4', + incompleteText: '#e5372c', }; export const TIGERPATH_THEME_OPTIONS = { @@ -27,6 +28,22 @@ export const TIGERPATH_THEME_OPTIONS = { requirementFillEnd: '#e1ff9a', requirementText: '#0da745', accent: '#4a1f87', + // New planner (src/new) only. The classic UI keeps reading the keys above. + courseCardFillStart: '#f1e9ff', + courseCardFillEnd: '#e2deff', + courseCardHoverFillStart: '#cfa2d8', + courseCardHoverFillEnd: '#bc7aea', + searchCardFillStart: '#f1e9ff', + searchCardFillEnd: '#e3d4fe', + searchCodeFillStart: '#cfa2d8', + searchCodeFillEnd: '#c88bee', + reqChipFillStart: '#daf6be', + reqChipFillEnd: '#ecffb6', + courseCardText: '#42116f', + reqChipText: '#0b7a2c', + planTabActiveFill: '#dcfdad', + planTabsFill: '#e5e5e5', + reqPanelFill: '#faf8ff', }, orange: { ...BASE_THEME, @@ -47,6 +64,22 @@ export const TIGERPATH_THEME_OPTIONS = { requirementFillEnd: '#e1ff9a', requirementText: '#289b2f', accent: '#c64019', + // New planner (src/new) only. The classic UI keeps reading the keys above. + courseCardFillStart: '#fff3ed', + courseCardFillEnd: '#ffebe2', + courseCardHoverFillStart: '#f0c1ab', + courseCardHoverFillEnd: '#f7ae8c', + searchCardFillStart: '#fff3ed', + searchCardFillEnd: '#ffe3d7', + searchCodeFillStart: '#f0c1ab', + searchCodeFillEnd: '#f8b596', + reqChipFillStart: '#effaaa', + reqChipFillEnd: '#e2f498', + courseCardText: '#922310', + reqChipText: '#597112', + planTabActiveFill: '#ecf9a5', + planTabsFill: '#eeeeee', + reqPanelFill: '#ffffff', }, blue: { ...BASE_THEME, @@ -67,6 +100,22 @@ export const TIGERPATH_THEME_OPTIONS = { requirementFillEnd: '#e1ff9a', requirementText: '#17a244', accent: '#006f80', + // New planner (src/new) only. The classic UI keeps reading the keys above. + courseCardFillStart: '#edfeff', + courseCardFillEnd: '#e2fdff', + courseCardHoverFillStart: '#abe8f0', + courseCardHoverFillEnd: '#8ceaf7', + searchCardFillStart: '#edfcff', + searchCardFillEnd: '#d7f9ff', + searchCodeFillStart: '#abe8f0', + searchCodeFillEnd: '#96ecf8', + reqChipFillStart: '#daf6be', + reqChipFillEnd: '#ecffb6', + courseCardText: '#0b6875', + reqChipText: '#0b7a2c', + planTabActiveFill: '#dcfdad', + planTabsFill: '#e5e5e5', + reqPanelFill: '#f8feff', }, pink: { ...BASE_THEME, @@ -87,6 +136,22 @@ export const TIGERPATH_THEME_OPTIONS = { requirementFillEnd: '#e1ff9a', requirementText: '#17a340', accent: '#b70f55', + // New planner (src/new) only. The classic UI keeps reading the keys above. + courseCardFillStart: '#fff2fa', + courseCardFillEnd: '#ffe5e9', + courseCardHoverFillStart: '#ffbed2', + courseCardHoverFillEnd: '#ffa3d4', + searchCardFillStart: '#fff2fa', + searchCardFillEnd: '#ffdbe0', + searchCodeFillStart: '#ffbed2', + searchCodeFillEnd: '#ffa3d4', + reqChipFillStart: '#effaaa', + reqChipFillEnd: '#e2f498', + courseCardText: '#970c48', + reqChipText: '#597112', + planTabActiveFill: '#ecf9a5', + planTabsFill: '#eeeeee', + reqPanelFill: '#ffffff', }, }; @@ -97,21 +162,85 @@ export function getTigerPathTheme(themeName) { return TIGERPATH_THEME_OPTIONS[normalizedThemeName] || TIGERPATH_THEME_OPTIONS[DEFAULT_TIGERPATH_THEME]; } +// Shared with the classic UI (components/App.jsx); values here must not change without +// checking styles/Courses.css, styles/Requirements.css and components/PlanHeader.jsx. +const CLASSIC_VARIABLES = { + '--tp-course-text': 'courseText', + '--tp-course-fill': 'courseFill', + '--tp-course-border': 'courseBorder', + '--tp-search-fill-start': 'searchFillStart', + '--tp-search-fill-end': 'searchFillEnd', + '--tp-search-pill-fill': 'searchPillFill', + '--tp-search-text': 'searchText', + '--tp-active-plan-fill': 'activePlanFill', + '--tp-active-plan-border': 'activePlanBorder', + '--tp-requirement-fill-start': 'requirementFillStart', + '--tp-requirement-fill-end': 'requirementFillEnd', + '--tp-requirement-text': 'requirementText', + '--tp-accent': 'accent', +}; + +// Theme-independent colors the new planner reads (previously redefined in new/styles.css :root). +const BASE_VARIABLES = { + '--tp-text': 'darkGreyText', + '--tp-border': 'lightGrey', + '--tp-muted': 'darkGrey', + '--tp-drop-ok': 'greenSemBody', + '--tp-drop-warn': 'redSemBody', + '--tp-incomplete': 'incompleteText', +}; + +// New planner gradient and surface tokens: FillStart -> --tp--fill-start. +const NEW_PLANNER_KEYS = [ + 'courseCardFillStart', + 'courseCardFillEnd', + 'courseCardHoverFillStart', + 'courseCardHoverFillEnd', + 'searchCardFillStart', + 'searchCardFillEnd', + 'searchCodeFillStart', + 'searchCodeFillEnd', + 'reqChipFillStart', + 'reqChipFillEnd', + 'courseCardText', + 'reqChipText', + 'planTabActiveFill', + 'planTabsFill', + 'reqPanelFill', +]; + +const toCssVariable = (key) => `--tp-${key.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`; + export function getTigerPathThemeVariables(themeName) { const theme = getTigerPathTheme(themeName); - return { - '--tp-course-text': theme.courseText, - '--tp-course-fill': theme.courseFill, - '--tp-course-border': theme.courseBorder, - '--tp-search-fill-start': theme.searchFillStart, - '--tp-search-fill-end': theme.searchFillEnd, - '--tp-search-pill-fill': theme.searchPillFill, - '--tp-search-text': theme.searchText, - '--tp-active-plan-fill': theme.activePlanFill, - '--tp-active-plan-border': theme.activePlanBorder, - '--tp-requirement-fill-start': theme.requirementFillStart, - '--tp-requirement-fill-end': theme.requirementFillEnd, - '--tp-requirement-text': theme.requirementText, - '--tp-accent': theme.accent, - }; + const variables = {}; + Object.entries({ ...CLASSIC_VARIABLES, ...BASE_VARIABLES }).forEach(([cssName, key]) => { + variables[cssName] = theme[key]; + }); + NEW_PLANNER_KEYS.forEach((key) => { + variables[toCssVariable(key)] = theme[key]; + }); + return variables; +} + +const THEME_STORAGE_KEY = 'tigerpath-theme'; + +/** Writes the theme's CSS variables onto and remembers the choice for the next first paint. */ +export function applyTigerPathTheme(themeName, root = document.documentElement) { + Object.entries(getTigerPathThemeVariables(themeName)).forEach(([k, v]) => root.style.setProperty(k, v)); + root.dataset.tigerpathTheme = themeName; + try { + window.localStorage.setItem(THEME_STORAGE_KEY, themeName); + } catch { + // Storage can be unavailable (private mode); the theme still applies for this page. + } +} + +/** Last theme this browser used, so the first paint is themed before the profile request returns. */ +export function getStoredTigerPathTheme() { + try { + return window.localStorage.getItem(THEME_STORAGE_KEY) || DEFAULT_TIGERPATH_THEME; + } catch { + return DEFAULT_TIGERPATH_THEME; + } } diff --git a/frontend/src/styles/theme.test.js b/frontend/src/styles/theme.test.js new file mode 100644 index 00000000..8fe26d9f --- /dev/null +++ b/frontend/src/styles/theme.test.js @@ -0,0 +1,76 @@ +import { describe, expect, it } from 'vitest'; +import { TIGERPATH_THEME_OPTIONS, getTigerPathThemeVariables } from './theme'; + +const THEMES = Object.keys(TIGERPATH_THEME_OPTIONS); + +function luminance(hex) { + const channels = hex + .replace('#', '') + .match(/../g) + .map((h) => parseInt(h, 16) / 255) + .map((c) => (c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4)); + return 0.2126 * channels[0] + 0.7152 * channels[1] + 0.0722 * channels[2]; +} + +function contrast(a, b) { + const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x); + return (hi + 0.05) / (lo + 0.05); +} + +// Text token -> every background stop it is drawn on in the new planner (styles in src/new/styles.css). +const TEXT_ON_GRADIENT = { + courseCardText: [ + 'courseCardFillStart', + 'courseCardFillEnd', + 'courseCardHoverFillStart', + 'courseCardHoverFillEnd', + 'searchCardFillStart', + 'searchCardFillEnd', + 'searchCodeFillStart', + 'searchCodeFillEnd', + ], + reqChipText: ['reqChipFillStart', 'reqChipFillEnd'], +}; + +describe('new planner theme tokens', () => { + it.each(THEMES)('%s: text on every gradient stop meets WCAG AA (4.5:1)', (name) => { + const theme = TIGERPATH_THEME_OPTIONS[name]; + Object.entries(TEXT_ON_GRADIENT).forEach(([text, backgrounds]) => { + backgrounds.forEach((bg) => { + expect(contrast(theme[text], theme[bg]), `${text} on ${bg}`).toBeGreaterThanOrEqual(4.5); + }); + }); + }); + + it.each(THEMES)('%s: emits every variable with a defined value', (name) => { + const variables = getTigerPathThemeVariables(name); + Object.entries(variables).forEach(([cssName, value]) => { + expect(value, cssName).toBeTruthy(); + }); + expect(variables['--tp-course-card-fill-start']).toBe(TIGERPATH_THEME_OPTIONS[name].courseCardFillStart); + expect(variables['--tp-req-panel-fill']).toBe(TIGERPATH_THEME_OPTIONS[name].reqPanelFill); + expect(variables['--tp-incomplete']).toBe('#e5372c'); + }); +}); + +describe('classic UI variables', () => { + // The classic UI (styles/Courses.css, styles/Requirements.css, components/PlanHeader.jsx) reads + // these. TIG-330 requires it to stay visually unchanged, so pin the purple values. + it('keeps the classic purple values', () => { + expect(getTigerPathThemeVariables('purple')).toMatchObject({ + '--tp-course-text': '#5a23a4', + '--tp-course-fill': '#ddd6ff', + '--tp-course-border': '#c8bbff', + '--tp-search-fill-start': '#ead8ff', + '--tp-search-fill-end': '#ded3ff', + '--tp-search-pill-fill': 'rgba(188, 137, 237, 0.45)', + '--tp-search-text': '#5922a5', + '--tp-active-plan-fill': '#ddd6ff', + '--tp-active-plan-border': '#b99df7', + '--tp-requirement-fill-start': '#dff6b4', + '--tp-requirement-fill-end': '#e1ff9a', + '--tp-requirement-text': '#0da745', + '--tp-accent': '#4a1f87', + }); + }); +}); From e4ddb4bffc165737e8add27547934b5209fc8605 Mon Sep 17 00:00:00 2001 From: Siddharth Gupta Date: Mon, 23 Nov 2026 20:40:53 -0500 Subject: [PATCH 2/6] (docs) TIG-330 decision log: alt branch skips the AA test Co-Authored-By: Claude Opus 5.5 --- docs/decisions/TIG-330-gradient-ui.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/decisions/TIG-330-gradient-ui.md b/docs/decisions/TIG-330-gradient-ui.md index aee49204..b483c2d2 100644 --- a/docs/decisions/TIG-330-gradient-ui.md +++ b/docs/decisions/TIG-330-gradient-ui.md @@ -63,8 +63,8 @@ and saturation, with lightness lowered to the lightest value that clears 4.5:1 o `theme.test.js` checks every text/stop pair for every theme. -**Other option:** `tig-330-alt-figma-exact-text` uses Lucy's exact colors (its AA test is marked as -an expected failure). Use it if Lucy would rather fix contrast in the design. +**Other option:** `tig-330-alt-figma-exact-text` uses Lucy's exact colors (its AA test is skipped +there). Use it if Lucy would rather fix contrast in the design. ## D5. Requirement chip direction: `to bottom` From 832792a4856dbf11095032014523d6a99e1a03fa Mon Sep 17 00:00:00 2001 From: Siddharth Gupta Date: Mon, 23 Nov 2026 20:44:10 -0500 Subject: [PATCH 3/6] (fix) TIG-336: keep the course remove icon at 3:1 on hover gradients The x used --tp-accent, which falls to 2.75:1 on the orange hover gradient; it now uses the card text color, and its red hover state sits on a light backing (>= 4.47:1 in every theme). Decision log adds D10 (icon contrast) and D11 (one branch/PR for TIG-330 and TIG-336) and notes the active plan tab's low luminance contrast for design review. Co-Authored-By: Claude Opus 5.5 --- docs/decisions/TIG-330-gradient-ui.md | 22 +++++++++++++++++++++- frontend/src/new/styles.css | 5 ++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/decisions/TIG-330-gradient-ui.md b/docs/decisions/TIG-330-gradient-ui.md index b483c2d2..a8bb730c 100644 --- a/docs/decisions/TIG-330-gradient-ui.md +++ b/docs/decisions/TIG-330-gradient-ui.md @@ -9,7 +9,7 @@ option, so you can switch with `git switch `. | Branch | What it changes | |---|---| -| `tig-330-tigerpath-implement-lucys-color-gradient-ui-on-the` | **Main branch.** Every decision uses its default (D1–D9). | +| `tig-330-tigerpath-implement-lucys-color-gradient-ui-on-the` | **Main branch.** Every decision uses its default (D1–D11). | | `tig-330-alt-figma-exact-text` | D4 alternative: Lucy's exact text colors, which fail WCAG AA. | | `tig-330-alt-shared-tokens` | D1 alternative: the classic UI adopts the new palette too. | @@ -77,6 +77,10 @@ active tab must stay easy to tell apart. **Decision:** lime fill from the Figma, `--tp-active-plan-border` outline, so the active tab still reads clearly against the grey bar and still shows the theme. +Caveat for design review: the lime fill and the grey bar differ mostly in hue. Their luminance +contrast is only 1.03 to 1.12, so what marks the active tab is its color, the outline and the bold name. +The tab text (`#181818`) is 15.8:1 on lime. + ## D7. Duplicate color tokens removed from `new/styles.css` `new/styles.css :root` had its own copies of `--tp-text`, `--tp-border`, `--tp-muted`, @@ -96,6 +100,22 @@ it loads. `@media print` swaps every gradient for its end stop (course card, search card, code pill, requirement chip) and keeps the requirement panel white. Print text stays black via the existing `* { color: #000 }`. +## D10. Course-card remove icon (×) contrast + +**Blocker (found while checking TIG-336):** the × used `--tp-accent`, which drops below the 3:1 that +icons need on the hover gradient (orange 2.75). Its red hover color (`#c0392b`) also fell as low as +1.84 on that gradient. + +**Decision:** the × now uses the card's text color, which is held to 4.5:1 or better on every hover stop +by `theme.test.js`. When hovered, it turns red over an 80% white backing, which measures 4.47:1 or +better in every theme. The classic accent token itself is unchanged. + +## D11. One branch and PR for TIG-330 and TIG-336 + +TIG-336 is the implementation half of TIG-330, so both ship from +`tig-330-tigerpath-implement-lucys-color-gradient-ui-on-the`. The PR names both issues so Linear +links it to each. No separate `tig-336-…` branch, which would have duplicated the same commits. + ## Not changed (out of scope, recorded for follow-up) - Semester and year headers: no fill in the Figma, so no tokens. diff --git a/frontend/src/new/styles.css b/frontend/src/new/styles.css index 75e61b10..bb23c605 100644 --- a/frontend/src/new/styles.css +++ b/frontend/src/new/styles.css @@ -533,7 +533,8 @@ button:disabled { background: none; padding: 3px; border-radius: 4px; - color: var(--tp-accent); + /* Card text color, not --tp-accent: the accent drops below 3:1 on some hover gradients. */ + color: inherit; } .tp-course:hover .tp-course-remove, @@ -543,6 +544,8 @@ button:disabled { .tp-course-remove:hover { color: #c0392b; + /* The red alone is under 3:1 on the hover gradient; a light backing keeps it at 4.4:1 or better. */ + background: rgba(255, 255, 255, 0.8); } .tp-hovercard { From 8c5ce21cc7f17a96d535b9bb9d987ca6e46c81e0 Mon Sep 17 00:00:00 2001 From: Siddharth Gupta Date: Tue, 24 Nov 2026 14:48:47 -0500 Subject: [PATCH 4/6] (fix) TIG-330: keep the remembered theme until the profile loads The theme effect applied purple while the profile was still loading (profile null), flashing purple and saving it over the remembered theme; a failed profile request also reset it to purple. Only apply and store a theme once the profile names one; until then the theme applied before first paint stays. Settings defaults to the remembered theme too. (Codex review on #545.) Co-Authored-By: Claude Opus 5.5 --- frontend/src/new/App.jsx | 12 ++++++++---- frontend/src/new/components/SettingsModal.jsx | 6 ++++-- frontend/src/new/usePlanner.js | 3 ++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/frontend/src/new/App.jsx b/frontend/src/new/App.jsx index 54015e3a..da4412ae 100644 --- a/frontend/src/new/App.jsx +++ b/frontend/src/new/App.jsx @@ -1,6 +1,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { DragDropContext } from '@hello-pangea/dnd'; -import { applyTigerPathTheme } from 'styles/theme'; +import { applyTigerPathTheme, getStoredTigerPathTheme } from 'styles/theme'; import usePlanner from './usePlanner'; import { getRequirementCourses, setUiVersion } from './api'; import startTutorial from './tutorial'; @@ -29,10 +29,14 @@ export default function App() { const [settingsOpen, setSettingsOpen] = useState(false); const [creditPath, setCreditPath] = useState(null); - const themeName = profile?.theme || 'purple'; + // main.jsx already applied the last-used theme before the first paint. Only apply (and remember) + // a theme once the profile says which one, so there is no flash to purple while it loads and a + // failed profile request never overwrites the remembered theme. + const profileTheme = profile?.theme || null; + const themeName = profileTheme || getStoredTigerPathTheme(); useEffect(() => { - applyTigerPathTheme(themeName); - }, [themeName]); + if (profileTheme) applyTigerPathTheme(profileTheme); + }, [profileTheme]); useEffect(() => { if (window.__TIGERPATH_SHOW_TUTORIAL__ && schedule) { diff --git a/frontend/src/new/components/SettingsModal.jsx b/frontend/src/new/components/SettingsModal.jsx index 433ca736..d7c00591 100644 --- a/frontend/src/new/components/SettingsModal.jsx +++ b/frontend/src/new/components/SettingsModal.jsx @@ -1,14 +1,16 @@ import React, { useState } from 'react'; import Modal from './Modal'; import Icon from './Icon'; -import { TIGERPATH_THEME_OPTIONS } from 'styles/theme'; +import { TIGERPATH_THEME_OPTIONS, getStoredTigerPathTheme } from 'styles/theme'; import { classYearChoices } from '../helpers/schedule'; import { saveSettings } from '../api'; export default function SettingsModal({ profile, onSaved, onClose }) { const years = classYearChoices(); const [year, setYear] = useState(profile?.classYear ?? years[0]); - const [theme, setTheme] = useState(profile?.theme === 'sunset' ? 'orange' : profile?.theme || 'purple'); + const [theme, setTheme] = useState( + profile?.theme === 'sunset' ? 'orange' : profile?.theme || getStoredTigerPathTheme() + ); const [busy, setBusy] = useState(false); const [error, setError] = useState(''); diff --git a/frontend/src/new/usePlanner.js b/frontend/src/new/usePlanner.js index 10edeebc..e689aa55 100644 --- a/frontend/src/new/usePlanner.js +++ b/frontend/src/new/usePlanner.js @@ -59,7 +59,8 @@ export default function usePlanner() { api .getProfile() .then(setProfile) - .catch(() => setProfile({ classYear: null, theme: 'purple' })); + // No theme on failure: the remembered theme stays applied instead of resetting to purple. + .catch(() => setProfile({ classYear: null, theme: null })); api.getPlans().then(applyPlans).catch(() => {}); api .getPlanEditorOptions() From 1efbeb93c012820998e1090c456beed5d933f7e7 Mon Sep 17 00:00:00 2001 From: Siddharth Gupta Date: Tue, 24 Nov 2026 14:59:57 -0500 Subject: [PATCH 5/6] (fix) TIG-330: classic UI keeps the remembered theme in sync Changing theme in the classic UI never updated the theme the new planner paints first, so switching UIs briefly showed the old theme. The classic App now remembers the profile's theme once the profile has loaded (no visual change to the classic UI). (Codex review on #545.) Co-Authored-By: Claude Opus 5.5 --- frontend/src/components/App.jsx | 6 +++++- frontend/src/styles/theme.js | 13 +++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/App.jsx b/frontend/src/components/App.jsx index 776e74f3..d184c24e 100644 --- a/frontend/src/components/App.jsx +++ b/frontend/src/components/App.jsx @@ -9,6 +9,7 @@ import { DEFAULT_TIGERPATH_THEME, getTigerPathTheme, getTigerPathThemeVariables, + rememberTigerPathTheme, } from 'styles/theme'; import { DEFAULT_SCHEDULE } from 'utils/SemesterUtils'; @@ -321,7 +322,10 @@ export default function App() { root.style.setProperty(property, value); }); root.dataset.tigerpathTheme = activeThemeName; - }, [activeThemeName]); + // Keep the new planner's remembered theme in sync, so switching UIs never paints a stale theme. + // Only once the profile has loaded: before that, activeThemeName is just the default. + if (profile?.theme) rememberTigerPathTheme(profile.theme); + }, [activeThemeName, profile?.theme]); return ( diff --git a/frontend/src/styles/theme.js b/frontend/src/styles/theme.js index 1d1b521b..03c46d60 100644 --- a/frontend/src/styles/theme.js +++ b/frontend/src/styles/theme.js @@ -225,10 +225,8 @@ export function getTigerPathThemeVariables(themeName) { const THEME_STORAGE_KEY = 'tigerpath-theme'; -/** Writes the theme's CSS variables onto and remembers the choice for the next first paint. */ -export function applyTigerPathTheme(themeName, root = document.documentElement) { - Object.entries(getTigerPathThemeVariables(themeName)).forEach(([k, v]) => root.style.setProperty(k, v)); - root.dataset.tigerpathTheme = themeName; +/** Remembers the user's theme so the new planner's first paint uses it (shared with the classic UI). */ +export function rememberTigerPathTheme(themeName) { try { window.localStorage.setItem(THEME_STORAGE_KEY, themeName); } catch { @@ -236,6 +234,13 @@ export function applyTigerPathTheme(themeName, root = document.documentElement) } } +/** Writes the theme's CSS variables onto and remembers the choice for the next first paint. */ +export function applyTigerPathTheme(themeName, root = document.documentElement) { + Object.entries(getTigerPathThemeVariables(themeName)).forEach(([k, v]) => root.style.setProperty(k, v)); + root.dataset.tigerpathTheme = themeName; + rememberTigerPathTheme(themeName); +} + /** Last theme this browser used, so the first paint is themed before the profile request returns. */ export function getStoredTigerPathTheme() { try { From 3650e03797c93ef6ca00d2337608b9256ab32e11 Mon Sep 17 00:00:00 2001 From: Siddharth Gupta Date: Tue, 24 Nov 2026 15:12:45 -0500 Subject: [PATCH 6/6] (fix) TIG-330: don't remember the classic profile-failure fallback When the classic UI's profile request failed, its fallback profile carried theme 'purple', which was then saved as the user's remembered theme. The fallback now has no theme; the page still shows the default as before. (Codex review on #545.) Co-Authored-By: Claude Opus 5.5 --- frontend/src/components/App.jsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/App.jsx b/frontend/src/components/App.jsx index d184c24e..4625eb30 100644 --- a/frontend/src/components/App.jsx +++ b/frontend/src/components/App.jsx @@ -49,7 +49,9 @@ export default function App() { const fetchProfile = useCallback(() => { apiFetch('/api/v1/get_profile/') .then(setProfile) - .catch(() => setProfile({ classYear: null, theme: DEFAULT_TIGERPATH_THEME })); + // No theme on failure: the page still shows the default (activeThemeName below), but the + // fallback must not be remembered as the user's theme. + .catch(() => setProfile({ classYear: null, theme: null })); }, []); const fetchRequirements = useCallback(() => {