# Week Calendar (Notchset): prompt.md (v1.0.0)

- id: `week-calendar` · version 1.0.0 · block · pro (Pro)
- category: Application UI
- build: Base UI (one set of files; its dependencies follow the build)
- install (this build): `npx shadcn@latest add @beautiful-ui-pro/week-calendar`
- npm dependencies: class-variance-authority@^0.7
- registry dependencies: utils, @beautiful-ui/segmented-control, https://beautiful-ui.dev/r/notchset-foundation.json
- docs: https://beautiful-ui.dev/components/week-calendar
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

A week calendar: TODAY, previous and next, WEEK / WEEKDAYS / DAY, a mini month that jumps to any week, calendars you can hide with counts, an all-day row, an hour grid where overlapping events cascade and text fits each event's height, a now line, click-to-draft events with a title, a calendar and SAVE, and an event panel whose delete needs a second press.

## Build it
- Stack: React 19 (`ref` is a plain prop), TypeScript, Tailwind CSS v4 utilities, a shadcn-initialised project with the `@/*` alias.
- Packages: `class-variance-authority@^0.7`.
- Files: `components/ui/notchset/blocks/week-calendar.tsx`; shared code: `lib/beautiful-ui/notchset/instrument.tsx`, `lib/beautiful-ui/notchset/root.ts`, `lib/beautiful-ui/notchset/button-variants.ts`, `lib/beautiful-ui/notchset/field-classes.ts`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `segmented-control`, `notchset-foundation`.
- Builds: one set of files for both, but its dependencies come in Base UI and Radix builds. Install the one that matches the project (see Install): a free item's bare URL installs the Base UI build of it and its dependencies.
- Exports to keep: `WeekCalendar`, and every exported type.
- CSS: the install adds the notchset foundation (tokens, keyframes, motion levels) to your global stylesheet once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Tokens: retheme with the `--notchset-*` custom properties (`--notchset-check`, `--notchset-control-edge`, `--notchset-draw-from`, `--notchset-ease-bloom`, `--notchset-ease-glide`, `--notchset-ease-key-down`, `--notchset-ease-key-up`, `--notchset-ease-travel`, `--notchset-fade`, `--notchset-focus-color`, `--notchset-focus-inset`, `--notchset-grow-to`, `--notchset-key-down`, `--notchset-key-up`, `--notchset-life-from`, `--notchset-life-ms`, `--notchset-node-blink`, `--notchset-node-bloom`, `--notchset-node-delay`, `--notchset-plate-color`, `--notchset-rise-from`, `--notchset-rule`, `--notchset-scan-to`, `--notchset-scroll`, `--notchset-signal`, `--notchset-sweep-to`, `--notchset-travel`). Never add Tailwind colour classes inside the component.

```tsx
import { WeekCalendar, type CalendarDef, type CalendarEvent } from "@/components/ui/notchset/blocks/week-calendar";
```

## Parts

| Part | data-slot | What it is for |
|---|---|---|
| `WeekCalendar` | `week-calendar` | Toolbar, sidebar, all-day row, hour grid and event panel. |

Style a part with `[data-slot="<slot>"]` selectors or its `className`; keep the attributes when editing.

## Sound
- Keep every `data-slot` and `data-sound` attribute: the sound layer reads them.
- Installing this item adds no audio. Nothing plays until the app mounts `SoundProvider` once (install: `npx shadcn@latest add https://beautiful-ui.dev/r/notchset-sound.json`, import from `@/components/ui/notchset/sound-provider`); `useSound()` gives `muted` and `setMuted` for a mute control. Without a provider the audio engine never loads.

## Match the original
- Read `components/ui/notchset/blocks/week-calendar.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when
- week calendar, calendar view, schedule, agenda, events, scheduler, day view, Notchset
- Showing a person's or team's week of meetings
- Letting people add an event straight from the grid

### Not when
- Month planning: use a month grid
- Booking a slot across people: use Find Time

## Mistakes
- Convert events to one zone before passing them
- Keep the grid to working hours; events outside from–to are clipped to it

## Usage

```tsx
import { WeekCalendar, type CalendarDef, type CalendarEvent } from "@/components/ui/notchset/blocks/week-calendar";

export function Agenda({ calendars, events }: { calendars: CalendarDef[]; events: CalendarEvent[] }) {
  return (
    <WeekCalendar
      calendars={calendars}
      events={events}
      today={new Date().toISOString().slice(0, 10)}
      zone="ZÜRICH · UTC+2"
      onCreate={async (event) => {
        const res = await fetch("/api/events", { method: "POST", body: JSON.stringify(event) });
        return (await res.json()) as CalendarEvent;
      }}
    />
  );
}
```

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `calendars` | `{ id, label, tone }[]` |  | tone is "ink", "muted", "edge" or "hatched": a left bar and a fill, no new hues. |
| `events` | `{ id, date, start, end, calendar, title, location?, note? }[]` |  | ISO dates and hours in the calendar's zone (9.5 is 09:30). |
| `allDay` | `{ id, from, to, calendar, title }[]` |  | Banners across the all-day row. |
| `today / now / zone` | `string / number / string` |  | Opens on today's week; now (hours) draws the now line; zone labels the sidebar. |
| `onCreate / onDelete` | `(event) => Promise<event> / (event) => void` |  | Store a drafted event (resolve with it) and a deletion. |

Full docs: https://beautiful-ui.dev/components/week-calendar

## Customising
- Colours: the component reads your shadcn tokens (`--background`, `--foreground`, `--border` …), refined by the `--notchset-*` tokens. The signal colour is `--notchset-signal` (it falls back to `--destructive`). Set tokens on `:root`, or on any container to retheme one area.
- Dark mode follows the `.dark` class on an ancestor (the shadcn and next-themes convention).
- Update later by re-running the install with `--overwrite` (review the diff if you edited it). Changelog: https://beautiful-ui.dev/r/changelog.json

## Keyboard

| Keys | Action |
|---|---|
| Tab then Enter | Open an event or a day (day view) |
| Enter | Save a draft from its title field |
| Esc | Close the panel or discard a draft |
| ← → | Change the view |

## Performance

- Overlaps are laid out per day on render; nothing runs while idle.

## Responsive

- Under 760px (container width) the sidebar hides and days keep 96px, scrolling sideways.

## Motion inventory

| Interaction | What moves |
|---|---|
| Week, day and view changes | The grid slides in from the direction of travel (380ms settle) |
| Draft | Scales in from the top (260ms) |
| Hide a calendar | Its events fade out (200ms) |
| Panel | Rises in (260ms) |

## Accessibility contract (preserve when editing)
- Every event is a button named with its title and time; the panel is a labelled dialog that Esc closes
- Calendars are checkboxes; hidden events leave the tab order
- The range label is a polite live region, so previous and next are announced

## Install

```bash
npx shadcn@latest add @beautiful-ui-pro/week-calendar
```

Pro item: needs the `@beautiful-ui-pro` registry in `components.json` and `BEAUTIFUL_UI_TOKEN` in `.env.local` (https://beautiful-ui.dev/account). Setup: https://beautiful-ui.dev/docs/pro. Your components.json `style` picks the build: radix-*, new-york and default get Radix, base-* gets Base UI.

## Credits
- Built on shadcn/ui (https://ui.shadcn.com)

The notchset foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://beautiful-ui.dev/r/notchset-foundation.json.
