Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
125 changes: 125 additions & 0 deletions docs/decisions/TIG-330-gradient-ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# 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>`.

| Branch | What it changes |
|---|---|
| `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. |

## 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 `<surface>FillStart/End` as TIG-336 asks. `getTigerPathThemeVariables()`
emits them as `--tp-<surface>-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 skipped
there). 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.

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`,
`--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 }`.

## 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.
- `.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.
10 changes: 8 additions & 2 deletions frontend/src/components/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
DEFAULT_TIGERPATH_THEME,
getTigerPathTheme,
getTigerPathThemeVariables,
rememberTigerPathTheme,
} from 'styles/theme';
import { DEFAULT_SCHEDULE } from 'utils/SemesterUtils';

Expand Down Expand Up @@ -48,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(() => {
Expand Down Expand Up @@ -321,7 +324,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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid caching the profile-error fallback

When /api/v1/get_profile/ fails in the classic UI, fetchProfile creates a fallback profile whose theme is purple, so this truthy check treats the fallback as successfully loaded and overwrites the user's remembered theme. A transient profile failure therefore erases a non-purple cached preference and makes the new planner's next first paint purple; preserve a null theme on failure or separately track whether the profile request succeeded before calling rememberTigerPathTheme.

Useful? React with 👍 / 👎.

}, [activeThemeName, profile?.theme]);

return (
<ThemeProvider theme={activeTheme}>
Expand Down
14 changes: 8 additions & 6 deletions frontend/src/new/App.jsx
Original file line number Diff line number Diff line change
@@ -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, getStoredTigerPathTheme } from 'styles/theme';
import usePlanner from './usePlanner';
import { getRequirementCourses, setUiVersion } from './api';
import startTutorial from './tutorial';
Expand Down Expand Up @@ -29,12 +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(() => {
const root = document.documentElement;
Object.entries(getTigerPathThemeVariables(themeName)).forEach(([k, v]) => root.style.setProperty(k, v));
root.dataset.tigerpathTheme = themeName;
}, [themeName]);
if (profileTheme) applyTigerPathTheme(profileTheme);
}, [profileTheme]);

useEffect(() => {
if (window.__TIGERPATH_SHOW_TUTORIAL__ && schedule) {
Expand Down
6 changes: 4 additions & 2 deletions frontend/src/new/components/SettingsModal.jsx
Original file line number Diff line number Diff line change
@@ -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('');

Expand Down
5 changes: 5 additions & 0 deletions frontend/src/new/main.jsx
Original file line number Diff line number Diff line change
@@ -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());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Refresh the cached theme when leaving the classic UI

When a user changes their theme in the classic planner and then clicks “Try new UI,” the classic flow only updates CSS variables and the server profile; it never updates tigerpath-theme in local storage. This line therefore applies the previously cached theme before get_profile returns, causing exactly the stale-theme flash this first-paint logic is intended to prevent—for example, changing from pink to purple in classic initially paints the new planner pink. Persist the theme from the classic flow as well, or provide the server-side theme to this entry point.

Useful? React with 👍 / 👎.


createRoot(document.getElementById('app')).render(<App />);
Loading
Loading