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

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

mason/deal-clock:mason/29-a-signed-out-visitor-lands-on-a-page-tha → main 3 commits fork 1 thread · 1 unresolved

  • Merged. mason/29-a-signed-out-visitor-lands-on-a-page-tha was merged into main as ec11a46.

Review

Sign in to review this change.
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
2222 reads well on a phone, with no sideways scrolling. In the terminal, press w
2323 for the same list; over MCP, an agent asks for the `this_week` tool.
2424
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
2527 1. **Look at the clock.** You see four lanes: 77 Harbor View Dr, Unit 4B
2628 (the inspection date has passed, so its marker is red), 1418 Alder Lane
2729 (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 {
6262 }
6363
6464 /** 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 {
6666 const out: string[] = [];
6767 for (let i = 0; i < days; i++) {
6868 const day = addDays(start, i);
src/pages/layout.ts +3 −1
@@ -25,6 +25,8 @@ export function layout(input: {
2525 path: string;
2626 heading?: string;
2727 notice?: string | undefined;
28 /** Whether the page keeps its regions live; false for a page with none. */
29 live?: boolean;
2830 /** A page handed to someone outside the app: the brand only, no sign-in, footer or script. */
2931 plain?: boolean;
3032 /** A class on <body>, for styles that belong to one page only. */
@@ -58,7 +60,7 @@ export function layout(input: {
5860 <meta name="twitter:description" content="${escape(description)}">
5961 <link rel="stylesheet" href="${tokensHref}">
6062 <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>`}
6264 <body${bodyClass === undefined ? "" : ` class="${escape(bodyClass)}"`}>
6365 <div class="page">
6466 <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">
outdated

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.

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";
6262 import { dealPage, newDealPage } from "./pages/deal.ts";
6363 import { refusedPage } from "./pages/refused.ts";
6464 import { timelinePage } from "./pages/timeline.ts";
65 import { welcomePage } from "./pages/welcome.ts";
6566 import { dueOn } from "./reminders.ts";
6667 import { tokensCss } from "./tokens.ts";
6768 import type { Who } from "./who.ts";
@@ -318,6 +319,7 @@ export const routes: readonly Route[] = [
318319 path: "/",
319320 handle: (c) => {
320321 const { notice, clear } = readNotice(c.request);
322 if (c.who.role === "anon") return html(welcomePage({ who: c.who, on: today() }), 200, clear);
321323 const deals = listDeals(c.db, c.who);
322324 if (!deals.ok)
323325 return html(
src/server.test.ts +13 −4
@@ -53,15 +53,24 @@ const rpc = (message: unknown, who: Record<string, string> = {}) =>
5353
5454 test("the clock knows who you are and offers the right door", async () => {
5555 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");
5863 expect(guest).toContain('href="/__forge/report"');
5964 expect(guest).not.toContain('href="/deals/new"');
6065 expect(guest).not.toContain('action="/deadlines/');
61 expect(guest).toContain("Sign in to see deals.");
6266 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();
6371 const signed = await (await api("/", {}, alice)).text();
6472 expect(signed).toContain("<b>alice</b>");
73 expect(signed).toContain("<h1>The clock</h1>");
6574 expect(signed).toContain("/__forge/signout");
6675 expect(signed).toContain('href="/deals/new"');
6776 expect(signed).toContain('action="/deadlines/');
@@ -553,7 +562,7 @@ test("the clock is gzipped for whoever asks, and plain for whoever does not", as
553562 expect(zipped.headers.get("content-security-policy")).toContain("default-src");
554563 const plain = await fetch(base + "/", { headers: { "accept-encoding": "identity" } });
555564 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");
557566 });
558567
559568 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 {
782782 flex: none;
783783 }
784784
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(--space-4);
789 }
790 .points {
791 max-width: 40rem;
792 margin: 0 0 var(--space-4);
793 padding-left: var(--space-4);
794 }
795 .welcome .card {
796 margin-top: var(--space-5);
797 }
798 .welcome .marker {
799 cursor: default;
800 }
801
785802 /* The client timeline. */
786803 .timeline-list {
787804 list-style: none;

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs