Public: anyone can read this; the crew can change it.
A signed-out visitor lands on a page that shows what deal-clock does, with a picture of the clock made from made-up data, and one Sign in button #32
Check · Review · Land · Live done — Landed and live in production.
mason/deal-clock:mason/29-a-signed-out-visitor-lands-on-a-page-tha → main 3 commits fork 1 thread · 1 unresolved
8 files
changed +110
−6
README.md +2
| @@ -22,6 +22,8 @@ address, who owes it and how urgent it is; tap a row to open its sheet. It | ||
| 22 | 22 | reads well on a phone, with no sideways scrolling. In the terminal, press w |
| 23 | 23 | for the same list; over MCP, an agent asks for the `this_week` tool. |
| 24 | 24 | |
| 25 | Signed out, `/` shows what deal-clock does, three short points, a still picture of the clock drawn from a made-up deal, and one **Sign in** button; no real deal is read. | |
| 26 | ||
| 25 | 27 | 1. **Look at the clock.** You see four lanes: 77 Harbor View Dr, Unit 4B |
| 26 | 28 | (the inspection date has passed, so its marker is red), 1418 Alder Lane |
| 27 | 29 | (closing in a few days, with the earlier dates grey), 9 Orchard Row (the |
docs/design/areas/welcome.md added +6
| @@ -0,0 +1,6 @@ | ||
| 1 | # Welcome | |
| 2 | ||
| 3 | New classes on the signed-out `/`: | |
| 4 | ||
| 5 | - `.welcome` — the page's wrapper; its headline is capped at 40rem. | |
| 6 | - `.points` — the three short points under the headline, a plain list. |
src/pages/clock.ts +1 −1
| @@ -62,7 +62,7 @@ function lane(deal: DealView, start: string, on: string): string { | ||
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** Weekends shaded, each Monday labelled, today a line through every lane. */ |
| 65 | function axis(start: string, days: number, on: string): string { | |
| 65 | export function axis(start: string, days: number, on: string): string { | |
| 66 | 66 | const out: string[] = []; |
| 67 | 67 | for (let i = 0; i < days; i++) { |
| 68 | 68 | const day = addDays(start, i); |
src/pages/layout.ts +3 −1
| @@ -25,6 +25,8 @@ export function layout(input: { | ||
| 25 | 25 | path: string; |
| 26 | 26 | heading?: string; |
| 27 | 27 | notice?: string | undefined; |
| 28 | /** Whether the page keeps its regions live; false for a page with none. */ | |
| 29 | live?: boolean; | |
| 28 | 30 | /** A page handed to someone outside the app: the brand only, no sign-in, footer or script. */ |
| 29 | 31 | plain?: boolean; |
| 30 | 32 | /** A class on <body>, for styles that belong to one page only. */ |
| @@ -58,7 +60,7 @@ export function layout(input: { | ||
| 58 | 60 | <meta name="twitter:description" content="${escape(description)}"> |
| 59 | 61 | <link rel="stylesheet" href="${tokensHref}"> |
| 60 | 62 | <link rel="stylesheet" href="${asset("app.css")}"> |
| 61 | ${plain ? "" : `<script type="module" src="${asset("live.js")}"></script>`} | |
| 63 | ${plain || input.live === false ? "" : `<script type="module" src="${asset("live.js")}"></script>`} | |
| 62 | 64 | <body${bodyClass === undefined ? "" : ` class="${escape(bodyClass)}"`}> |
| 63 | 65 | <div class="page"> |
| 64 | 66 | <header class="head"> |
src/pages/welcome.ts added +66
| @@ -0,0 +1,66 @@ | ||
| 1 | /** | |
| 2 | * What a signed-out visitor sees at `/`: what the app does, three short | |
| 3 | * points, a picture of the clock. The one Sign in button is the layout's. The picture is drawn | |
| 4 | * with the clock's own markup and classes from a made-up deal written here; | |
| 5 | * no row is read from the database, so nothing about `deal` opens to anon. | |
| 6 | */ | |
| 7 | ||
| 8 | import { addDays, short, urgency } from "../dates.ts"; | |
| 9 | import { KIND, schedule } from "../deadlines.ts"; | |
| 10 | import { escape } from "../http.ts"; | |
| 11 | import type { Who } from "../who.ts"; | |
| 12 | import { axis } from "./clock.ts"; | |
| 13 | import { layout } from "./layout.ts"; | |
| 14 | ||
| 15 | /** The days the picture shows: a week behind today to three weeks ahead. */ | |
| 16 | const BEHIND = 7; | |
| 17 | const DAYS = 30; | |
| 18 | ||
| 19 | const at = (days: number): string => `calc(${days} * var(--size-day))`; | |
| 20 | ||
| 21 | /** The made-up deal's dates, from today: signed twelve days ago, closing in eighteen. */ | |
| 22 | function madeUp(on: string): { due: string; tag: string; done: boolean }[] { | |
| 23 | return schedule({ | |
| 24 | contractDate: addDays(on, -12), | |
| 25 | closingDate: addDays(on, 18), | |
| 26 | lengths: { inspection: 10, appraisal: 21, financing: 30, title: 14, walkthrough: 1 }, | |
| 27 | businessDays: false, | |
| 28 | }).map(({ kind, due }) => ({ due, tag: KIND[kind].tag, done: kind === "inspection" })); | |
| 29 | } | |
| 30 | ||
| 31 | /** The clock, still: one lane of markers that do nothing when touched. */ | |
| 32 | function picture(on: string): string { | |
| 33 | const start = addDays(on, -BEHIND); | |
| 34 | const markers = madeUp(on) | |
| 35 | .map((d, i) => { | |
| 36 | const x = Math.round((Date.parse(d.due) - Date.parse(start)) / 86_400_000); | |
| 37 | const u = urgency(d.due, on, d.done); | |
| 38 | // Staggered over two rows so neighbouring markers never overlap. | |
| 39 | return `<span class="marker" data-u="${u}" style="left:${at(x)};top:calc(${i % 2} * 3rem)"><span class="dot"></span>${escape(d.tag)}</span>`; | |
| 40 | }) | |
| 41 | .join(""); | |
| 42 | return `<div class="clock-scroll" aria-hidden="true"> | |
| 43 | <div class="clock-inner" style="width:${at(DAYS)}"> | |
| 44 | <div class="axis">${axis(start, DAYS, on)}</div> | |
| 45 | <ol class="lanes"><li class="lane"> | |
| 46 | <div class="lane-head"><b>Example Court</b> <small class="muted">a made-up deal · closes ${escape(short(addDays(on, 18)))}</small></div> | |
| 47 | <div class="track" style="height:calc(2 * 3rem)">${markers}</div> | |
| 48 | </li></ol> | |
| 49 | </div> | |
| 50 | </div>`; | |
| 51 | } | |
| 52 | ||
| 53 | export function welcomePage(input: { who: Who; on: string }): string { | |
| 54 | const body = `<section class="welcome"> | |
| 55 | <h1>Every deadline of every deal on one timeline, with reminders each party gets before anything slips.</h1> | |
| 56 | <ul class="points"> | |
| 57 | <li><b>Computed.</b> The dates are worked out from the contract.</li> | |
| 58 | <li><b>Drafted.</b> Reminders are written for each party.</li> | |
| 59 | <li><b>Approved.</b> Nothing is sent until the agent approves it.</li> | |
| 60 | </ul> | |
| 61 | <section class="card clock" aria-label="An example of the clock"> | |
| 62 | ${picture(input.on)} | |
| 63 | </section> | |
| 64 | </section>`; | |
| 65 | return layout({ body, who: input.who, path: "/", live: false }); | |
| 66 | } |
src/routes.ts +2
| @@ -62,6 +62,7 @@ import { clock } from "./pages/clock.ts"; | ||
| 62 | 62 | import { dealPage, newDealPage } from "./pages/deal.ts"; |
| 63 | 63 | import { refusedPage } from "./pages/refused.ts"; |
| 64 | 64 | import { timelinePage } from "./pages/timeline.ts"; |
| 65 | import { welcomePage } from "./pages/welcome.ts"; | |
| 65 | 66 | import { dueOn } from "./reminders.ts"; |
| 66 | 67 | import { tokensCss } from "./tokens.ts"; |
| 67 | 68 | import type { Who } from "./who.ts"; |
| @@ -318,6 +319,7 @@ export const routes: readonly Route[] = [ | ||
| 318 | 319 | path: "/", |
| 319 | 320 | handle: (c) => { |
| 320 | 321 | const { notice, clear } = readNotice(c.request); |
| 322 | if (c.who.role === "anon") return html(welcomePage({ who: c.who, on: today() }), 200, clear); | |
| 321 | 323 | const deals = listDeals(c.db, c.who); |
| 322 | 324 | if (!deals.ok) |
| 323 | 325 | return html( |
src/server.test.ts +13 −4
| @@ -53,15 +53,24 @@ const rpc = (message: unknown, who: Record<string, string> = {}) => | ||
| 53 | 53 | |
| 54 | 54 | test("the clock knows who you are and offers the right door", async () => { |
| 55 | 55 | const guest = await (await fetch(base + "/")).text(); |
| 56 | expect(guest).toContain("<h1>The clock</h1>"); | |
| 57 | expect(guest).toContain("/__forge/signin?to=%2F"); | |
| 56 | expect(guest).toContain("Every deadline of every deal on one timeline"); | |
| 57 | expect(guest).toContain('href="/__forge/signin?to=%2F"'); | |
| 58 | expect(guest.match(/>Sign in</g)).toHaveLength(1); | |
| 59 | expect(guest).toContain('class="marker"'); | |
| 60 | expect(guest).not.toContain("<script"); | |
| 61 | expect(guest).not.toContain("Maya"); | |
| 62 | expect(guest).not.toContain("Ruth Lindqvist"); | |
| 58 | 63 | expect(guest).toContain('href="/__forge/report"'); |
| 59 | 64 | expect(guest).not.toContain('href="/deals/new"'); |
| 60 | 65 | expect(guest).not.toContain('action="/deadlines/'); |
| 61 | expect(guest).toContain("Sign in to see deals."); | |
| 62 | 66 | expect(guest).not.toContain("Alder Lane"); |
| 67 | const headers = (await fetch(base + "/")).headers; | |
| 68 | expect(headers.get("content-security-policy")).toBeTruthy(); | |
| 69 | expect(headers.get("x-content-type-options")).toBe("nosniff"); | |
| 70 | expect(headers.get("referrer-policy")).toBeTruthy(); | |
| 63 | 71 | const signed = await (await api("/", {}, alice)).text(); |
| 64 | 72 | expect(signed).toContain("<b>alice</b>"); |
| 73 | expect(signed).toContain("<h1>The clock</h1>"); | |
| 65 | 74 | expect(signed).toContain("/__forge/signout"); |
| 66 | 75 | expect(signed).toContain('href="/deals/new"'); |
| 67 | 76 | expect(signed).toContain('action="/deadlines/'); |
| @@ -553,7 +562,7 @@ test("the clock is gzipped for whoever asks, and plain for whoever does not", as | ||
| 553 | 562 | expect(zipped.headers.get("content-security-policy")).toContain("default-src"); |
| 554 | 563 | const plain = await fetch(base + "/", { headers: { "accept-encoding": "identity" } }); |
| 555 | 564 | expect(plain.headers.get("content-encoding")).toBeNull(); |
| 556 | expect(await plain.text()).toContain("The clock"); | |
| 565 | expect(await plain.text()).toContain("Every deadline of every deal"); | |
| 557 | 566 | }); |
| 558 | 567 | |
| 559 | 568 | test("a form route answers 4xx, never 500, to a body that is not a form", async () => { |
static/app.css +17
| @@ -782,6 +782,23 @@ textarea.input { | ||
| 782 | 782 | flex: none; |
| 783 | 783 | } |
| 784 | 784 | |
| 785 | /* The signed-out front page: a headline, three points, a still picture of the clock. */ | |
| 786 | .welcome h1 { | |
| 787 | max-width: 40rem; | |
| 788 | margin: 0 0 var(); | |
| 789 | } | |
| 790 | .points { | |
| 791 | max-width: 40rem; | |
| 792 | margin: 0 0 var(); | |
| 793 | padding-left: var(); | |
| 794 | } | |
| 795 | .welcome .card { | |
| 796 | margin-top: var(); | |
| 797 | } | |
| 798 | .welcome .marker { | |
| 799 | cursor: default; | |
| 800 | } | |
| 801 | ||
| 785 | 802 | /* The client timeline. */ |
| 786 | 803 | .timeline-list { |
| 787 | 804 | list-style: none; |
new above
offline
This is a second Sign in on the page: layout already renders one in the header (href=/__forge/signin?to=%2F). The issue says one Sign in button. Keep one, and add a test counting Sign in links on the guest page.