diff --git a/docs/superpowers/specs/2026-12-03-page-builder-design.md b/docs/superpowers/specs/2026-12-03-page-builder-design.md new file mode 100644 index 0000000..6ed5395 --- /dev/null +++ b/docs/superpowers/specs/2026-12-03-page-builder-design.md @@ -0,0 +1,114 @@ +# Landing-page builder for marketing staff — design + +Status: draft for owner approval, 2026-12-03. + +## Why + +Marketing staff at INS and CV build a landing page for every event. They are not technical. Today they fill in a form of blocks and open a separate preview of the last saved version, and the one real page (INS "hotel-technology") is pasted HTML that only a developer can change. The owner wants a Wix-like experience: staff edit the page itself and see the result as they work, and start from templates rather than a blank page. + +Success: a marketing staff member, without help, creates an event page from a template, changes its text and images on the page, links its form to the event, checks it at phone size, and publishes it, in well under an hour. + +## Goals + +- Edit on the page: click text to change it, click a section to change its settings, add, move, duplicate and remove sections, and see the change at once. +- Desktop and phone views in the editor, each showing the page exactly as visitors on that device see it. +- Templates: start a page from a ready-made design, or copy an earlier event's page. +- Enough section types to build a page like the INS one without code. + +## Non-goals + +- Free placement of elements anywhere on a canvas (owner chose stacking sections, 2026-12-03). +- Per-element styling: fonts, sizes or colours chosen per text. Each section has a small set of looks instead. +- Animations, page version history, scheduled publishing, custom domains, A/B tests. +- Editing pages on a phone: the on-page editor is for laptop and desktop screens. + +## Anti-goals + +- A page that looks fine in the editor but broken on a visitor's phone. +- An editor that saves anything the server would not accept, or shows something different from the public page. +- Weakening the landing-page rules: block validation, HTML sanitising, the sealed Custom HTML frame, and company scoping all stay as they are. + +## Constraints + +- Go-live is 2027-01-15. The work ships as three changes, each usable on its own, so a late editor does not hold back the rest. The current form editor keeps working until the on-page editor replaces it. +- Pages stay one JSON list of blocks in `cms_page.blocks`, checked by services-counter. New section types extend that list; the editor writes the same JSON. +- Tailwind 3.4 with viewport breakpoints (`sm:`, `md:`): a block's phone layout depends on the window width, not the width of its container. +- Owner rules apply: TDD, Playwright checks, no Tastefully customer data, and SQL only in the change folders. + +## Approaches considered + +**How staff place content** (owner's choice): stacking full-width sections (chosen) versus free placement on a canvas. Free placement roughly doubles the build and makes phone layouts the staff's problem. + +**How the editor is built** (my call, the owner handed over the how): + +1. **Our own editor on the existing blocks (chosen).** The page renders in edit mode inside a same-origin frame. Text becomes editable in place (Tiptap, already installed, for rich text), and a side panel reuses today's block fields. Pros: the data, validation, sanitising and public rendering do not change; no large dependency. Cons: drag-and-drop, selection and undo are ours to build and test. +2. **An open-source page-builder library (Puck, MIT).** It ships drag-and-drop, a fields panel, an outline and undo. Pros: less UI to build. Cons: a large new dependency with its own look and data format (an adapter both ways), and its in-place text editing is less mature than Tiptap (unverified for the current version). Rejected: the parts it saves us are the smaller parts of the work. +3. **An HTML builder (GrapesJS).** It produces free-form HTML and CSS. Rejected: it bypasses block validation and sanitising, it cannot hold the lead form, and it is free placement. + +**Phone view** (my call): render the page in a frame of the chosen width, so the page's own breakpoints apply, as visitors see it. The alternative, container queries, needs a Tailwind plugin and changes to every block's and the sign-up form's classes, which the QR registration pages share. + +**Templates** (my call): starter templates shipped with the portal, plus "Duplicate page". Templates saved by staff per company would need a new table and screens; duplicating last event's page covers the "every event" case without them. + +## Design + +### Change 1: `add-page-sections` (new section types and section looks) + +New block types, each validated in services-counter, rendered by the public page and edited in today's form: + +- `FEATURES`: heading, optional intro, 2 to 6 cards, each with an icon from a fixed list (about 12 Lucide icons), a title and a short text. +- `STEPS`: heading, 2 to 6 numbered steps, each with a title and a short text. +- `TRUST`: 2 to 6 short items in one strip (for example "Certified with LG · Samsung · Philips"). +- `CTA`: a full-width band with a heading, a short text and a button. + +Every block gains a look: `DEFAULT`, `MUTED`, `DARK` or `ACCENT` (the company's accent colour). The look sets the background and the text colour, which is always readable on it. Sections become full-width bands with their content centred, so a page reads like the INS design. The HERO image becomes optional: a hero without an image uses its look's background. + +Limits follow the existing ones: headings 120 characters, short texts 300, card and step titles 80. + +### Change 2: `add-page-templates` + +- "New page" first asks for a starting point: Blank, or a starter template with a thumbnail and one line on what it is for. Starters at launch: **Event sign-up** (hero, trust strip, features, steps, FAQ, sign-up form, CTA) and **Service showcase** (hero, image with text, features, FAQ, CTA, form). Placeholder text tells staff what to write ("Your event name"). Templates hold no images; the editor marks the image spots to fill in. +- A template's sign-up form has no event yet. Saving tells staff to pick one, as today. +- "Duplicate" on the pages list and in the editor copies a page into a new draft of the same company, with slug `-copy` and status Draft. It runs in the portal (load, then save as new). It needs no new API. +- Starters live in portal code as block lists, with their own tests that every starter passes the same rules as a save. + +### Change 3: `add-page-visual-editor` (the on-page editor) + +Layout, at 1024 px and wider: + +``` +┌ ← Pages Hotel day ▾ Draft [Desktop|Phone] ↶ ↷ [Preview] [Save] [Publish] ┐ +├───────────────────────────────────────────────────────────────┬───────────────────────┤ +│ ┌──────── canvas (the page, at the chosen width) ────────┐ │ Section: Features │ +│ │ HERO "Hotel technology that just works" │ │ Look: [Muted ▾] │ +│ │ ┌─[⠿ ↑ ↓ ⧉ 🗑]──────────────────────────────────────┐ │ │ Link name: [ ] │ +│ │ │ FEATURES (selected) click any text to edit │ │ │ Cards: 3 [+ card] │ +│ │ └─────────────────────────────────────────────────────┘ │ │ Icon card 1: [Wifi▾] │ +│ │ [ + Add section ] │ │ │ +│ └─────────────────────────────────────────────────────────┘ │ │ +└───────────────────────────────────────────────────────────────┴───────────────────────┘ +``` + +- **Canvas.** A same-origin frame showing the page through the same `LandingPage` component the public page uses, in edit mode, at full width (Desktop) or 390 px (Phone). The editor and the canvas exchange the draft and the edit events by `postMessage`, and each accepts messages only from the other. Custom HTML blocks stay sealed frames inside the canvas, showing the unsaved HTML. +- **Select.** Hovering a section outlines it. Clicking selects it and shows its toolbar: drag handle, up, down, duplicate, delete. The side panel shows that section's settings, which are today's block fields plus the look and the link name. With nothing selected, the panel shows the page settings: title, address, description, header, status. +- **Edit text in place.** Clicking a heading, a short text or a button label edits it in place as plain text, with the same length limits as the server, shown when close. Rich text (Text and Image-with-text blocks) edits in place with Tiptap and a small floating toolbar (bold, italic, link, lists, alignment). Links are typed in the side panel or the toolbar's link box, and follow the existing link rule. +- **Images.** Clicking an image, or an empty image spot, opens the file picker. The new image shows at once and uploads on save, as today. +- **Add and move.** "+ Add section" between sections and at the end opens a picker of section types with small thumbnails. Sections move by dragging the handle (native drag-and-drop) or with the up and down buttons; the buttons are also the keyboard path. +- **Undo and redo.** Page-level, up to 50 steps, with Ctrl+Z and Ctrl+Shift+Z. +- **Saving.** Save keeps the draft; Publish saves with status Published. Server refusals show on the canvas (the section is outlined, and the panel shows the field's message), using today's error paths. Leaving with unsaved changes asks first, including in-app links (this closes today's gap). +- **Below 1024 px** the editor shows today's form, with Preview, because the canvas and panel do not fit. + +The server and the public page do not change in this change, apart from edit-mode hooks in `LandingPage` that only the canvas uses. + +## Left to the builder + +- The exact icon list, the starter templates' wording, the thumbnail images, and the colours of each look within the design tokens. +- Undo grouping (one step per word or per field). +- Whether the canvas reuses `BlockFields` sub-components for the side panel or splits them. + +## Sequencing + +1. `add-page-sections`: about 3 to 4 days. +2. `add-page-templates`: about 2 days. +3. `add-page-visual-editor`: about 2 to 3 weeks. + +Each is its own OpenSpec change, approved before it is built. Once change 1 is out, the INS page can be rebuilt as sections instead of pasted HTML. Staff do this in the editor; it is content, not code.