From 0425c3def4b11565fb7378ad890354581372a65b Mon Sep 17 00:00:00 2001 From: Vadym Musiienko Date: Wed, 28 Oct 2026 18:15:29 -0700 Subject: [PATCH 01/18] Add design tokens and color guard --- .gitignore | 1 + .../plans/2026-10-28-frontend-redesign.md | 260 ++++++++++++++++++ .../2026-10-28-frontend-redesign-design.md | 128 +++++++++ frontend/package.json | 2 - frontend/pnpm-lock.yaml | 26 -- frontend/src/app/globals.css | 53 ++-- frontend/src/app/layout.tsx | 46 ++-- frontend/src/providers/ThemeProvider.tsx | 12 - frontend/src/styles/noRawColors.test.ts | 109 ++++++++ frontend/tailwind.config.js | 108 +++++--- start.sh | 16 +- 11 files changed, 638 insertions(+), 123 deletions(-) create mode 100644 docs/superpowers/plans/2026-10-28-frontend-redesign.md create mode 100644 docs/superpowers/specs/2026-10-28-frontend-redesign-design.md delete mode 100644 frontend/src/providers/ThemeProvider.tsx create mode 100644 frontend/src/styles/noRawColors.test.ts diff --git a/.gitignore b/.gitignore index e43b0f9..5c8ea4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +.superpowers/ diff --git a/docs/superpowers/plans/2026-10-28-frontend-redesign.md b/docs/superpowers/plans/2026-10-28-frontend-redesign.md new file mode 100644 index 0000000..9412687 --- /dev/null +++ b/docs/superpowers/plans/2026-10-28-frontend-redesign.md @@ -0,0 +1,260 @@ +# PICKUP Frontend Redesign Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Restyle every PICKUP screen into the approved navy + sage, ASPC-family design system without changing any behavior. + +**Architecture:** Colors, fonts, radii and shadows become semantic tokens (CSS variables in `globals.css`, mapped in `tailwind.config.js`). A small shared UI kit in `src/components/ui/` is built once, then every page is migrated onto it. A guard test fails while any file still uses raw Tailwind palette classes or hex colors; each migration task removes its files from the guard's legacy allowlist, and the final task asserts the allowlist is empty. + +**Tech Stack:** Next.js 15 App Router, React 18, Tailwind 3.3, Radix (popover, tooltip, scroll-area), react-day-picker 10, lucide-react, Jest + Testing Library, pnpm. + +**Spec:** `docs/superpowers/specs/2026-10-28-frontend-redesign-design.md` + +## Global Constraints + +- Palette tokens only: `navy #13294B`, `sage #3E7C6B`, `sage-tint ~#E3EDE8`, `paper #F7F5F0`, `card #FFFFFF`, `stone ~#6B7280` family, `line ~#E7E3DA`, `danger ~#B42318` + tint. Optional `warning` (amber) only for a real pending-action state. No raw Tailwind color scales or hex values in `src/` outside `globals.css` and `tailwind.config.js`. +- Fonts: Inter for body/UI, Playfair Display for h1 / hero headlines only. Both via `next/font/google`. +- No gradients, blobs, floating shapes, pulsing or bouncing decoration. Motion 150-200ms, respects `prefers-reduced-motion`. +- Behavior, routes, API calls, Supabase queries and copy meaning are unchanged. +- Keep name PICKUP and existing logo files; logo sits on a white rounded tile in the navy header. +- Light theme only. +- WCAG AA contrast, visible focus rings (sage), 44px min touch targets on mobile. +- Student pages: centered column, max ~640-720px. Info pages: prose width. Admin: full width. +- Prettier config in repo (no semicolons, single quotes, 2 spaces). No em dashes anywhere. +- CI must pass: `pnpm type-check`, `pnpm knip`, `pnpm knip:production`, `pnpm lint`, `pnpm test:ci`, `pnpm build`. +- Keep `.animate-spin` on the admin loading indicator (asserted in `AdminDashboard.test.tsx:412`). +- All work on branch `redesign/frontend`, one commit per task, one PR at the end. + +## Review Focus + +1. Long content on phones (long names, long pickup locations, 6-person groups, many comments): text must wrap or truncate, never overflow the 360px viewport. Each page task's E2E step checks at 360px as well as 390px. +2. Keyboard and screen-reader use of rebuilt interactive pieces (mobile menu, modal, accordion, date picker): focus moves in and back out, Escape closes, labels announced. Pinned by tests in Task 2 and Task 3. +3. Loading, empty and error states of every data page (results with no matches, unmatched with none, admin with no rides, Supabase error): each must use the kit's `Spinner` / `EmptyState` / `Alert`, not a blank screen. Checked in each page task's E2E step by forcing the state with seed data or offline mode. +4. Status meaning: matched, waiting/unmatched, cancelled, ready, and delayed must always map to the same badge tone everywhere. Pinned by the `StatusBadge` mapping test in Task 2. +5. Signed-out and non-admin access: header must never flash admin links to non-admins, and protected pages must look right while auth resolves. Pinned by Header tests in Task 3. + +--- + +## File Structure + +New: + +- `src/styles/noRawColors.test.ts` - guard test with `LEGACY_FILES` allowlist +- `src/components/ui/Button.tsx` - `Button`, `ButtonLink` +- `src/components/ui/Field.tsx` - `Field`, `Input`, `Textarea`, `Select`, `Checkbox` +- `src/components/ui/Card.tsx` - `Card`, `CardHeader`, `CardBody`, `CardFooter` +- `src/components/ui/StatusBadge.tsx` - `Badge`, `StatusBadge`, `rideStatusTone` +- `src/components/ui/Alert.tsx` +- `src/components/ui/Modal.tsx` +- `src/components/ui/Accordion.tsx` +- `src/components/ui/PageHeader.tsx` - `PageHeader`, `PageContainer` +- `src/components/ui/EmptyState.tsx` +- `src/components/ui/Spinner.tsx` +- `src/components/ui/RideTicket.tsx` - boarding-pass card +- `src/components/ui/ui.test.tsx` - kit tests +- `src/components/ui/RideTicket.test.tsx` +- `src/components/PickupHeader.test.tsx` + +Modified: `tailwind.config.js`, `src/app/globals.css`, `src/app/layout.tsx`, `package.json`, `.gitignore`, every page and component listed in the spec's Scope. + +Removed: `src/providers/ThemeProvider.tsx` (if nothing else imports it), `src/components/results/EmptyState.tsx` (replaced by kit), `src/components/buttons/*` (replaced by `ButtonLink` / nav links) once unused. + +--- + +### Task 1: Tokens, fonts, dependency cleanup, guard test + +**Files:** + +- Create: `frontend/src/styles/noRawColors.test.ts` +- Modify: `frontend/tailwind.config.js`, `frontend/src/app/globals.css`, `frontend/src/app/layout.tsx`, `frontend/package.json`, `.gitignore` +- Remove: `frontend/src/providers/ThemeProvider.tsx` + +**Interfaces:** + +- Produces Tailwind color names: `navy` (`DEFAULT`, `50`..`900` tonal steps, `foreground`), `sage` (`DEFAULT`, `tint`, `strong`, `foreground`), `paper`, `card`, `ink` (body text, = navy-ish), `stone` (`DEFAULT` muted text, `light` placeholder), `line`, `danger` (`DEFAULT`, `tint`, `foreground`), optional `warning` (`DEFAULT`, `tint`). Keep shadcn aliases `background`, `foreground`, `border`, `input`, `ring`, `primary`, `muted`, `accent`, `destructive`, `popover` pointing at those tokens so Radix-based files keep working. +- Produces font families: `font-sans` (Inter, CSS var `--font-inter`), `font-display` (Playfair Display, `--font-playfair`). +- Produces `borderRadius`: `lg` 12px (cards), `md` 9px (controls), `sm` 6px. +- Produces `LEGACY_FILES: string[]` in the guard test, which later tasks shrink. + +- [ ] **Step 1:** Create branch `redesign/frontend` from `main`. Add `.superpowers/` to root `.gitignore`. +- [ ] **Step 2:** Start the app with `./start.sh`, sign in as a seeded student and a seeded admin, and save "before" screenshots of every route at 390px and 1440px to the scratchpad (not the repo). These are the reference for "behavior unchanged". +- [ ] **Step 3: Write the guard test** `noRawColors.test.ts`. It globs `src/**/*.{ts,tsx}` (excluding `*.test.*`, `database.types.ts`) and fails for any file not in `LEGACY_FILES` that matches either regex: + - `/\b(?:bg|text|border|ring|from|via|to|fill|stroke|outline|divide|placeholder|shadow|decoration|accent|caret)-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-\d{2,3}\b/` + - `/#[0-9a-fA-F]{3,8}\b/` inside a `className`, `style`, or `color=` value (ignore `#` in URLs and comments by matching only within quotes/backticks on lines containing `className`, `style`, or `color`). + - Also fails for any file that matches `bg-gradient-` or `animate-(?:float|gradient-x|pulse|bounce)`. + - Second test: `it('legacy allowlist only lists files that still violate')` fails if a listed file is now clean (forces shrinking the list). + - Initialize `LEGACY_FILES` with every currently violating file (generate the list by running the matcher once). +- [ ] **Step 4:** Run `pnpm test -- noRawColors`. Expected: PASS (allowlist covers today's violations). Temporarily add `text-teal-500` to a clean file and confirm it FAILS, then revert. +- [ ] **Step 5:** Replace tokens in `globals.css` (`:root` HSL vars for the palette above, `body` uses `bg-paper text-ink font-sans antialiased`, a `:focus-visible` base ring in sage, `@media (prefers-reduced-motion: reduce)` disabling transitions/animations). Delete `fade-in-up`, `gradient-x`, `float` keyframes and their utility classes only after Task 5 removes their last use (leave a note in the task log until then). Keep the `cecil-arc` spinner CSS. +- [ ] **Step 6:** Rewrite `tailwind.config.js` without `withMT`; add the color, font and radius tokens above; keep `tailwindcss-animate`. +- [ ] **Step 7:** In `layout.tsx` load Inter and Playfair Display via `next/font/google` with `variable` option, drop Geist and `ThemeProvider`, set NextTopLoader color to sage `#3E7C6B` (the one allowed hex outside CSS: add `layout.tsx` to a `TOKEN_FILES` exemption in the guard, with a comment). `pnpm remove @material-tailwind/react geist next-themes` (FAQ keeps working until Task 12 only if it is migrated in the same commit, so migrate the FAQ accordion import to a temporary plain `
` here and finish styling in Task 12). +- [ ] **Step 8:** Run `pnpm type-check && pnpm lint && pnpm test:ci && pnpm knip && pnpm build`. Expected: all pass. +- [ ] **Step 9:** Commit `Add design tokens, fonts and raw color guard`. + +### Task 2: Shared UI kit + +**Files:** + +- Create: the `src/components/ui/` files listed in File Structure (except `RideTicket`), `src/components/ui/ui.test.tsx` +- Modify: `src/components/ui/popover.tsx`, `tooltip.tsx`, `scroll-area.tsx`, `date-picker.tsx` (token restyle only) + +**Interfaces (Produces):** + +- `Button(props: ButtonHTMLAttributes & { variant?: 'primary' | 'secondary' | 'ghost' | 'danger' | 'accent'; size?: 'sm' | 'md' | 'lg'; loading?: boolean; fullWidth?: boolean })`. `primary` = navy fill, `accent` = sage fill, `secondary` = white + line border, `ghost` = text only, `danger` = danger fill. `loading` shows `Spinner` and sets `disabled` + `aria-busy`. +- `ButtonLink(props: LinkProps & same variant/size/fullWidth & { children })` - Next `Link` styled as button. +- `buttonClasses({ variant, size, fullWidth }): string` - exported for non-button elements. +- `Field({ label, htmlFor, hint?, error?, required?, children })`; `Input`, `Textarea`, `Select` forward refs, accept `invalid?: boolean` (sets `aria-invalid` and danger border); `Checkbox({ label, ...input })`. +- `Card({ as?, padded?: boolean, className, children })`, `CardHeader({ title, description?, action? })`, `CardBody`, `CardFooter`. +- `type BadgeTone = 'neutral' | 'success' | 'danger' | 'warning' | 'info'`; `Badge({ tone, dot?: boolean, children })`. +- `type RideStatus = 'matched' | 'ready' | 'waiting' | 'unmatched' | 'cancelled' | 'delayed' | 'past'`; `rideStatusTone(status: RideStatus): BadgeTone`; `StatusBadge({ status, label? })` (default labels: Matched, Ready, Waiting, Unmatched, Cancelled, Delayed, Past). +- `Alert({ tone: 'info' | 'success' | 'warning' | 'danger', title?, children, action? })` with `role="alert"` for danger/warning, `role="status"` otherwise. +- `Modal({ open, onClose, title, description?, children, footer?, size?: 'sm' | 'md' | 'lg' })` - portal, `role="dialog"`, `aria-modal`, labelled by title, Escape and backdrop click call `onClose`, focus moves into the dialog on open and returns to the previously focused element on close, body scroll locked while open. +- `Accordion({ items: { id: string; title: ReactNode; content: ReactNode }[]; defaultOpenId?: string })` - buttons with `aria-expanded` / `aria-controls`. +- `PageContainer({ width?: 'narrow' | 'prose' | 'wide' | 'full', children })` (narrow = max-w-2xl, prose = max-w-3xl, wide = max-w-6xl, full = none, all with `px-4 sm:px-6`), `PageHeader({ eyebrow?, title, description?, actions? })` (title in `font-display`). +- `EmptyState({ icon?: LucideIcon, title, description?, action? })`. +- `Spinner({ size?: 'sm' | 'md' | 'lg', label?: string })` - uses `animate-spin`, `role="status"`, visually hidden label default "Loading". + +- [ ] **Step 1: Write failing tests** in `ui.test.tsx`: + - `rideStatusTone`: `matched`→`success`, `ready`→`success`, `waiting`→`neutral`, `unmatched`→`neutral`, `past`→`neutral`, `cancelled`→`danger`, `delayed`→`warning`. + - `Button loading` renders `aria-busy="true"`, is disabled, and contains `role="status"`. + - `Input invalid` sets `aria-invalid="true"`; `Field` associates label with input (`getByLabelText('Email')` returns the input) and renders `error` text linked by `aria-describedby`. + - `Modal`: when `open`, `getByRole('dialog', { name: 'Title' })` exists; pressing Escape calls `onClose`; focus is inside the dialog after open; on rerender with `open=false`, focus returns to the trigger button. + - `Accordion`: clicking a title toggles `aria-expanded` from `false` to `true` and shows content; only `defaultOpenId` is open initially. + - `Alert tone="danger"` has `role="alert"`. +- [ ] **Step 2:** Run `pnpm test -- ui.test`. Expected: FAIL (modules not found). +- [ ] **Step 3:** Implement the components to the interfaces above using `cn` from `@/utils/tailwind` and only token classes. Restyle popover/tooltip/scroll-area/date-picker with tokens (day picker: selected day navy, today ring sage, disabled stone-light). +- [ ] **Step 4:** Run `pnpm test -- ui.test`. Expected: PASS. +- [ ] **Step 5:** Build a temporary unlisted route `src/app/_kit/page.tsx` showing every component and state; inspect it in Chrome at 360px and 1440px for spacing, alignment, focus rings, contrast; fix issues; delete the route. +- [ ] **Step 6:** Run full CI command set from Task 1 Step 8. Commit `Add shared UI kit`. + +### Task 3: Header, footer, sign-in modal + +**Files:** + +- Modify: `src/components/PickupHeader.tsx`, `src/components/PickupFooter.tsx`, `src/components/SignInModal.tsx` +- Create: `src/components/PickupHeader.test.tsx` +- Remove: `src/components/buttons/SimpleRedirectButton.tsx`, `RedirectButton.tsx` once no imports remain (check with `pnpm knip`) + +**Interfaces:** + +- Consumes: `Modal`, `Button`, `buttonClasses` from Task 2; `useAuth()` (`user`, `avatarUrl`, `isAdmin`, `signOut`, `signInWithGoogle`). +- Produces: `NavLink({ href, children, variant: 'header' | 'mobile' | 'footer', onNavigate? })` in `src/components/NavLink.tsx`, preserving `SimpleRedirectButton`'s behavior: `aria-current="page"` when active (exact or prefix match), click on current exact route is prevented. + +- [ ] **Step 1: Write failing tests** (mock `useAuth`, `next/navigation`): + - Signed-out: no "Dashboard" link; "Sign in" button present; clicking profile area opens dialog named "Sign in". + - Non-admin signed-in: no "Dashboard" link in the DOM at all (not just hidden). + - Admin: "Dashboard" link to `/admin` present. + - Mobile menu: toggle button has `aria-expanded`, opening it shows nav links, pressing Escape closes it and returns focus to the toggle. + - With pathname `/results`, the Results link has `aria-current="page"`. +- [ ] **Step 2:** Run, expect FAIL. +- [ ] **Step 3:** Rebuild header: navy bar (`h-16`), left: logo on white `rounded-lg` tile + "PICKUP" wordmark with "by ASPC" small caps in navy-200; desktop nav (`md:` and up) with Forms, Results, About, FAQ, and Dashboard for admins, sage underline for active; right: avatar button (profile) or "Sign in" secondary-on-navy button; mobile: hamburger opening a full-height paper sheet with large links and sign out. Remove the "always rendered but invisible" Dashboard trick; reserve layout width instead to avoid shift. Footer: paper with top hairline, links About, Contact, FAQ, ASPC Info, and "PICKUP is a service of the Associated Students of Pomona College". SignInModal uses `Modal` + Google button (`Button variant="primary"`). +- [ ] **Step 4:** Run tests, expect PASS. Remove header/footer/SignInModal from `LEGACY_FILES`; guard passes. +- [ ] **Step 5:** E2E in Chrome at 360, 390, 768, 1440 as signed-out, student, admin. Check no layout shift when auth resolves. +- [ ] **Step 6:** CI set, commit `Redesign header, footer and sign-in modal`. + +### Task 4: Boarding-pass RideTicket + +**Files:** + +- Create: `src/components/ui/RideTicket.tsx`, `src/components/ui/RideTicket.test.tsx` + +**Interfaces (Produces):** + +- `RideTicket({ date: string | null, time: string | null, airport: string, toAirport: boolean, status: RideStatus, stub?: ReactNode, children?: ReactNode, timeLabel?: string })`. +- Origin/destination codes: campus code is `CLA` (label "Claremont"); `toAirport` true → `CLA` then airport, false → airport then `CLA`. Time is formatted with existing `formatTime12Hour` from `@/utils/formatTime`; date shown as `Fri, Dec 12` using the parse approach in `date-picker.tsx` (no UTC shift). +- `children` render below the route (details, actions); `stub` renders below the dashed perforation. + +- [ ] **Step 1: Write failing tests:** `toAirport=true, airport='LAX'` renders codes in order `CLA`, `LAX`; `toAirport=false, airport='ONT'` renders `ONT`, `CLA`; `date='2026-12-12'` renders `Sat, Dec 12` regardless of TZ (run with `TZ=America/Los_Angeles` and `TZ=UTC` via `process.env.TZ` in test); `status='matched'` renders a `StatusBadge` with text Matched; route has an accessible label like "Claremont to LAX". +- [ ] **Step 2:** Run, expect FAIL. **Step 3:** Implement per spec's signature element description; codes `text-2xl font-semibold tracking-wide tabular-nums`; dashed line `border-dashed border-line`; perforation: dashed top border plus two paper-colored half-circle notches at the edges. Long `stub` text wraps. **Step 4:** Run, expect PASS. +- [ ] **Step 5:** Commit `Add boarding-pass RideTicket`. + +### Task 5: Home and error page + +**Files:** Modify `src/app/page.tsx`, `src/app/error.tsx`. + +- [ ] **Step 1:** Rebuild home keeping `handleGetStarted` logic untouched: paper hero (eyebrow in sage, Playfair headline "Split the ride to the airport.", supporting copy keeping the "$100+" message, primary CTA "Sign in with Google" / "Get started"), a three-step "How it works" row (Submit your flight → We match you → Ride together) with lucide icons in navy on sage-tint tiles, then a short ASPC subsidy/info strip linking to `/aspc-info`, and an FAQ link. No full-viewport-height hero on mobile; content starts above the fold. +- [ ] **Step 2:** Error page: `PageContainer narrow` + `EmptyState` with retry `Button` calling `reset`. +- [ ] **Step 3:** Remove both from `LEGACY_FILES`; delete now-unused `fade-in-up`/`gradient-x`/`float` CSS (grep first). Guard + CI pass. +- [ ] **Step 4:** E2E: signed-out CTA triggers Google sign-in, signed-in with incomplete profile routes to `/profile`, complete to `/questionnaires`. Check 360/390/1440. +- [ ] **Step 5:** Commit `Redesign home and error page`. + +### Task 6: Profile + +**Files:** Modify `src/app/profile/page.tsx`. + +- [ ] **Step 1:** Restyle with `PageContainer narrow`, `PageHeader`, `Card` sections, `Field`/`Input`/`Select`, avatar upload area, `Button` loading states, `Alert` for save success/error. Keep every handler, validation, and state variable. +- [ ] **Step 2:** Remove from `LEGACY_FILES`; guard + CI pass. +- [ ] **Step 3:** E2E: edit and save each field, trigger a validation error, upload avatar, check header avatar refresh; 360/390/1440. +- [ ] **Step 4:** Commit `Redesign profile page`. + +### Task 7: Flight forms + +**Files:** Modify `src/components/forms/FlightForm.tsx`, `src/app/questionnaires/page.tsx`, `src/app/matchForm/page.tsx`, `src/app/editForm/[flight_id]/page.tsx`, `src/components/questionnaires/ConfirmCancel.tsx`, `ManyBagsNotice.tsx`, `SubmitSuccess.tsx`. + +- [ ] **Step 1:** While restyling `FlightForm.tsx`, split presentational sections into `src/components/forms/flight-form/` files (one per visual section, e.g. `TripSection.tsx`, `TimeWindowSection.tsx`, `LuggageSection.tsx`, `PreferencesSection.tsx`, `ReviewSection.tsx`), each receiving values and callbacks as props; state, validation and submit logic stay in `FlightForm.tsx`. Use `Field` components, `DatePicker`, segmented control for to/from airport built from `buttonClasses`, sticky bottom submit bar on mobile. +- [ ] **Step 2:** Questionnaires list: each submitted flight as a `RideTicket` with status (`waiting` / `matched` / `past`) and edit/cancel actions; `ConfirmCancel` uses `Modal`; `ManyBagsNotice` uses `Alert warning`; `SubmitSuccess` uses `EmptyState`-style success panel. +- [ ] **Step 3:** Remove all listed files from `LEGACY_FILES`; guard + CI pass (including `flightValidation` and `studentCommands` tests untouched). +- [ ] **Step 4:** E2E: submit a new flight (to and from airport), trigger each validation error, edit an existing flight, cancel one, many-bags notice; deadline-closed state; 360/390/1440. +- [ ] **Step 5:** Commit `Redesign flight forms and questionnaires`. + +### Task 8: Results + +**Files:** Modify `src/app/results/page.tsx`, `src/app/results/layout.tsx`, `src/components/results/MatchCard.tsx`, `CommentSection.tsx`, `ConfirmCancelMatch.tsx`. Remove `src/components/results/EmptyState.tsx` in favor of the kit. + +- [ ] **Step 1:** `MatchCard` renders `RideTicket` (status from `isGroupReady`/`upcoming`), group members as avatar list with names and contact links, voucher and Uber type in the stub, add-to-calendar and airport address actions as `Button secondary sm`, cancel via `ConfirmCancelMatch` on `Modal`. Upcoming and past sections with headings. `CommentSection` as a simple thread inside the card. +- [ ] **Step 2:** Remove files from `LEGACY_FILES`; guard + CI pass. +- [ ] **Step 3:** E2E with seeded matches: upcoming + past, ready group, 6-person group, long names, comment post, calendar download, cancel; no-match empty state; 360/390/1440. +- [ ] **Step 4:** Commit `Redesign results`. + +### Task 9: Unmatched and match requests + +**Files:** Modify `src/app/unmatched/page.tsx`, `src/app/unmatched/layout.tsx`, `src/app/MatchRequestsPage/page.tsx`. + +- [ ] **Step 1:** Unmatched flights as `RideTicket status="unmatched"`; other riders list as compact cards; request actions as `Button`; info `Alert` explaining next steps. Same for match requests page. +- [ ] **Step 2:** Guard + CI. **Step 3:** E2E with `NEXT_PUBLIC_ENABLE_MATCH_REQUESTS` both `true` and `false`; empty state; 360/1440. **Step 4:** Commit `Redesign unmatched and match requests`. + +### Task 10: ASPC delay and ready flows + +**Files:** Modify `src/app/aspc-delay/page.tsx`, `src/app/aspc-delay/[rideId]/page.tsx`, `src/components/aspc-delay/*.tsx`, `src/app/aspc-ready/page.tsx`. + +- [ ] **Step 1:** Multi-step delay flow gets a step indicator (numbered, navy current, sage done), one `Card` per step, sticky back/next bar on mobile, `RideTicket status="delayed"` summary. Ready page: large clear confirm action, group summary as `RideTicket status="ready"`. +- [ ] **Step 2:** Guard + CI. **Step 3:** E2E through every delay step, including validation errors and the new-flight step; ready confirmation; 360/1440. **Step 4:** Commit `Redesign ASPC delay and ready flows`. + +### Task 11: Feedback + +**Files:** Modify `src/app/feedback/page.tsx`, `src/components/feedback/StarRating.tsx`. + +- [ ] **Step 1:** Form in `Card`s with `Field`s; `StarRating` stars in navy filled / line outline, keyboard operable as a radio group (`role="radiogroup"`, arrow keys). Add a test in `src/components/feedback/StarRating.test.tsx`: arrow right increases selection, each star has an accessible name "N stars". +- [ ] **Step 2:** Run test, FAIL, implement, PASS. Guard + CI. **Step 3:** E2E submit; 360/1440. **Step 4:** Commit `Redesign feedback`. + +### Task 12: Info pages + +**Files:** Modify `src/app/about/page.tsx`, `contact/page.tsx`, `faq/page.tsx`, `aspc-info/page.tsx`, `aspc-fees/page.tsx`, `aspc-policy/page.tsx`. + +- [ ] **Step 1:** `PageContainer prose` + `PageHeader`; consistent prose styles (headings, lists, tables for fees using `line` borders, callouts as `Alert`). FAQ uses `Accordion`. About keeps `teampic.jpg` with rounded corners. +- [ ] **Step 2:** Guard + CI. **Step 3:** E2E read-through at 360/1440, check tables don't overflow (wrap in horizontal scroll container on mobile). **Step 4:** Commit `Redesign info pages`. + +### Task 13: Admin dashboard + +**Files:** Modify `src/app/admin/layout.tsx`, `src/components/admin/AdminDashboard.tsx`, `AddRider.tsx`, `EmailComposerModal.tsx`. + +- [ ] **Step 1:** `PageContainer full`, admin sub-nav (Dashboard, Groups) as tabs, stat tiles as `Card`s, tables with sticky header, zebra-free rows separated by `line`, compact `Badge`s, `Button size="sm"`. `EmailComposerModal` on `Modal size="lg"`. Keep `.animate-spin` loading indicator (via `Spinner`). +- [ ] **Step 2:** Run `pnpm test -- AdminDashboard`; update only selectors that targeted removed classes, never assertions. Guard + CI. +- [ ] **Step 3:** E2E as admin at 1440 and 1024: add rider, compose email (do not send to real addresses; local DB only), filters, loading/empty states. **Step 4:** Commit `Redesign admin dashboard`. + +### Task 14: Admin groups management + +**Files:** Modify `src/components/admin/GroupsManagement.tsx` and every `.tsx` under `src/components/admin/groups-management/`. + +- [ ] **Step 1:** Restyle panels (`FiltersPanel`, `UnmatchedRidersPanel`, `MatchedGroupsPanel`, `CorralPanel`, `CreateGroupPanel`, `ChangesPanel`, `ChangeLogPanel`, `GroupsManagementModals`) with kit components and tokens. Groups shown as compact cards (route codes, time, members, voucher); drag/select states in sage-tint; destructive actions danger. Keep density: no larger than current row heights. +- [ ] **Step 2:** Run `pnpm test -- GroupsManagement UnmatchedRidersPanel`; selector-only updates. Guard + CI. +- [ ] **Step 3:** E2E as admin at 1440: filter, create group, move rider, corral, view changes and change log, export. **Step 4:** Commit `Redesign admin groups management`. + +### Task 15: Final sweep and PR + +**Files:** Modify `src/styles/noRawColors.test.ts`, any stragglers. + +- [ ] **Step 1:** Add assertion `expect(LEGACY_FILES).toEqual([])`; fix any remaining files. Remove unused components/exports flagged by `pnpm knip` and `pnpm knip:production`. +- [ ] **Step 2:** Full CI set passes; `pnpm format-check` passes; `grep -rn "—" src` returns nothing. +- [ ] **Step 3:** Full E2E pass of every route as signed-out, student and admin at 360, 390 and 1440, compared against the "before" screenshots for missing features. Fix anything off, however small. +- [ ] **Step 4:** Commit, push branch, open PR to `main` with a summary and before/after screenshots (no Claude attribution). diff --git a/docs/superpowers/specs/2026-10-28-frontend-redesign-design.md b/docs/superpowers/specs/2026-10-28-frontend-redesign-design.md new file mode 100644 index 0000000..d996ef3 --- /dev/null +++ b/docs/superpowers/specs/2026-10-28-frontend-redesign-design.md @@ -0,0 +1,128 @@ +# PICKUP frontend redesign - design + +Date: 2026-10-28 +Status: draft, awaiting approval + +## Intent + +PICKUP groups Claremont students into shared airport rides. The current frontend works but looks unfinished: a teal-to-pale-yellow gradient header and footer, floating blobs, pulsing text, and raw Tailwind teal / blue / indigo / yellow / red used with no shared meaning. Two styling systems coexist (shadcn-style CSS tokens that are mostly unused, plus Material Tailwind). + +The redesign should make PICKUP look like a member of the ASPC family (see `../aspc-website-v2`) while keeping its own personality, with a **clean and natural** feel. All existing functionality stays exactly as it is. + +## Users and devices + +- **Students, mostly on phones.** Every student screen is designed mobile-first and must look excellent at 360-430px wide, then scale up. +- **Admins, on laptops.** Admin screens are designed for 1280px+ first, using the same tokens and components but denser layouts. They must remain usable (not necessarily pretty) on tablets. + +## Goals + +1. One small, disciplined palette, enforced through tokens. No page may use raw Tailwind color scales (`teal-500`, `blue-600`, `gray-700`, ...) or hex values. +2. Visual kinship with ASPC: navy header, Inter body text, Playfair Display headings, white surfaces. +3. PICKUP's own identity through the sage accent and the boarding-pass ride card. +4. A shared component set (button, input, select, textarea, card, badge, modal, alert, page header, empty state, etc.) used by every page, so the look stays consistent and future pages inherit it. +5. Pixel-level polish: consistent spacing scale, alignment, focus states, hover/active states, loading and empty states, no layout shift. + +## Non-goals + +- No changes to behavior, data flow, routes, API routes, Supabase queries, auth, edge functions, or the ML pipeline. +- No rename and no new logo. Keep the name **PICKUP** and the current logo files (`/favicon.png`, `/favicon.ico`). +- No dark mode in this pass (no page uses `dark:` today). Light theme only. +- No new features. + +## Anti-goals (failure even if it "works") + +- Gradients, glowing blobs, floating shapes, pulsing or bouncing decorative text, rainbow of accent colors. +- A generic "AI template" look: centered hero with emoji, purple gradients, glassmorphism. +- Any regression in a student or admin flow, or any change in copy meaning. +- Admin tables and panels becoming less information-dense or slower to work in. + +## Visual system (decided) + +### Palette + +| Token | Value | Use | +| -------------------- | -------------------------------------- | ------------------------------------------------------------ | +| `navy` (primary) | `#13294B` | Header bar, headings, primary buttons, brand | +| `sage` (accent) | `#3E7C6B` | "Go / matched", success, links, small highlights, focus ring | +| `sage-tint` | approx `#E3EDE8` | Background behind sage badges and success alerts | +| `paper` (background) | `#F7F5F0` | Page background | +| `white` (card) | `#FFFFFF` | Cards, inputs, modals | +| `stone` (muted fg) | approx `#6B7280` family | Secondary text, placeholders, icons | +| `line` (border) | approx `#E7E3DA` | Hairline borders and dividers (warm, matches paper) | +| `danger` | a muted red, e.g. `#B42318` + its tint | Errors and destructive actions only | + +The builder may add tonal steps of navy and sage (for hover/pressed states, and a lighter navy for header text such as `#C9D3E3`) and a warm amber for "warning / pending action" states **only if a real state needs it**. Every color must be a named token in `globals.css` and `tailwind.config.js`; nothing else is allowed. + +### Typography + +- **Body/UI:** Inter (via `next/font/google`), replacing Geist. +- **Display:** Playfair Display for page titles (h1) and hero headlines only. Section headings and everything inside cards stay in Inter. +- A defined type scale (e.g. display, h1, h2, h3, body, small, caption, eyebrow) used everywhere. + +### Surfaces and shape + +- Paper page, white cards with a 1px warm hairline border. Shadows minimal (at most a subtle shadow on popovers/modals). +- Corner radius around 10-14px for cards, 8-10px for controls. Consistent across the app. +- Generous whitespace on student pages; tighter spacing on admin pages. + +### Header and footer + +- **Header:** solid navy bar like ASPC's. Logo + "PICKUP" wordmark with a small "by ASPC" line. Desktop: text nav links (Forms, Results, info pages, Dashboard for admins), profile avatar / sign-in. Mobile: hamburger opening a clean full-height navy or paper sheet. The current behaviors (admin Dashboard link, sign-in modal, sign-out, avatar refresh, active-route highlighting, preventing re-navigation to the current page) must all be preserved. +- **Footer:** quiet: paper or navy, with About, Contact, FAQ, ASPC Info links and a small ASPC attribution. + +### Signature element: boarding-pass ride card + +A ride/match is shown as a boarding pass: date and status badge on top; large origin and destination codes (e.g. `CLA` to `LAX`) joined by a dashed line, with time underneath; a dashed perforation separating a stub with group size and pickup location. Used on Results (`MatchCard`) and anywhere a ride summary appears (profile, unmatched, delay flow). Status badges use a dot plus a label: matched = sage, waiting/unmatched = stone, cancelled/error = danger. + +### Motion + +Subtle and functional only: short (150-200ms) color/opacity transitions, gentle enter for modals and the mobile menu, respecting `prefers-reduced-motion`. Keep the existing Cecil loading spinner and NextTopLoader (recolored to navy or sage). + +## Scope: every screen + +Student and public: + +- `/` home (hero, how it works, CTA logic for signed-in vs signed-out) +- `/profile` +- `/questionnaires`, `/matchForm`, `/editForm/[flight_id]` and `components/forms/FlightForm.tsx` (largest form, 2.6k lines) +- `/results` (+ `MatchCard`, `CommentSection`, `ConfirmCancelMatch`, `EmptyState`) +- `/unmatched`, `/MatchRequestsPage` (behind `NEXT_PUBLIC_ENABLE_MATCH_REQUESTS`) +- `/aspc-delay`, `/aspc-delay/[rideId]` and `components/aspc-delay/*` +- `/aspc-ready`, `/aspc-info`, `/aspc-fees`, `/aspc-policy` +- `/feedback` (+ `StarRating`) +- `/about`, `/contact`, `/faq` (drop Material Tailwind's accordion for a small in-house one) +- `error.tsx`, `SignInModal`, `components/questionnaires/*` + +Admin: + +- `/admin` (`AdminDashboard`, `AddRider`, `EmailComposerModal`) +- `/admin/groups` (`GroupsManagement` and everything in `groups-management/`) + +## Constraints + +- Stack stays: Next.js 15 App Router, React 18, Tailwind 3, Supabase. Keep existing Radix primitives (popover, tooltip, scroll-area) and `react-day-picker`; restyle them. +- Remove `@material-tailwind/react` (only used by the FAQ) and the `withMT` wrapper in `tailwind.config.js`. Remove `geist`. Remove `next-themes` / `ThemeProvider` if nothing else needs it after going light-only. Clean up unused custom animations in `globals.css`. +- CI must stay green: `pnpm type-check`, `pnpm knip`, `pnpm knip:production`, `pnpm lint`, `pnpm test:ci`, `pnpm build`. Existing tests (e.g. `AdminDashboard.test.tsx`, `GroupsManagement.test.tsx`, `UnmatchedRidersPanel.test.tsx`) must keep passing; update selectors only if they relied on visual classes, never weaken assertions. +- Accessibility: WCAG AA contrast for all text, visible focus rings, proper labels, 44px minimum touch targets on mobile. +- Prettier formatting as configured in the repo. No em dashes in copy or code. + +## How the work is verified + +- Run locally with `./start.sh` (local Supabase with seeded fake users and flights), sign in, and walk every flow end to end in a real browser at phone width (390px) and laptop width (1440px), as both a student and an admin. +- Screenshot each screen before and after for comparison. +- All CI checks above pass. + +## Calls made during review (not discussed explicitly) + +- **Logo:** the current logo is a cartoon mint car. It stays unchanged, sitting in a small white/paper rounded tile on the navy header so its mint glow does not clash with sage. Revisit if a new mark is designed later. +- **Delivery:** all work happens on one feature branch (`redesign/frontend`) with a commit per phase, merged as a single PR. `main` deploys to production on Netlify, so shipping half the pages restyled would look broken; the Netlify deploy preview on the PR is used for review. +- **Home hero:** light paper hero with a Playfair headline (as in the approved mockup), no photo and no navy hero block. +- **Wide layouts:** student pages use a centered single column (max around 640-720px) even on desktop; info pages use a readable prose width; admin uses full width. + +## Left to the builder + +- Exact tonal steps, spacing scale and type scale values, within the rules above. +- Component APIs and file layout for the shared UI kit (expected under `src/components/ui/`). +- The order pages are rebuilt in. Expected order: tokens and UI kit, then header and footer, then the student flow in the order students hit it, then info pages, then admin. +- How to restructure very large files (`FlightForm.tsx`, `GroupsManagement.tsx`) during restyling, provided behavior is unchanged and tests pass. +- Copy may be tightened for clarity, but meaning and instructions must stay the same. diff --git a/frontend/package.json b/frontend/package.json index 7f26144..dd9ef9e 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -46,10 +46,8 @@ "@types/react-dom": "18.2.5", "autoprefixer": "10.6.1", "clsx": "^2.1.0", - "geist": "^1.8.2", "lucide-react": "^0.304.0", "next": "15.5.28", - "next-themes": "^0.4.6", "nextjs-toploader": "^1.6.4", "react": "18.2.0", "react-day-picker": "^10.0.2", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 076fa83..c49d6c8 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -56,18 +56,12 @@ importers: clsx: specifier: ^2.1.0 version: 2.1.1 - geist: - specifier: ^1.8.2 - version: 1.8.2(next@15.5.28(@babel/core@7.29.6)(@types/node@20.3.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)) lucide-react: specifier: ^0.304.0 version: 0.304.0(react@18.2.0) next: specifier: 15.5.28 version: 15.5.28(@babel/core@7.29.6)(@types/node@20.3.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - next-themes: - specifier: ^0.4.6 - version: 0.4.6(react-dom@18.2.0(react@18.2.0))(react@18.2.0) nextjs-toploader: specifier: ^1.6.4 version: 1.6.12(next@15.5.28(@babel/core@7.29.6)(@types/node@20.3.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0))(react-dom@18.2.0(react@18.2.0))(react@18.2.0) @@ -2546,11 +2540,6 @@ packages: functions-have-names@1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} - geist@1.8.2: - resolution: {integrity: sha512-fRF4sbJ9qcCxPb35cVtKBAwYlTt1IbU9nkbPi0a+xyZqPIjCJ2BY8ekGhx6/SGSZKrR7/UuL57r/eeDQ1Xy11g==} - peerDependencies: - next: '>=13.2.0' - generator-function@2.0.1: resolution: {integrity: sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==} engines: {node: '>= 0.4'} @@ -3281,12 +3270,6 @@ packages: natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - next-themes@0.4.6: - resolution: {integrity: sha512-pZvgD5L0IEvX5/9GWyHMf3m8BKiVQwsCMHfoFosXtXBMnaS0ZnIJ9ST4b4NqLVKDEm8QBxoNNGNaBv2JNF6XNA==} - peerDependencies: - react: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc - react-dom: ^16.8 || ^17 || ^18 || ^19 || ^19.0.0-rc - next@15.5.28: resolution: {integrity: sha512-JjhLBBY1PNnuwPtcZ7t8yxVeJVYvD2Jyp633J+gRCNbzSt7N0E+xqCf6uQiff3+3qmUkwcF/ksfSsK1xsZ76Tw==} engines: {node: ^18.18.0 || ^19.8.0 || >= 20.0.0} @@ -6899,10 +6882,6 @@ snapshots: functions-have-names@1.2.3: {} - geist@1.8.2(next@15.5.28(@babel/core@7.29.6)(@types/node@20.3.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)): - dependencies: - next: 15.5.28(@babel/core@7.29.6)(@types/node@20.3.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0) - generator-function@2.0.1: {} gensync@1.0.0-beta.2: {} @@ -7819,11 +7798,6 @@ snapshots: natural-compare@1.4.0: {} - next-themes@0.4.6(react-dom@18.2.0(react@18.2.0))(react@18.2.0): - dependencies: - react: 18.2.0 - react-dom: 18.2.0(react@18.2.0) - next@15.5.28(@babel/core@7.29.6)(@types/node@20.3.1)(react-dom@18.2.0(react@18.2.0))(react@18.2.0): dependencies: '@next/env': 15.5.28 diff --git a/frontend/src/app/globals.css b/frontend/src/app/globals.css index 76c7bdd..f965b65 100644 --- a/frontend/src/app/globals.css +++ b/frontend/src/app/globals.css @@ -4,35 +4,38 @@ @layer base { :root { - --background: 0 0% 100%; - --foreground: 240 10% 3.9%; - --card: 0 0% 100%; - --card-foreground: 240 10% 3.9%; - --popover: 0 0% 100%; - --popover-foreground: 240 10% 3.9%; - --primary: 240 5.9% 10%; - --primary-foreground: 0 0% 98%; - --secondary: 240 4.8% 95.9%; - --secondary-foreground: 240 5.9% 10%; - --muted: 240 4.8% 95.9%; - --muted-foreground: 240 3.8% 46.1%; - --accent: 240 4.8% 95.9%; - --accent-foreground: 240 5.9% 10%; - --destructive: 0 84.2% 60.2%; - --destructive-foreground: 0 0% 98%; - --border: 240 5.9% 90%; - --input: 240 5.9% 90%; - --ring: 240 5.9% 10%; - --radius: 0.3rem; + --color-sage: theme('colors.sage.DEFAULT'); } -} -@layer base { - * { - @apply border-border; + html { + -webkit-text-size-adjust: 100%; } + body { - @apply bg-background text-foreground; + @apply bg-paper font-sans text-ink antialiased; + } + + * { + @apply border-line; + } + + :focus-visible { + @apply outline-none ring-2 ring-sage ring-offset-2 ring-offset-paper; + } + + ::selection { + @apply bg-sage-tint text-navy; + } +} + +@media (prefers-reduced-motion: reduce) { + *, + *::before, + *::after { + animation-duration: 0.01ms !important; + animation-iteration-count: 1 !important; + transition-duration: 0.01ms !important; + scroll-behavior: auto !important; } } diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx index d1d695e..1519bf3 100644 --- a/frontend/src/app/layout.tsx +++ b/frontend/src/app/layout.tsx @@ -1,5 +1,4 @@ -import { GeistSans } from 'geist/font/sans' -import ThemeProvider from '@/providers/ThemeProvider' +import { Inter, Playfair_Display } from 'next/font/google' import NextTopLoader from 'nextjs-toploader' import './globals.css' import PickupHeader from '@/components/PickupHeader' @@ -7,6 +6,19 @@ import PickupFooter from '@/components/PickupFooter' import { TooltipProvider } from '@/components/ui/tooltip' import { AuthProvider } from '@/providers/AuthProvider' +const inter = Inter({ + subsets: ['latin'], + variable: '--font-inter', + display: 'swap', +}) + +const playfair = Playfair_Display({ + subsets: ['latin'], + weight: ['600', '700'], + variable: '--font-playfair', + display: 'swap', +}) + const defaultUrl = process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000' @@ -27,20 +39,22 @@ export default function RootLayout({ children: React.ReactNode }) { return ( - - - - - - -
- -
{children}
- -
-
-
-
+ + + + + +
+ +
{children}
+ +
+
+
) diff --git a/frontend/src/providers/ThemeProvider.tsx b/frontend/src/providers/ThemeProvider.tsx deleted file mode 100644 index f3f78b4..0000000 --- a/frontend/src/providers/ThemeProvider.tsx +++ /dev/null @@ -1,12 +0,0 @@ -'use client' - -import { - ThemeProvider as NextThemesProvider, - type ThemeProviderProps, -} from 'next-themes' - -const ThemeProvider = ({ children, ...props }: ThemeProviderProps) => ( - {children} -) - -export default ThemeProvider diff --git a/frontend/src/styles/noRawColors.test.ts b/frontend/src/styles/noRawColors.test.ts new file mode 100644 index 0000000..0be41a4 --- /dev/null +++ b/frontend/src/styles/noRawColors.test.ts @@ -0,0 +1,109 @@ +import fs from 'fs' +import path from 'path' + +// Colors must come from the design tokens in globals.css / tailwind.config.js. +// This guard fails for any source file that reaches for a raw Tailwind palette +// class, a hex color, a gradient or a decorative animation. + +const SRC = path.join(__dirname, '..') + +const RAW_PALETTE = + /\b(?:bg|text|border(?:-[trblxy])?|ring|ring-offset|from|via|to|fill|stroke|outline|divide|placeholder|shadow|decoration|accent|caret)-(?:slate|gray|zinc|neutral|stone|red|orange|amber|yellow|lime|green|emerald|teal|cyan|sky|blue|indigo|violet|purple|fuchsia|pink|rose)-\d{2,3}\b/ +const HEX_COLOR = + /(?:['"`[(]|:\s*)#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})\b/ +const DECORATION = + /\bbg-gradient-|\banimate-(?:float|gradient-x|pulse|bounce)\b/ + +// Files not yet migrated to the design system. Shrinks to empty. +const LEGACY_FILES: string[] = [ + 'app/about/page.tsx', + 'app/aspc-delay/[rideId]/page.tsx', + 'app/aspc-delay/page.tsx', + 'app/aspc-fees/page.tsx', + 'app/aspc-info/page.tsx', + 'app/aspc-policy/page.tsx', + 'app/aspc-ready/page.tsx', + 'app/contact/page.tsx', + 'app/editForm/[flight_id]/page.tsx', + 'app/faq/page.tsx', + 'app/feedback/page.tsx', + 'app/matchForm/page.tsx', + 'app/MatchRequestsPage/page.tsx', + 'app/page.tsx', + 'app/profile/page.tsx', + 'app/questionnaires/page.tsx', + 'app/results/page.tsx', + 'app/unmatched/page.tsx', + 'components/admin/AddRider.tsx', + 'components/admin/AdminDashboard.tsx', + 'components/admin/EmailComposerModal.tsx', + 'components/admin/groups-management/ChangeLogPanel.tsx', + 'components/admin/groups-management/ChangesPanel.tsx', + 'components/admin/groups-management/CorralPanel.tsx', + 'components/admin/groups-management/CreateGroupPanel.tsx', + 'components/admin/groups-management/FiltersPanel.tsx', + 'components/admin/groups-management/GroupsManagementModals.tsx', + 'components/admin/groups-management/MatchedGroupsPanel.tsx', + 'components/admin/groups-management/UnmatchedRidersPanel.tsx', + 'components/admin/groups-management/utils/rules.ts', + 'components/admin/GroupsManagement.tsx', + 'components/aspc-delay/DelayInfoStep.tsx', + 'components/aspc-delay/FlightConfirmStep.tsx', + 'components/aspc-delay/NewFlightStep.tsx', + 'components/aspc-delay/ReasonForDelayStep.tsx', + 'components/buttons/RedirectButton.tsx', + 'components/buttons/SimpleRedirectButton.tsx', + 'components/feedback/StarRating.tsx', + 'components/forms/FlightForm.tsx', + 'components/PickupFooter.tsx', + 'components/PickupHeader.tsx', + 'components/questionnaires/ConfirmCancel.tsx', + 'components/questionnaires/ManyBagsNotice.tsx', + 'components/questionnaires/SubmitSuccess.tsx', + 'components/results/CommentSection.tsx', + 'components/results/ConfirmCancelMatch.tsx', + 'components/results/EmptyState.tsx', + 'components/results/MatchCard.tsx', + 'components/SignInModal.tsx', + 'components/ui/date-picker.tsx', + 'components/ui/popover.tsx', +] + +const listSourceFiles = (dir: string): string[] => + fs.readdirSync(dir, { withFileTypes: true }).flatMap((entry) => { + const full = path.join(dir, entry.name) + if (entry.isDirectory()) return listSourceFiles(full) + if (!/\.(ts|tsx)$/.test(entry.name)) return [] + if (/\.test\.(ts|tsx)$/.test(entry.name)) return [] + if (entry.name === 'database.types.ts') return [] + return [path.relative(SRC, full)] + }) + +const findViolations = (file: string): string[] => + fs + .readFileSync(path.join(SRC, file), 'utf8') + .split('\n') + .flatMap((line, index) => + [RAW_PALETTE, HEX_COLOR, DECORATION] + .map((pattern) => line.match(pattern)?.[0]) + .filter((match): match is string => Boolean(match)) + .map((match) => `${file}:${index + 1} ${match}`), + ) + +describe('design tokens', () => { + const files = listSourceFiles(SRC) + + it('uses no raw colors, gradients or decorative animations', () => { + const violations = files + .filter((file) => !LEGACY_FILES.includes(file)) + .flatMap(findViolations) + expect(violations).toEqual([]) + }) + + it('only lists legacy files that still violate', () => { + const clean = LEGACY_FILES.filter( + (file) => !files.includes(file) || findViolations(file).length === 0, + ) + expect(clean).toEqual([]) + }) +}) diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js index 5cf27d4..0470eea 100644 --- a/frontend/tailwind.config.js +++ b/frontend/tailwind.config.js @@ -1,4 +1,49 @@ const withMT = require('@material-tailwind/react/utils/withMT') +const defaultTheme = require('tailwindcss/defaultTheme') + +// PICKUP design tokens. Every color used in the app is named here; pages must +// not reach for Tailwind's raw palettes (enforced by src/styles/noRawColors.test.ts). +const palette = { + navy: { + 50: '#EEF1F6', + 100: '#DCE3EE', + 200: '#C9D3E3', + 300: '#9AABC6', + 400: '#6A80A3', + 500: '#43597E', + 600: '#2A4068', + 700: '#1C3358', + DEFAULT: '#13294B', + 900: '#0C1C36', + }, + sage: { + DEFAULT: '#3E7C6B', + strong: '#2F6355', + soft: '#7FB8A4', + tint: '#E3EDE8', + }, + ink: '#18233A', + stone: { + DEFAULT: '#5F6878', + light: '#8E95A2', + }, + paper: '#F7F5F0', + sunken: '#F0EDE6', + card: '#FFFFFF', + line: { + DEFAULT: '#E7E3DA', + strong: '#D3CEC2', + }, + danger: { + DEFAULT: '#B42318', + strong: '#912018', + tint: '#FDECEA', + }, + warning: { + DEFAULT: '#8A5A0B', + tint: '#FBF0D9', + }, +} /** @type {import('tailwindcss').Config} */ module.exports = withMT({ @@ -7,49 +52,38 @@ module.exports = withMT({ theme: { container: { center: true, - padding: '2rem', + padding: '1rem', screens: { '2xl': '1400px' }, }, extend: { colors: { - border: 'hsl(var(--border))', - input: 'hsl(var(--input))', - ring: 'hsl(var(--ring))', - background: 'hsl(var(--background))', - foreground: 'hsl(var(--foreground))', - primary: { - DEFAULT: 'hsl(var(--primary))', - foreground: 'hsl(var(--primary-foreground))', - }, - secondary: { - DEFAULT: 'hsl(var(--secondary))', - foreground: 'hsl(var(--secondary-foreground))', - }, - destructive: { - DEFAULT: 'hsl(var(--destructive))', - foreground: 'hsl(var(--destructive-foreground))', - }, - muted: { - DEFAULT: 'hsl(var(--muted))', - foreground: 'hsl(var(--muted-foreground))', - }, - accent: { - DEFAULT: 'hsl(var(--accent))', - foreground: 'hsl(var(--accent-foreground))', - }, - popover: { - DEFAULT: 'hsl(var(--popover))', - foreground: 'hsl(var(--popover-foreground))', - }, - card: { - DEFAULT: 'hsl(var(--card))', - foreground: 'hsl(var(--card-foreground))', - }, + ...palette, + white: '#FFFFFF', + // Aliases kept for the Radix-based primitives in components/ui. + background: palette.paper, + foreground: palette.ink, + border: palette.line.DEFAULT, + input: palette.line.strong, + ring: palette.sage.DEFAULT, + primary: { DEFAULT: palette.navy.DEFAULT, foreground: '#FFFFFF' }, + muted: { DEFAULT: palette.sunken, foreground: palette.stone.DEFAULT }, + accent: { DEFAULT: palette.sunken, foreground: palette.ink }, + destructive: { DEFAULT: palette.danger.DEFAULT, foreground: '#FFFFFF' }, + popover: { DEFAULT: '#FFFFFF', foreground: palette.ink }, + }, + fontFamily: { + sans: ['var(--font-inter)', ...defaultTheme.fontFamily.sans], + display: ['var(--font-playfair)', 'Georgia', 'serif'], }, borderRadius: { - lg: 'var(--radius)', - md: 'calc(var(--radius) - 2px)', - sm: 'calc(var(--radius) - 4px)', + lg: '12px', + md: '9px', + sm: '6px', + }, + boxShadow: { + card: '0 1px 2px rgba(19, 41, 75, 0.04)', + overlay: + '0 12px 32px -8px rgba(19, 41, 75, 0.18), 0 2px 6px rgba(19, 41, 75, 0.06)', }, keyframes: { 'accordion-down': { diff --git a/start.sh b/start.sh index 41b8a42..6d76dd5 100755 --- a/start.sh +++ b/start.sh @@ -110,11 +110,17 @@ start_local_db() { # Exports the local stack's URL and keys under the names each app expects. export_local_credentials() { - local status api_url anon_key service_key - status="$(supabase_cli status -o env 2>/dev/null || true)" - api_url="$(env_value <(printf '%s\n' "$status") API_URL)" - anon_key="$(env_value <(printf '%s\n' "$status") ANON_KEY)" - service_key="$(env_value <(printf '%s\n' "$status") SERVICE_ROLE_KEY)" + local status api_url anon_key service_key attempt + # Right after Docker Desktop starts, containers auto-restart and status fails + # until they are healthy, so give the stack a moment before giving up. + for attempt in $(seq 1 15); do + status="$(supabase_cli status -o env 2>/dev/null || true)" + api_url="$(env_value <(printf '%s\n' "$status") API_URL)" + anon_key="$(env_value <(printf '%s\n' "$status") ANON_KEY)" + service_key="$(env_value <(printf '%s\n' "$status") SERVICE_ROLE_KEY)" + [[ -n "$api_url" && -n "$anon_key" && -n "$service_key" ]] && break + [[ "$attempt" -lt 15 ]] && sleep 2 + done [[ -n "$api_url" && -n "$anon_key" && -n "$service_key" ]] || die "Could not read local Supabase credentials. Run ./start.sh db:status to see which service is down, or ./start.sh db:stop and retry." # Process env takes precedence over frontend/.env and ML/.env, so production values there are ignored. From 1f6d7ba9143351e1e2a4df4796afc998726d0be9 Mon Sep 17 00:00:00 2001 From: Vadym Musiienko Date: Wed, 28 Oct 2026 18:21:52 -0700 Subject: [PATCH 02/18] Add shared UI kit --- frontend/src/components/ui/Accordion.tsx | 70 ++++++++ frontend/src/components/ui/Alert.tsx | 67 ++++++++ frontend/src/components/ui/Button.tsx | 100 +++++++++++ frontend/src/components/ui/Card.tsx | 73 +++++++++ frontend/src/components/ui/EmptyState.tsx | 42 +++++ frontend/src/components/ui/Field.tsx | 182 +++++++++++++++++++++ frontend/src/components/ui/Modal.tsx | 149 +++++++++++++++++ frontend/src/components/ui/PageHeader.tsx | 76 +++++++++ frontend/src/components/ui/Spinner.tsx | 32 ++++ frontend/src/components/ui/StatusBadge.tsx | 91 +++++++++++ frontend/src/components/ui/date-picker.tsx | 41 +++-- frontend/src/components/ui/popover.tsx | 2 +- frontend/src/components/ui/tooltip.tsx | 2 +- frontend/src/components/ui/ui.test.tsx | 114 +++++++++++++ frontend/src/styles/noRawColors.test.ts | 2 - frontend/tailwind.config.js | 11 ++ 16 files changed, 1038 insertions(+), 16 deletions(-) create mode 100644 frontend/src/components/ui/Accordion.tsx create mode 100644 frontend/src/components/ui/Alert.tsx create mode 100644 frontend/src/components/ui/Button.tsx create mode 100644 frontend/src/components/ui/Card.tsx create mode 100644 frontend/src/components/ui/EmptyState.tsx create mode 100644 frontend/src/components/ui/Field.tsx create mode 100644 frontend/src/components/ui/Modal.tsx create mode 100644 frontend/src/components/ui/PageHeader.tsx create mode 100644 frontend/src/components/ui/Spinner.tsx create mode 100644 frontend/src/components/ui/StatusBadge.tsx create mode 100644 frontend/src/components/ui/ui.test.tsx diff --git a/frontend/src/components/ui/Accordion.tsx b/frontend/src/components/ui/Accordion.tsx new file mode 100644 index 0000000..a7e698d --- /dev/null +++ b/frontend/src/components/ui/Accordion.tsx @@ -0,0 +1,70 @@ +'use client' + +import { ChevronDown } from 'lucide-react' +import { useId, useState, type ReactNode } from 'react' + +import { cn } from '@/utils/tailwind' + +interface AccordionItem { + id: string + title: ReactNode + content: ReactNode +} + +interface AccordionProps { + items: AccordionItem[] + defaultOpenId?: string + className?: string +} + +export function Accordion({ items, defaultOpenId, className }: AccordionProps) { + const baseId = useId() + const [openId, setOpenId] = useState(defaultOpenId) + + return ( +
+ {items.map((item) => { + const open = openId === item.id + const buttonId = `${baseId}-${item.id}-button` + const panelId = `${baseId}-${item.id}-panel` + return ( +
+

+ +

+ +
+ ) + })} +
+ ) +} diff --git a/frontend/src/components/ui/Alert.tsx b/frontend/src/components/ui/Alert.tsx new file mode 100644 index 0000000..ea9e202 --- /dev/null +++ b/frontend/src/components/ui/Alert.tsx @@ -0,0 +1,67 @@ +import { AlertTriangle, CheckCircle2, Info, XCircle } from 'lucide-react' +import type { ReactNode } from 'react' + +import { cn } from '@/utils/tailwind' + +const tones = { + info: { + box: 'border-navy-100 bg-navy-50', + icon: 'text-navy-500', + Icon: Info, + }, + success: { + box: 'border-sage/25 bg-sage-tint', + icon: 'text-sage', + Icon: CheckCircle2, + }, + warning: { + box: 'border-warning/20 bg-warning-tint', + icon: 'text-warning', + Icon: AlertTriangle, + }, + danger: { + box: 'border-danger/20 bg-danger-tint', + icon: 'text-danger', + Icon: XCircle, + }, +} + +interface AlertProps { + tone?: keyof typeof tones + title?: ReactNode + action?: ReactNode + className?: string + children?: ReactNode +} + +export function Alert({ + tone = 'info', + title, + action, + className, + children, +}: AlertProps) { + const { box, icon, Icon } = tones[tone] + const urgent = tone === 'danger' || tone === 'warning' + + return ( +
+ +
+ {title &&

{title}

} + {children &&
{children}
} + {action &&
{action}
} +
+
+ ) +} diff --git a/frontend/src/components/ui/Button.tsx b/frontend/src/components/ui/Button.tsx new file mode 100644 index 0000000..76bd525 --- /dev/null +++ b/frontend/src/components/ui/Button.tsx @@ -0,0 +1,100 @@ +import Link from 'next/link' +import { forwardRef, type ComponentProps } from 'react' + +import { cn } from '@/utils/tailwind' +import { Spinner } from './Spinner' + +const variants = { + primary: 'bg-navy text-white hover:bg-navy-700 active:bg-navy-900', + accent: 'bg-sage text-white hover:bg-sage-strong', + secondary: + 'border border-line-strong bg-card text-ink hover:border-navy-300 hover:bg-sunken', + ghost: 'text-navy hover:bg-sunken', + danger: 'bg-danger text-white hover:bg-danger-strong', + 'danger-ghost': 'text-danger hover:bg-danger-tint', + 'on-navy': 'border border-navy-500 text-white hover:bg-navy-700', +} + +const sizes = { + sm: 'h-9 gap-1.5 px-3 text-sm', + md: 'h-11 gap-2 px-4 text-[15px]', + lg: 'h-12 gap-2 px-5 text-base', +} + +type ButtonVariant = keyof typeof variants +type ButtonSize = keyof typeof sizes + +interface ButtonStyleOptions { + variant?: ButtonVariant + size?: ButtonSize + fullWidth?: boolean +} + +export const buttonClasses = ({ + variant = 'primary', + size = 'md', + fullWidth = false, +}: ButtonStyleOptions = {}) => + cn( + 'inline-flex select-none items-center justify-center whitespace-nowrap rounded-md font-medium', + 'transition-[background-color,border-color,color,transform] duration-150 ease-out active:scale-[0.97]', + 'disabled:pointer-events-none disabled:opacity-50', + variants[variant], + sizes[size], + fullWidth && 'w-full', + ) + +type ButtonProps = ComponentProps<'button'> & + ButtonStyleOptions & { loading?: boolean } + +export const Button = forwardRef( + function Button( + { + variant, + size, + fullWidth, + loading = false, + disabled, + className, + children, + type = 'button', + ...props + }, + ref, + ) { + return ( + + ) + }, +) + +type ButtonLinkProps = ComponentProps & ButtonStyleOptions + +export function ButtonLink({ + variant, + size, + fullWidth, + className, + ...props +}: ButtonLinkProps) { + return ( + + ) +} diff --git a/frontend/src/components/ui/Card.tsx b/frontend/src/components/ui/Card.tsx new file mode 100644 index 0000000..a098319 --- /dev/null +++ b/frontend/src/components/ui/Card.tsx @@ -0,0 +1,73 @@ +import type { ComponentProps, ElementType, ReactNode } from 'react' + +import { cn } from '@/utils/tailwind' + +type CardProps = ComponentProps<'div'> & { + as?: ElementType + padded?: boolean +} + +export function Card({ + as: Component = 'div', + padded = false, + className, + ...props +}: CardProps) { + return ( + + ) +} + +interface CardHeaderProps { + title: ReactNode + description?: ReactNode + action?: ReactNode + className?: string +} + +export function CardHeader({ + title, + description, + action, + className, +}: CardHeaderProps) { + return ( +
+
+

{title}

+ {description && ( +

{description}

+ )} +
+ {action &&
{action}
} +
+ ) +} + +export function CardBody({ className, ...props }: ComponentProps<'div'>) { + return
+} + +export function CardFooter({ className, ...props }: ComponentProps<'div'>) { + return ( +
+ ) +} diff --git a/frontend/src/components/ui/EmptyState.tsx b/frontend/src/components/ui/EmptyState.tsx new file mode 100644 index 0000000..9ce7a73 --- /dev/null +++ b/frontend/src/components/ui/EmptyState.tsx @@ -0,0 +1,42 @@ +import type { LucideIcon } from 'lucide-react' +import type { ReactNode } from 'react' + +import { cn } from '@/utils/tailwind' + +interface EmptyStateProps { + icon?: LucideIcon + title: ReactNode + description?: ReactNode + action?: ReactNode + className?: string +} + +export function EmptyState({ + icon: Icon, + title, + description, + action, + className, +}: EmptyStateProps) { + return ( +
+ {Icon && ( + + + + )} +

{title}

+ {description && ( +

+ {description} +

+ )} + {action &&
{action}
} +
+ ) +} diff --git a/frontend/src/components/ui/Field.tsx b/frontend/src/components/ui/Field.tsx new file mode 100644 index 0000000..07da116 --- /dev/null +++ b/frontend/src/components/ui/Field.tsx @@ -0,0 +1,182 @@ +import { + Children, + cloneElement, + forwardRef, + isValidElement, + type ComponentProps, + type ReactElement, + type ReactNode, +} from 'react' + +import { cn } from '@/utils/tailwind' + +const controlClasses = (invalid?: boolean) => + cn( + 'w-full rounded-md border bg-card px-3.5 text-[15px] text-ink placeholder:text-stone-light', + 'transition-[border-color,box-shadow] duration-150 ease-out', + 'focus:border-sage focus:outline-none focus:ring-2 focus:ring-sage/25 focus-visible:ring-offset-0', + 'disabled:cursor-not-allowed disabled:bg-sunken disabled:text-stone', + invalid + ? 'border-danger focus:border-danger focus:ring-danger/20' + : 'border-line-strong hover:border-navy-300', + ) + +interface FieldProps { + label: ReactNode + htmlFor: string + hint?: ReactNode + error?: ReactNode + required?: boolean + className?: string + children: ReactNode +} + +export function Field({ + label, + htmlFor, + hint, + error, + required, + className, + children, +}: FieldProps) { + const hintId = hint ? `${htmlFor}-hint` : undefined + const errorId = error ? `${htmlFor}-error` : undefined + const describedBy = [hintId, errorId].filter(Boolean).join(' ') || undefined + + // Link hint and error text to the control so screen readers announce them. + const control = Children.map(children, (child) => + isValidElement(child) && describedBy + ? cloneElement(child as ReactElement<{ 'aria-describedby'?: string }>, { + 'aria-describedby': describedBy, + }) + : child, + ) + + return ( +
+ + {control} + {hint && ( +

+ {hint} +

+ )} + {error && ( +

+ {error} +

+ )} +
+ ) +} + +type InputProps = ComponentProps<'input'> & { invalid?: boolean } + +export const Input = forwardRef(function Input( + { invalid, className, ...props }, + ref, +) { + return ( + + ) +}) + +type TextareaProps = ComponentProps<'textarea'> & { invalid?: boolean } + +export const Textarea = forwardRef( + function Textarea({ invalid, className, ...props }, ref) { + return ( +