diff --git a/AGENTS.md b/AGENTS.md index 2bf3378a6..20a474b85 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,3 +11,17 @@ The comprehensive agent guidelines for this repository are located in: ## Typography Set type per the [Cal Sans font guide](packages/ui/src/fonts/font-guide.md): no added letter-spacing, `font-optical-sizing: auto` instead of a hard-coded `opsz`, one `GEOM` value per role, no synthesized bold or italic, and typeset punctuation (’ – − “ ”) in UI strings. + +## Agent skills + +### Issue tracker + +Issues and specs live as markdown files under `.scratch//`. See `docs/agents/issue-tracker.md`. + +### Triage labels + +The five default triage roles, recorded as a `Status:` line in each issue file. See `docs/agents/triage-labels.md`. + +### Domain docs + +Single-context: one `GLOSSARY.md` and `docs/adr/` at the repo root. See `docs/agents/domain.md`. diff --git a/GLOSSARY.md b/GLOSSARY.md new file mode 100644 index 000000000..fd79981fa --- /dev/null +++ b/GLOSSARY.md @@ -0,0 +1,33 @@ +# coss ui + +A registry of copy-paste React components installed with the shadcn CLI. This glossary fixes the words used for the kinds of thing the registry ships. + +## Language + +**Atom**: +A registry item that connects coss ui components to the Cal.com API, so it works against real scheduling data once installed. +_Avoid_: Cal atom, widget, block, embed + +**Booker**: +The atom that lets someone pick a time and book a Cal.com event. +_Avoid_: Booking widget, scheduler, calendar embed + +**Event type**: +What an attendee books: a kind of meeting a host offers on Cal.com, with its own title, duration, locations and rules. +_Avoid_: Event, target, meeting type, booking link + +**Attendee**: +The person booking an event through the Booker. +_Avoid_: Booker (for the person), visitor, user, customer + +**Guest**: +A person the attendee adds to their booking. +_Avoid_: Additional attendee, invitee + +**Fallback**: +What the Booker shows in place of the booking flow when an event cannot be booked through it: a short message and a link to the event's own Cal.com booking page. +_Avoid_: Error state, unsupported screen + +**Particle**: +A pre-assembled registry item that combines several primitives into a ready-to-use piece of interface, with no connection to an outside service. +_Avoid_: Block, pattern, atom diff --git a/apps/ui/app/playground/booker/page.tsx b/apps/ui/app/playground/booker/page.tsx new file mode 100644 index 000000000..01725f94a --- /dev/null +++ b/apps/ui/app/playground/booker/page.tsx @@ -0,0 +1,50 @@ +import type { Metadata } from "next"; +import { Booker } from "@/registry/default/booker/booker"; +import { fetchRawBookerDataAction } from "@/registry/default/booker/lib/actions"; +import type { BookerTarget } from "@/registry/default/booker/lib/target"; + +export const metadata: Metadata = { + title: "Booker Playground - coss ui", +}; + +const defaultBookingUrl = "https://i.cal.com/pasquale/15min"; +const timeZone = "Europe/Rome"; + +type BookerPlaygroundPageProps = { + searchParams: Promise<{ bookingUrl?: string | string[] }>; +}; + +// Temporary demo page. Pass `?bookingUrl=` to point the Booker at another +// event, e.g. `?bookingUrl=cal.com/rickastley/15min`. +export default async function BookerPlaygroundPage({ + searchParams, +}: BookerPlaygroundPageProps) { + const { bookingUrl } = await searchParams; + const target = { + bookingUrl: + typeof bookingUrl === "string" && bookingUrl.trim() + ? bookingUrl + : defaultBookingUrl, + type: "link", + } satisfies BookerTarget; + + const initialInput = { + fetchMeta: true, + monthIso: new Date().toISOString(), + monthsToFetch: 3, + target, + timeZone, + }; + const initialData = { + monthIso: initialInput.monthIso, + monthsToFetch: initialInput.monthsToFetch, + result: await fetchRawBookerDataAction(initialInput), + timeZone: initialInput.timeZone, + }; + + return ( +
+ +
+ ); +} diff --git a/apps/ui/app/playground/booker/prototype-confirmation/confirmation-prototype.tsx b/apps/ui/app/playground/booker/prototype-confirmation/confirmation-prototype.tsx new file mode 100644 index 000000000..ee9484376 --- /dev/null +++ b/apps/ui/app/playground/booker/prototype-confirmation/confirmation-prototype.tsx @@ -0,0 +1,58 @@ +"use client"; + +// PROTOTYPE ONLY. Mounts one confirmation variant with a synthetic booking, +// the state panel and the switcher. + +import { useEffect, useState } from "react"; +import { PrototypeSwitcher } from "../../prototype-switcher"; +import { + bookings, + type ScenarioKey, + scenarios, + type VariantKey, + variants, +} from "./fixtures"; +import { VariantA, type VariantProps } from "./variants"; + +const variantComponents: Record< + VariantKey, + (props: VariantProps) => React.ReactElement +> = { A: VariantA }; + +export function ConfirmationPrototype({ + variant, + scenario, +}: { + variant: VariantKey; + scenario: ScenarioKey; +}) { + const [lastAction, setLastAction] = useState("none"); + const booking = bookings[scenario]; + const Variant = variantComponents[variant]; + + // biome-ignore lint/correctness/useExhaustiveDependencies: reset on switch + useEffect(() => { + setLastAction("none"); + }, [scenario, variant]); + + return ( +
+ + +
+        {JSON.stringify(
+          { lastAction: `${lastAction} (stub)`, scenario, variant, booking },
+          null,
+          2,
+        )}
+      
+ + ({ ...item }))} + variant={variant} + variants={variants.map((item) => ({ ...item }))} + /> +
+ ); +} diff --git a/apps/ui/app/playground/booker/prototype-confirmation/fixtures.ts b/apps/ui/app/playground/booker/prototype-confirmation/fixtures.ts new file mode 100644 index 000000000..b3d567198 --- /dev/null +++ b/apps/ui/app/playground/booker/prototype-confirmation/fixtures.ts @@ -0,0 +1,117 @@ +// PROTOTYPE ONLY. Synthetic bookings, modelled on what Cal's API returns after +// a booking is created. No network. + +export type ProtoLocation = + | { kind: "video"; label: string; link: string } + | { kind: "address"; label: string; address: string } + | { kind: "phone"; label: string; phone: string }; + +export type ProtoOccurrence = { date: string; time: string }; + +export type ProtoBooking = { + status: "accepted" | "pending"; + title: string; + description: string; + host: string; + hostInitials: string; + date: string; + time: string; + // The same start, local time, for the event pane's selected time. + start: Date; + durationMinutes: number; + timeZone: string; + location: ProtoLocation; + attendee: { name: string; email: string }; + guests: string[]; + notes?: string; + // Set for a recurring series; `date` and `time` are then the first one. + occurrences?: ProtoOccurrence[]; +}; + +const base: ProtoBooking = { + attendee: { email: "dana@example.com", name: "Dana Whitfield" }, + date: "Monday, November 23, 2026", + description: "A walkthrough tailored to your team, with time for questions.", + durationMinutes: 30, + guests: [], + host: "Rick Astley", + hostInitials: "RA", + location: { + kind: "video", + label: "Cal Video", + link: "https://app.cal.com/video/abc123", + }, + start: new Date(2026, 10, 23, 10, 0), + status: "accepted", + time: "10:00 – 10:30am", + timeZone: "Europe/Rome", + title: "Product demo", +}; + +export const bookings = { + accepted: base, + inPerson: { + ...base, + guests: ["sam@example.com", "priya@example.com"], + location: { + address: "Via Torino 12, 20123 Milan", + kind: "address", + label: "In person", + }, + notes: "We would like to see the routing features in particular.", + }, + pending: { ...base, status: "pending" }, + recurring: { + ...base, + occurrences: [ + { date: "Monday, November 23, 2026", time: "10:00 – 10:30am" }, + { date: "Monday, November 30, 2026", time: "10:00 – 10:30am" }, + { date: "Monday, December 7, 2026", time: "10:00 – 10:30am" }, + { date: "Monday, December 14, 2026", time: "10:00 – 10:30am" }, + ], + }, +} satisfies Record; + +export const variants = [{ key: "A", label: "In place" }] as const; + +export type VariantKey = (typeof variants)[number]["key"]; + +export const scenarios = [ + { key: "accepted", label: "Confirmed" }, + { key: "pending", label: "Awaiting the host" }, + { key: "recurring", label: "Recurring series" }, + { key: "inPerson", label: "In person, guests, notes" }, +] as const; + +export type ScenarioKey = (typeof scenarios)[number]["key"]; + +export const calendars = ["Google", "Outlook", "Apple or other (.ics)"]; + +export function getHeadline(booking: ProtoBooking) { + if (booking.status === "pending") { + return { + text: `${booking.host} needs to confirm this booking. We’ll email ${booking.attendee.email} when they do.`, + title: "Waiting for confirmation", + }; + } + if (booking.occurrences) { + return { + text: `Calendar invitations are on their way to ${booking.attendee.email}.`, + title: `${booking.occurrences.length} meetings booked`, + }; + } + return { + text: `A calendar invitation is on its way to ${booking.attendee.email}.`, + title: "You’re booked", + }; +} + +export function getLocationText(location: ProtoLocation) { + if (location.kind === "video") { + return location.label; + } + if (location.kind === "address") { + return location.address; + } + return location.phone; +} diff --git a/apps/ui/app/playground/booker/prototype-confirmation/page.tsx b/apps/ui/app/playground/booker/prototype-confirmation/page.tsx new file mode 100644 index 000000000..7e1d49382 --- /dev/null +++ b/apps/ui/app/playground/booker/prototype-confirmation/page.tsx @@ -0,0 +1,44 @@ +// PROTOTYPE ONLY. Throwaway route for the wayfinder ticket "The confirmation +// screen" (.scratch/booker/issues/09-confirmation-screen.md). +// +// The chosen layout of what an attendee sees after booking, with a synthetic +// booking picked by the `scenario` search param. Nothing is sent. The two +// layouts that lost are on the `prototype/booker-confirmation` branch. + +import type { Metadata } from "next"; +import { ConfirmationPrototype } from "./confirmation-prototype"; +import { + type ScenarioKey, + scenarios, + type VariantKey, + variants, +} from "./fixtures"; + +export const metadata: Metadata = { + title: "Booker confirmation prototype - coss ui", +}; + +type PageProps = { + searchParams: Promise<{ + variant?: string | string[]; + scenario?: string | string[]; + }>; +}; + +export default async function BookerConfirmationPrototypePage({ + searchParams, +}: PageProps) { + const params = await searchParams; + const variant = + variants.find((item) => item.key === params.variant)?.key ?? + ("A" satisfies VariantKey); + const scenario = + scenarios.find((item) => item.key === params.scenario)?.key ?? + ("accepted" satisfies ScenarioKey); + + return ( +
+ +
+ ); +} diff --git a/apps/ui/app/playground/booker/prototype-confirmation/variants.tsx b/apps/ui/app/playground/booker/prototype-confirmation/variants.tsx new file mode 100644 index 000000000..297d3f83c --- /dev/null +++ b/apps/ui/app/playground/booker/prototype-confirmation/variants.tsx @@ -0,0 +1,190 @@ +"use client"; + +// PROTOTYPE ONLY. The chosen layout of the screen an attendee sees after +// booking. The two layouts that lost are on the prototype/booker-confirmation +// branch. + +import { CalendarPlusIcon, CircleCheckIcon, HourglassIcon } from "lucide-react"; +import type { ReactNode } from "react"; +import { getBookerLabels } from "@/registry/default/booker/booker-labels"; +import { EventDescription } from "@/registry/default/booker/event-description"; +import { + EventTitle, + FixedDuration, + HostIdentity, + RequiresConfirmation, + SelectedTime, +} from "@/registry/default/booker/event-meta"; +import { LocationRow } from "@/registry/default/booker/location"; +import { TimezoneDisplay } from "@/registry/default/booker/timezone-picker"; +import { Button } from "@/registry/default/ui/button"; +import { Card } from "@/registry/default/ui/card"; +import { + calendars, + getHeadline, + getLocationText, + type ProtoBooking, +} from "./fixtures"; + +const labels = getBookerLabels(); + +export type VariantProps = { + booking: ProtoBooking; + onAction: (action: string) => void; +}; + +const cardClassName = + "@max-3xl:w-full @3xl:flex-row @5xl:[--booker-side:--spacing(70)] [--booker-side:--spacing(56)]"; +const sideClassName = + "@3xl:w-(--booker-side) @3xl:border-e border-b @3xl:border-b-0"; +const mainClassName = + "@3xl:w-[min(28.75rem,100cqw-2*var(--booker-side))] w-full @3xl:shrink-0 @5xl:p-6 p-4"; + +function StatusIcon({ + booking, + className, +}: { + booking: ProtoBooking; + className?: string; +}) { + return booking.status === "pending" ? ( +