diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f16d6a..38f7ce6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,42 @@ The project follows Semantic Versioning. --- +## v1.3.0 + +### Added + +#### Tactile artifact personalization and material stocks +- Added type-specific material stocks mapping artifact types to distinct paper stock tokens (`--stock-text`, `--stock-link`, `--stock-photo`, `--stock-issue`). +- Replaced deterministic ID-based color assignment with semantic material identities. +- Added distinct typographic voices: `--font-serif` (`EB Garamond`) for TEXT thoughts, `--font-mono` for metadata/indices, and Caveat handwriting for polaroid captions. +- Added tactile drop settle animation (`@keyframes nook-artifact-settle`) with shadow dampening on card landing. +- Added user-customizable paper tint palette (`cream`, `rose`, `sky`, `sage`, `lavender`, `butter`). +- Added accessible square swatch `TintPicker` component (`role="radiogroup"`, `role="radio"`, `aria-checked`, focus rings). +- Added `tint String?` column to the `Artifact` database model with migration `20261102120000_add_artifact_tint`. +- Added backend tint whitelist validation, update persistence, and unit test suites. + +#### OAuth 2.0 authentication +- Added Google and GitHub OAuth 2.0 sign-in flows with automatic identity linking and reconciliation. +- Added `OAuthAccount` database model linking external identity providers to user accounts. +- Added `GET /auth/google`, `GET /auth/google/callback`, `GET /auth/github`, and `GET /auth/github/callback`. +- Added frontend OAuth buttons and auth callback route. +- Made user `passwordHash` optional to support pure OAuth users. + +#### GitHub issue integration +- Added `GITHUB_ISSUE` artifacts as a first-class spatial artifact type. +- Added webhook ingress at `POST /webhooks/github` with HMAC-SHA256 signature verification. +- Added asynchronous RabbitMQ pipeline with publisher confirms, prefetch control, and reconnection handling. +- Added background worker runtime (`github-worker.ts`) consuming issues and syncing state transitions (`opened`, `edited`, `closed`, `reopened`). +- Added dead-letter queue (DLQ) routing after bounded retries for transient failures. +- Added transactional persistence and webhook delivery idempotency tracking. + +#### Polaroid captions +- Added optional caption support (`caption?`) on `POLAROID` artifacts stored in artifact JSON. +- Added caption input in polaroid draft creation and inline double-click caption editing on the wall. +- Added single-line enforcement and a 48-character limit. + +--- + ## v1.2.0 ### Added diff --git a/README.md b/README.md index 9c7a9ac..2617743 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ Instead of forcing ideas into folders, documents, or rigid workflows, Nook lets ### Authentication - User registration and login +- Google and GitHub OAuth 2.0 authentication with account linking - JWT-based authentication - Protected application routes - Private user workspaces @@ -25,11 +26,15 @@ Instead of forcing ideas into folders, documents, or rigid workflows, Nook lets ### Spatial workspace - Workspace-based artifact model -- Text, link, and Polaroid artifacts +- Text, link, Polaroid (with captions), and GitHub Issue artifacts +- Type-specific paper stocks (`--stock-text`, `--stock-link`, `--stock-photo`, `--stock-issue`) +- User-selectable paper tint customization palette with accessible swatches +- Physical micro-interactions: lift on hover, hold on drag, and tactile settle on drop +- Distinct typographic voices (serif for thoughts, mono for metadata, handwriting for polaroid captions) - Free positioning with persisted `x` / `y` coordinates - Draft artifact creation - Drag and reposition artifacts -- Inline text editing +- Inline text and caption editing - Artifact deletion - Multi-artifact selection and selection toolbar - Foundation for future insight-oriented interactions @@ -127,19 +132,21 @@ See [GitHub Integration](docs/integrations/github.md) for the implementation det ## Artifact model -Nook currently represents three artifact types: +Nook currently represents four artifact types: -| Type | Meaning | Stored content | -| ---------- | -------------------------- | -------------- | -| `TEXT` | “I thought this” | `{ text }` | -| `LINK` | “I found this” | `{ url }` | -| `POLAROID` | “I saw / experienced this” | `{ imageKey }` | +| Type | Meaning | Stored content | +| -------------- | -------------------------- | -------------------------------------------------------------- | +| `TEXT` | “I thought this” | `{ text }` | +| `LINK` | “I found this” | `{ url }` | +| `POLAROID` | “I saw / experienced this” | `{ imageKey, caption? }` | +| `GITHUB_ISSUE` | “I am tracking this” | `{ repository, issueNumber, title, body, state, url, author }` | -Spatial state is stored independently from artifact content: +Spatial state and customization are stored independently from artifact content: - `x` - `y` - `zIndex` +- `tint` (custom paper tint override) - `createdAt` - `updatedAt` @@ -153,6 +160,10 @@ The database schema lives in `backend/prisma/schema.prisma`. - `POST /auth/register` - `POST /auth/login` +- `GET /auth/google` +- `GET /auth/google/callback` +- `GET /auth/github` +- `GET /auth/github/callback` ### Workspaces @@ -171,6 +182,10 @@ The database schema lives in `backend/prisma/schema.prisma`. The image endpoint returns JSON containing a signed URL rather than redirecting the browser to Google Cloud Storage. +### Webhooks + +- `POST /webhooks/github` + ### Health - `GET /health` diff --git a/docs/architecture.md b/docs/architecture.md index 0883d7f..7f352f8 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -70,6 +70,7 @@ The current artifact vocabulary is: - `TEXT` - `LINK` - `POLAROID` +- `GITHUB_ISSUE` Components receive artifact data and interaction callbacks rather than directly owning persistence. @@ -194,17 +195,19 @@ An artifact also belongs to a user. The current artifact schema stores flexible type-specific content in PostgreSQL JSON: ```text -TEXT → { text } -LINK → { url } -POLAROID → { imageKey } +TEXT → { text } +LINK → { url } +POLAROID → { imageKey, caption? } +GITHUB_ISSUE → { repository, issueNumber, title, body, state, url, author } ``` -Spatial properties remain first-class columns: +Spatial and customization properties remain first-class columns: ```text x y zIndex +tint ``` This keeps positioning queryable without coupling the database schema to every artifact content shape. diff --git a/docs/design-system/interaction.md b/docs/design-system/interaction.md index 840f961..86c13d3 100644 --- a/docs/design-system/interaction.md +++ b/docs/design-system/interaction.md @@ -30,6 +30,12 @@ The artifact is actively being repositioned. Dragging updates the visual position immediately and persists the final position optimistically. +### Settling + +The artifact has just been released from a drag and is landing on the desk surface. + +A short keyframed settle animation (`--motion-settle` for notes, `--motion-pop` for photos) plays with shadow dampening to simulate physical landing. Grabbing the card again immediately interrupts the settle animation. + ### Editing The artifact is being edited. diff --git a/docs/setup.md b/docs/setup.md index 292f2dc..7ed215b 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -60,9 +60,17 @@ GCS_BUCKET_NAME=your-gcs-bucket RABBITMQ_URL=amqp://guest:guest@localhost:5672 GITHUB_WEBHOOK_SECRET=your-local-webhook-secret + +BACKEND_URL=http://localhost:3003 + +# Optional OAuth 2.0 configuration +GOOGLE_CLIENT_ID=your-google-client-id +GOOGLE_CLIENT_SECRET=your-google-client-secret +GITHUB_CLIENT_ID=your-github-client-id +GITHUB_CLIENT_SECRET=your-github-client-secret ``` -Required backend variables: +Required and optional backend variables: | Variable | Purpose | | ----------------------- | ------------------------------------------------- | @@ -73,6 +81,11 @@ Required backend variables: | `GCS_BUCKET_NAME` | Google Cloud Storage bucket used for media | | `RABBITMQ_URL` | RabbitMQ connection string | | `GITHUB_WEBHOOK_SECRET` | Secret used to verify GitHub webhook signatures | +| `BACKEND_URL` | Optional; public backend URL for OAuth callbacks | +| `GOOGLE_CLIENT_ID` | Optional; Google OAuth 2.0 client ID | +| `GOOGLE_CLIENT_SECRET` | Optional; Google OAuth 2.0 client secret | +| `GITHUB_CLIENT_ID` | Optional; GitHub OAuth App client ID | +| `GITHUB_CLIENT_SECRET` | Optional; GitHub OAuth App client secret | For local development involving Polaroid uploads, Google Cloud credentials must also be available to the Google Cloud Storage client through Application Default Credentials. diff --git a/frontend/README.md b/frontend/README.md index 6c29395..c30ea83 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -12,7 +12,14 @@ npm run dev ## Styling -The application relies on a structural design system using design tokens from `src/assets/nook-tokens.json`. All styling adheres strictly to the brand guidelines (sentence-case logo, structured block elements with 2px charcoal borders, and 24px rounded corners). +The application relies on plain CSS and semantic design tokens defined in `src/assets/styles/tokens/tokens.css` (no Tailwind, no external UI library). Component CSS uses CSS custom properties exclusively for color, typography, shape, and motion. + +Key design principles (v2): +- **Tokens only**: No raw hex, raw radius, raw shadow, or raw font families in component CSS. +- **Square shape**: Cards, buttons, inputs, and controls use `--radius-0`. Only Polaroid frames use `--radius-paper`. +- **Typographic voices**: Serif (`EB Garamond`) for thoughts and display, sans (`Plus Jakarta Sans`) for UI, mono (`IBM Plex Mono`) for metadata, and handwriting (`Caveat`) for polaroid captions. +- **Tactile depth**: UI cards carry an ink border, lifting with offset shadows on hover and drag, and playing a subtle physical settle on drop. +- **Color has a job**: Paper stocks identify artifact type (`--stock-text`, `--stock-link`, `--stock-photo`, `--stock-issue`) or user-chosen tint overrides (`--tint-*`). Color is never picked from an ID. ## Architecture diff --git a/frontend/src/assets/styles/artifacts/artifact.css b/frontend/src/assets/styles/artifacts/artifact.css index e05b61f..2c1c88a 100644 --- a/frontend/src/assets/styles/artifacts/artifact.css +++ b/frontend/src/assets/styles/artifacts/artifact.css @@ -40,7 +40,8 @@ transition: transform var(--motion-lift), box-shadow var(--motion-lift), - border-color var(--motion-lift); + border-color var(--motion-lift), + background-color var(--motion-settle); } /* @@ -264,70 +265,6 @@ color: var(--accent-action); } -/* --------------------------------------------------------------- - Tint picker — paper color palette - --------------------------------------------------------------- */ - -.nook-tint-picker { - display: flex; - align-items: center; - gap: 3px; - margin-right: 2px; -} - -.nook-tint-picker__dot { - width: 14px; - height: 14px; - - padding: 0; - - border: 1px solid color-mix( - in srgb, - var(--border-strong) 24%, - transparent - ); - - border-radius: var(--radius-0); - - background: var(--dot-color, var(--stock-note)); - - cursor: pointer; - - box-shadow: none; - - transition: - border-color var(--motion-lift), - transform var(--motion-lift); -} - -.nook-tint-picker__dot--default { - background: linear-gradient( - 135deg, - var(--stock-note) 50%, - var(--stock-link) 50% - ); -} - -.nook-tint-picker__dot:hover { - border-color: color-mix( - in srgb, - var(--border-strong) 52%, - transparent - ); - - transform: translateY(-1px); -} - -.nook-tint-picker__dot--active { - border-color: var(--border-strong); - - box-shadow: 0 0 0 1px var(--border-strong); -} - -.nook-tint-picker__dot:focus-visible { - box-shadow: var(--focus-ring); -} - /* --------------------------------------------------------------- Content --------------------------------------------------------------- */ @@ -709,7 +646,7 @@ box-sizing: border-box; padding: 5.7% 5.7% 0; - background: var(--stock-photo); + background: var(--artifact-color, var(--stock-photo)); border-radius: var(--radius-paper); box-shadow: var(--shadow-paper-rest); diff --git a/frontend/src/assets/styles/auth.css b/frontend/src/assets/styles/auth.css index 3420c1e..713a7f9 100644 --- a/frontend/src/assets/styles/auth.css +++ b/frontend/src/assets/styles/auth.css @@ -958,51 +958,59 @@ } .auth-oauth-group { - display: flex; - flex-direction: column; - gap: var(--space-2); + display: grid; + grid-template-columns: 1fr 1fr; + gap: var(--space-3); } .auth-oauth-btn { display: inline-flex; align-items: center; justify-content: center; - gap: var(--space-3); width: 100%; min-height: 44px; - padding: var(--space-2) var(--space-4); + padding: var(--space-2) var(--space-3); background: var(--color-artifact); color: var(--text-primary); border: 1px solid var(--border-subtle); border-radius: var(--radius-0); - font-family: var(--font-ui); - font-size: var(--type-label-size); - font-weight: var(--weight-medium); cursor: pointer; text-decoration: none; + box-shadow: none; transition: border-color var(--interaction-duration) var(--interaction-easing), - background var(--interaction-duration) var(--interaction-easing); + background var(--interaction-duration) var(--interaction-easing), + transform var(--motion-lift), + box-shadow var(--motion-lift); } .auth-oauth-btn:hover:not(:disabled) { - border-color: var(--text-primary); + border-color: var(--border-strong); background: var(--color-canvas); + transform: translateY(-1px); + box-shadow: 2px 2px 0 var(--palette-ink); +} + +.auth-oauth-btn:active:not(:disabled) { + transform: translateY(0); + box-shadow: none; } .auth-oauth-btn:focus-visible { - outline: 2px solid var(--accent-primary); - outline-offset: 2px; + box-shadow: var(--focus-ring); + outline: none; } .auth-oauth-btn:disabled { cursor: not-allowed; opacity: 0.6; + transform: none; + box-shadow: none; } .auth-oauth-icon { - width: 18px; - height: 18px; + width: 20px; + height: 20px; flex-shrink: 0; } diff --git a/frontend/src/assets/styles/layouts/overlays.css b/frontend/src/assets/styles/layouts/overlays.css index 4bacce7..57dafea 100644 --- a/frontend/src/assets/styles/layouts/overlays.css +++ b/frontend/src/assets/styles/layouts/overlays.css @@ -74,8 +74,59 @@ .nook-insight-panel__status { margin-bottom: var(--space-5); +} + +.nook-insight-panel__working { + display: inline-flex; + align-items: center; + gap: var(--space-2); + padding: var(--space-2) var(--space-3); + border: 1px solid color-mix(in srgb, var(--accent-action) 35%, transparent); + border-radius: var(--radius-0); + background: color-mix(in srgb, var(--accent-action) 8%, transparent); + color: var(--accent-action); + font-family: var(--font-mono); + font-size: var(--type-overline-size); + font-weight: var(--weight-bold); + letter-spacing: var(--tracking-overline); + text-transform: uppercase; + box-shadow: 2px 2px 0 color-mix(in srgb, var(--accent-action) 18%, transparent); +} + +.nook-insight-panel__beacon { + display: inline-block; + width: 6px; + height: 6px; + border-radius: var(--radius-0); + background: var(--accent-action); + box-shadow: 0 0 6px color-mix(in srgb, var(--accent-action) 70%, transparent); + animation: nook-beacon-pulse 1600ms ease-in-out infinite; +} + +.nook-insight-panel__working-hint { + margin-top: var(--space-3); color: var(--text-muted); font-size: var(--type-label-size); + line-height: var(--leading-body); +} + +@keyframes nook-beacon-pulse { + 0%, 100% { + opacity: 0.35; + transform: scale(0.9); + } + 50% { + opacity: 1; + transform: scale(1.15); + } +} + +@media (prefers-reduced-motion: reduce) { + .nook-insight-panel__beacon { + animation: none; + opacity: 1; + transform: none; + } } .nook-insight-panel__copy { @@ -138,4 +189,169 @@ kbd { opacity: 1; transform: translateX(0); } +} + +/* --------------------------------------------------------------- + Color Dashboard — centralized left-docked paper tint palette + --------------------------------------------------------------- */ + +.nook-color-dashboard { + position: fixed; + z-index: var(--z-toolbar); + top: 50%; + left: var(--space-4); + transform: translateY(-50%); + + display: flex; + flex-direction: column; + gap: var(--space-2); + min-width: 52px; + padding: var(--space-3) var(--space-2); + + border: 1px solid color-mix( + in srgb, + var(--border-strong) 14%, + transparent + ); + border-radius: var(--radius-0); + + background: color-mix( + in srgb, + var(--color-artifact) 92%, + transparent + ); + + box-shadow: + 0 2px 0 color-mix( + in srgb, + var(--border-strong) 8%, + transparent + ), + 0 9px 26px rgba(42, 36, 56, 0.11); + + backdrop-filter: blur(16px); + animation: nook-dashboard-enter var(--motion-settle) both; +} + +@media (prefers-reduced-motion: reduce) { + .nook-color-dashboard { + animation: none; + } +} + +.nook-color-dashboard__header { + display: flex; + flex-direction: column; + align-items: center; + gap: 2px; + padding-bottom: var(--space-1); + border-bottom: 1px solid color-mix( + in srgb, + var(--border-strong) 12%, + transparent + ); +} + +.nook-color-dashboard__title { + font-size: var(--type-overline-size); + font-weight: var(--weight-bold); + letter-spacing: var(--tracking-overline); + text-transform: uppercase; + color: var(--text-heading); +} + +.nook-color-dashboard__count { + font-family: var(--font-mono); + font-size: 10px; + color: var(--text-muted); + white-space: nowrap; + transition: opacity var(--motion-lift); +} + +.nook-color-dashboard__palette { + display: flex; + flex-direction: column; + align-items: center; + gap: 7px; +} + +.nook-color-dashboard__swatch { + position: relative; + width: 28px; + height: 28px; + padding: 2px; + + border: 1px solid color-mix( + in srgb, + var(--border-strong) 24%, + transparent + ); + border-radius: var(--radius-0); + background: transparent; + + cursor: pointer; + box-shadow: none; + + transition: + border-color var(--motion-lift), + transform var(--motion-lift), + box-shadow var(--motion-lift); +} + +.nook-color-dashboard__swatch-fill { + display: block; + width: 100%; + height: 100%; + background: var(--swatch-color, var(--stock-note)); + border-radius: var(--radius-0); +} + +.nook-color-dashboard__swatch--default .nook-color-dashboard__swatch-fill { + background: var(--stock-note); +} + +.nook-color-dashboard__swatch:hover { + border-color: var(--border-strong); + transform: translateX(2px) translateY(-1px); + box-shadow: 2px 2px 0 var(--palette-ink); +} + +.nook-color-dashboard__swatch:active { + transform: translateX(1px) translateY(1px); + box-shadow: none; + transition-duration: 40ms; +} + +.nook-color-dashboard__swatch--active { + border-color: var(--border-strong); + box-shadow: 2px 2px 0 var(--palette-ink); +} + +.nook-color-dashboard__swatch-mark { + position: absolute; + top: 50%; + left: 50%; + width: 4px; + height: 4px; + background: var(--palette-ink); + transform: translate(-50%, -50%); + border-radius: var(--radius-0); + pointer-events: none; +} + +.nook-color-dashboard__swatch:focus-visible { + box-shadow: var(--focus-ring); + outline: none; +} + +@keyframes nook-dashboard-enter { + from { + opacity: 0; + transform: translate(-10px, -50%); + } + + to { + opacity: 1; + transform: translate(0, -50%); + } } \ No newline at end of file diff --git a/frontend/src/assets/styles/layouts/workspace.css b/frontend/src/assets/styles/layouts/workspace.css index 9af41a5..f67a323 100644 --- a/frontend/src/assets/styles/layouts/workspace.css +++ b/frontend/src/assets/styles/layouts/workspace.css @@ -20,7 +20,7 @@ overflow: hidden; width: 100%; height: 100%; - cursor: default; + cursor: var(--cursor-spatial); touch-action: none; overscroll-behavior: none; @@ -52,6 +52,7 @@ width: var(--render-world-size); height: var(--render-world-size); z-index: var(--z-base); + cursor: var(--cursor-spatial); background: linear-gradient( diff --git a/frontend/src/assets/styles/tokens/interaction.css b/frontend/src/assets/styles/tokens/interaction.css index 71b626e..ffbfaa8 100644 --- a/frontend/src/assets/styles/tokens/interaction.css +++ b/frontend/src/assets/styles/tokens/interaction.css @@ -15,6 +15,9 @@ --interaction-selected-outline: 2px solid rgba(74, 67, 104, .28); + /* Spatial canvas delta arrowhead cursor: ink body with crisp white stroke and subtle contrast shadow */ + --cursor-spatial: + url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M2.5 2.5l18 7-8.5 2.5-2.5 8.5z' fill='none' stroke='%23000000' stroke-opacity='0.3' stroke-width='3.2' stroke-linejoin='round'/%3E%3Cpath d='M2.5 2.5l18 7-8.5 2.5-2.5 8.5z' fill='%2317141F' stroke='%23ffffff' stroke-width='1.5' stroke-linejoin='round'/%3E%3C/svg%3E") 2 2, default; } :focus-visible { diff --git a/frontend/src/components/Artifact/ArtifactActions.tsx b/frontend/src/components/Artifact/ArtifactActions.tsx index d9ac40f..065ea1b 100644 --- a/frontend/src/components/Artifact/ArtifactActions.tsx +++ b/frontend/src/components/Artifact/ArtifactActions.tsx @@ -1,30 +1,17 @@ -import TintPicker from "./TintPicker"; - interface ArtifactActionsProps { onEdit?: () => void; onDelete: () => void; - currentTint?: string | null; - onSelectTint?: (tint: string | null) => void; } export default function ArtifactActions({ onEdit, onDelete, - currentTint, - onSelectTint, }: ArtifactActionsProps) { return (
e.stopPropagation()} > - {onSelectTint && ( - - )} - {onEdit && (
diff --git a/frontend/src/components/ColorDashboard.test.tsx b/frontend/src/components/ColorDashboard.test.tsx new file mode 100644 index 0000000..39bb70d --- /dev/null +++ b/frontend/src/components/ColorDashboard.test.tsx @@ -0,0 +1,127 @@ +import { fireEvent, render, screen } from "@testing-library/react"; +import { describe, expect, it, vi } from "vitest"; +import ColorDashboard from "./ColorDashboard"; + +describe("ColorDashboard", () => { + it("renders all 7 tint options in radiogroup", () => { + const onSelectTint = vi.fn(); + render( + + ); + + const group = screen.getByRole("radiogroup", { name: "Paper tint options" }); + expect(group).toBeInTheDocument(); + + const radios = screen.getAllByRole("radio"); + expect(radios).toHaveLength(7); + radios.forEach((radio) => { + expect(radio).toBeEnabled(); + }); + + expect(screen.getByText("Default")).toBeInTheDocument(); + }); + + it("displays count when thoughts are selected", () => { + const onSelectTint = vi.fn(); + render( + + ); + + expect(screen.getByText("2 thoughts")).toBeInTheDocument(); + const radios = screen.getAllByRole("radio"); + radios.forEach((radio) => { + expect(radio).toBeEnabled(); + }); + }); + + it("marks the active tint as checked", () => { + const onSelectTint = vi.fn(); + render( + + ); + + const skyRadio = screen.getByRole("radio", { name: "Sky" }); + expect(skyRadio).toHaveAttribute("aria-checked", "true"); + + const defaultRadio = screen.getByRole("radio", { name: "Default" }); + expect(defaultRadio).toHaveAttribute("aria-checked", "false"); + }); + + it("triggers onSelectTint when clicking a swatch even when selectedCount is 0", () => { + const onSelectTint = vi.fn(); + render( + + ); + + const roseRadio = screen.getByRole("radio", { name: "Rose" }); + fireEvent.click(roseRadio); + + expect(onSelectTint).toHaveBeenCalledWith("rose"); + }); + + it("triggers onSelectTint with null when selecting default", () => { + const onSelectTint = vi.fn(); + render( + + ); + + const defaultRadio = screen.getByRole("radio", { name: "Default" }); + fireEvent.click(defaultRadio); + + expect(onSelectTint).toHaveBeenCalledWith(null); + }); + + it("previews tint name on hover and restores subtitle on mouse leave", () => { + const onSelectTint = vi.fn(); + render( + + ); + + expect(screen.getByText("3 thoughts")).toBeInTheDocument(); + + const butterRadio = screen.getByRole("radio", { name: "Butter" }); + fireEvent.mouseEnter(butterRadio); + + expect(screen.getByText("Butter")).toBeInTheDocument(); + + fireEvent.mouseLeave(butterRadio); + expect(screen.getByText("3 thoughts")).toBeInTheDocument(); + }); + + it("supports keyboard arrow navigation across swatches", () => { + const onSelectTint = vi.fn(); + render( + + ); + + const group = screen.getByRole("radiogroup", { name: "Paper tint options" }); + fireEvent.keyDown(group, { key: "ArrowDown" }); + + // TINT_OPTIONS[1] is cream + expect(onSelectTint).toHaveBeenCalledWith("cream"); + }); +}); diff --git a/frontend/src/components/ColorDashboard.tsx b/frontend/src/components/ColorDashboard.tsx new file mode 100644 index 0000000..36b5233 --- /dev/null +++ b/frontend/src/components/ColorDashboard.tsx @@ -0,0 +1,105 @@ +import { useState } from "react"; +import { cn } from "../lib/cn"; +import { TINT_OPTIONS } from "../lib/tints"; + +interface ColorDashboardProps { + selectedCount: number; + currentTint?: string | null; + onSelectTint: (tint: string | null) => void; +} + +export default function ColorDashboard({ + selectedCount, + currentTint, + onSelectTint, +}: ColorDashboardProps) { + const [hoveredLabel, setHoveredLabel] = useState(null); + const isTargeted = selectedCount > 0; + + const activeLabel = + TINT_OPTIONS.find((option) => option.key === (currentTint ?? null))?.label ?? + "Default"; + + const subtitle = hoveredLabel + ? hoveredLabel + : isTargeted + ? `${selectedCount} thought${selectedCount !== 1 ? "s" : ""}` + : activeLabel; + + function handleKeyDown(e: React.KeyboardEvent) { + if (e.key !== "ArrowDown" && e.key !== "ArrowUp") return; + e.preventDefault(); + + const currentIndex = TINT_OPTIONS.findIndex( + (option) => option.key === (currentTint ?? null) + ); + const nextIndex = + e.key === "ArrowDown" + ? (currentIndex + 1) % TINT_OPTIONS.length + : (currentIndex - 1 + TINT_OPTIONS.length) % TINT_OPTIONS.length; + + onSelectTint(TINT_OPTIONS[nextIndex].key); + } + + return ( + + ); +} diff --git a/frontend/src/components/InsightPanel.test.tsx b/frontend/src/components/InsightPanel.test.tsx new file mode 100644 index 0000000..ce2c81b --- /dev/null +++ b/frontend/src/components/InsightPanel.test.tsx @@ -0,0 +1,25 @@ +import { fireEvent, render, screen } from "@testing-library/react"; +import { describe, expect, it, vi } from "vitest"; +import InsightPanel from "./InsightPanel"; + +describe("InsightPanel", () => { + it("renders pattern finder eyebrow, 'working right now' beacon badge, and scan hint", () => { + const onClose = vi.fn(); + render(); + + expect(screen.getByText("pattern finder")).toBeInTheDocument(); + expect(screen.getByText("working right now")).toBeInTheDocument(); + expect(screen.getByText("What stands out")).toBeInTheDocument(); + expect(screen.getByText("Scanning 2 selected thoughts for patterns.")).toBeInTheDocument(); + }); + + it("triggers onClose when clicking close button", () => { + const onClose = vi.fn(); + render(); + + const closeBtn = screen.getByRole("button", { name: "Close" }); + fireEvent.click(closeBtn); + + expect(onClose).toHaveBeenCalledTimes(1); + }); +}); diff --git a/frontend/src/components/InsightPanel.tsx b/frontend/src/components/InsightPanel.tsx index b2def1e..4edbeb6 100644 --- a/frontend/src/components/InsightPanel.tsx +++ b/frontend/src/components/InsightPanel.tsx @@ -1,5 +1,5 @@ interface InsightPanelProps { - selectedCount: number; + selectedCount?: number; onClose: () => void; } @@ -14,25 +14,25 @@ export default function InsightPanel({ pattern finder

What stands out

- +
-

- Looking for patterns across {selectedCount} thoughts... -

-
-
-

- It seems you're investing in multiple long-term goals simultaneously. -

-

- Rather than trying to progress everything today, identify the one task that unlocks the most momentum before switching context. +

+
+

+ {selectedCount && selectedCount > 0 + ? `Scanning ${selectedCount} selected thought${selectedCount > 1 ? "s" : ""} for patterns.` + : "Scanning thoughts for patterns."}

-
- Suggested next step -

Choose the one thought that unlocks the most momentum today.

-
); } diff --git a/frontend/src/components/Wall.tsx b/frontend/src/components/Wall.tsx index e78dc3d..b40d79e 100644 --- a/frontend/src/components/Wall.tsx +++ b/frontend/src/components/Wall.tsx @@ -25,8 +25,9 @@ interface WallProps { onCommitDraftPolaroid: (imageKey: string, caption?: string) => Promise; onCancelDraft: () => void; - selectedArtifactIds: number[] - onToggleArtifactSelection: (artifactId: number) => void + selectedArtifactIds: number[]; + onToggleArtifactSelection: (artifactId: number) => void; + onClearSelection?: () => void; editingArtifactId: number | null; onEditingArtifactChange: (artifactId: number | null) => void; @@ -46,6 +47,7 @@ export default function Wall({ onCancelDraft, selectedArtifactIds, onToggleArtifactSelection, + onClearSelection, createPosition, onSelectArtifactType, onCancelCreation, @@ -88,6 +90,8 @@ function handlePointerDown( if (editingArtifactId !== null) { onEditingArtifactChange(null); } + + onClearSelection?.(); } return ( diff --git a/frontend/src/lib/tints.ts b/frontend/src/lib/tints.ts new file mode 100644 index 0000000..0a65560 --- /dev/null +++ b/frontend/src/lib/tints.ts @@ -0,0 +1,14 @@ +export interface TintOption { + key: string | null; + label: string; +} + +export const TINT_OPTIONS = [ + { key: null, label: "Default" }, + { key: "cream", label: "Cream" }, + { key: "rose", label: "Rose" }, + { key: "sky", label: "Sky" }, + { key: "sage", label: "Sage" }, + { key: "lavender", label: "Lavender" }, + { key: "butter", label: "Butter" }, +] as const; diff --git a/frontend/src/pages/Home.tsx b/frontend/src/pages/Home.tsx index f92a6a8..7a6134b 100644 --- a/frontend/src/pages/Home.tsx +++ b/frontend/src/pages/Home.tsx @@ -5,6 +5,7 @@ import type { Artifact, ArtifactUpdate, DraftArtifact, Position, TextArtifact, L import { markPhotoAsNew } from "../lib/developingPhotos"; import Wall from "../components/Wall" import InsightPanel from "../components/InsightPanel"; +import ColorDashboard from "../components/ColorDashboard"; import WorkspaceShell from "../components/WorkspaceShell"; import FloatingToolbar from "../components/FloatingToolbar"; import { logout } from "../services/auth"; @@ -49,6 +50,7 @@ export default function Home() { const [artifacts, setArtifacts] = useState([]); const [draftArtifact, setDraftArtifact] = useState(null); const [selectedArtifactIds, setSelectedArtifactIds] = useState([]); + const [defaultTint, setDefaultTint] = useState(null); const [activeWorkspace, setActiveWorkspace] = useState(null); const [workspaces, setWorkspaces] = useState([]); const [isInsightOpen, setIsInsightOpen] = useState(false); @@ -137,6 +139,7 @@ export default function Home() { content: { text, }, + tint: defaultTint, x: draftArtifact.x, y: draftArtifact.y, zIndex: 0, @@ -160,10 +163,23 @@ export default function Home() { } ); + let finalArtifact = savedArtifact; + if (defaultTint) { + try { + finalArtifact = await updateArtifact( + activeWorkspace.id, + savedArtifact.id, + { tint: defaultTint } + ); + } catch { + // Fall back to savedArtifact if tint update fails + } + } + setArtifacts((current) => current.map((artifact) => artifact.id === optimisticArtifact.id - ? savedArtifact + ? finalArtifact : artifact ) ); @@ -200,6 +216,7 @@ export default function Home() { content: { url, }, + tint: defaultTint, x: draftArtifact.x, y: draftArtifact.y, zIndex: 0, @@ -223,10 +240,23 @@ export default function Home() { } ); + let finalArtifact = savedArtifact; + if (defaultTint) { + try { + finalArtifact = await updateArtifact( + activeWorkspace.id, + savedArtifact.id, + { tint: defaultTint } + ); + } catch { + // Fall back to savedArtifact if tint update fails + } + } + setArtifacts((current) => current.map((artifact) => artifact.id === optimisticArtifact.id - ? savedArtifact + ? finalArtifact : artifact ) ); @@ -270,6 +300,7 @@ export default function Home() { workspaceId: activeWorkspace.id, type: "POLAROID", content, + tint: defaultTint, x: draftArtifact.x, y: draftArtifact.y, zIndex: 0, @@ -297,10 +328,23 @@ export default function Home() { // Only a photo uploaded in this session develops its image. markPhotoAsNew(savedArtifact.id); + let finalArtifact = savedArtifact; + if (defaultTint) { + try { + finalArtifact = await updateArtifact( + activeWorkspace.id, + savedArtifact.id, + { tint: defaultTint } + ); + } catch { + // Fall back to savedArtifact if tint update fails + } + } + setArtifacts((current) => current.map((artifact) => artifact.id === optimisticArtifact.id - ? savedArtifact + ? finalArtifact : artifact ) ); @@ -501,6 +545,70 @@ function handleFindInsight() { function handleCloseInsight(){ setIsInsightOpen(false); } + + const targetArtifactIds = + selectedArtifactIds.length > 0 + ? selectedArtifactIds + : editingArtifactId !== null + ? [editingArtifactId] + : []; + + const targetArtifacts = artifacts.filter((artifact) => + targetArtifactIds.includes(artifact.id) + ); + + const resolvedCurrentTint = + targetArtifacts.length === 0 + ? defaultTint + : targetArtifacts.every( + (a) => (a.tint ?? null) === (targetArtifacts[0].tint ?? null) + ) + ? (targetArtifacts[0].tint ?? null) + : undefined; + + async function handleBatchTint(tint: string | null) { + if (targetArtifactIds.length === 0) { + setDefaultTint(tint); + return; + } + + if (!activeWorkspace) return; + + const targetSet = new Set(targetArtifactIds); + const previousArtifacts = artifacts; + + setArtifacts((current) => + current.map((artifact) => + targetSet.has(artifact.id) + ? { ...artifact, tint } + : artifact + ) + ); + + try { + await Promise.all( + targetArtifactIds.map(async (id) => { + if (id < 0) return; + const updated = await updateArtifact( + activeWorkspace.id, + id, + { tint } + ); + setArtifacts((current) => + current.map((a) => (a.id === id ? updated : a)) + ); + }) + ); + } catch (error) { + setArtifacts(previousArtifacts); + setSaveError("Couldn't save that. Please try again."); + setTimeout(() => { + setSaveError(null); + }, 3000); + console.error(error); + } + } + return ( + {activeWorkspace && ( + + )} {!activeWorkspace ? (