feat(pages): complete reusable page block editor controls
This commit is contained in:
3
TODO.md
3
TODO.md
@@ -137,7 +137,7 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
### Admin App (Primary Focus)
|
### Admin App (Primary Focus)
|
||||||
|
|
||||||
- [~] [P1] Page management (create/edit/publish/unpublish/schedule)
|
- [~] [P1] Page management (create/edit/publish/unpublish/schedule)
|
||||||
- [ ] [P1] Page builder with reusable content blocks (hero, rich text, gallery, CTA, forms, price cards)
|
- [x] [P1] Page builder with reusable content blocks (hero, rich text, gallery, CTA, forms, price cards)
|
||||||
- [~] [P1] Navigation management (menus, nested items, order, visibility)
|
- [~] [P1] Navigation management (menus, nested items, order, visibility)
|
||||||
- [~] [P1] Media library (upload, browse, replace, delete) with media-type classification (artwork, banner, promo, generic, video/gif)
|
- [~] [P1] Media library (upload, browse, replace, delete) with media-type classification (artwork, banner, promo, generic, video/gif)
|
||||||
- [x] [P1] Media enrichment metadata (alt text, copyright, author, source, tags, licensing, usage context)
|
- [x] [P1] Media enrichment metadata (alt text, copyright, author, source, tags, licensing, usage context)
|
||||||
@@ -365,6 +365,7 @@ This file is the single source of truth for roadmap and delivery progress.
|
|||||||
- [2026-02-12] Artwork refinement baseline completed: admin `/portfolio` now captures/edits medium, dimensions, year, framing, availability, publish state, and optional price visibility (`priceAmountCents` + `priceCurrency`), with public artwork detail rendering visible prices only.
|
- [2026-02-12] Artwork refinement baseline completed: admin `/portfolio` now captures/edits medium, dimensions, year, framing, availability, publish state, and optional price visibility (`priceAmountCents` + `priceCurrency`), with public artwork detail rendering visible prices only.
|
||||||
- [2026-02-12] Artwork rendition management completed: admin `/portfolio` supports `thumbnail/card/full/retina/custom` slot assignment with dimensions and primary flag, plus per-artwork rendition listing and delete controls.
|
- [2026-02-12] Artwork rendition management completed: admin `/portfolio` supports `thumbnail/card/full/retina/custom` slot assignment with dimensions and primary flag, plus per-artwork rendition listing and delete controls.
|
||||||
- [2026-02-12] Media type presets baseline completed in upload API: server-side validation now uses shared per-type rules (mime + max size) for `artwork/banner/promotion/video/gif/generic`, with optional env cap override via `CMS_MEDIA_UPLOAD_MAX_BYTES`.
|
- [2026-02-12] Media type presets baseline completed in upload API: server-side validation now uses shared per-type rules (mime + max size) for `artwork/banner/promotion/video/gif/generic`, with optional env cap override via `CMS_MEDIA_UPLOAD_MAX_BYTES`.
|
||||||
|
- [2026-02-12] Page builder reusable blocks completed: admin block editor now supports full field editing + ordering controls for hero/rich-text/gallery/cta/form/price-cards; public renderer includes form-link behavior for `contact`/`commission` keys.
|
||||||
- [2026-02-12] Public UX pass: commission request flow now reports explicit invalid budget range errors, and header navigation now falls back to localized defaults (`home`, `portfolio`, `news`, `commissions`) when no CMS menu exists; seed data now creates those default menu entries.
|
- [2026-02-12] Public UX pass: commission request flow now reports explicit invalid budget range errors, and header navigation now falls back to localized defaults (`home`, `portfolio`, `news`, `commissions`) when no CMS menu exists; seed data now creates those default menu entries.
|
||||||
- [2026-02-12] Added `e2e/public-rendering.pw.ts` web coverage for fallback navigation visibility, portfolio routes, and commission submission validation (invalid budget range + successful submission path).
|
- [2026-02-12] Added `e2e/public-rendering.pw.ts` web coverage for fallback navigation visibility, portfolio routes, and commission submission validation (invalid budget range + successful submission path).
|
||||||
- [2026-02-12] Testing execution is temporarily paused for delivery velocity: root test scripts are stubbed and CI test steps are disabled; all testing backlog is consolidated under `MVP 3: Testing and Quality`.
|
- [2026-02-12] Testing execution is temporarily paused for delivery velocity: root test scripts are stubbed and CI test steps are disabled; all testing backlog is consolidated under `MVP 3: Testing and Quality`.
|
||||||
|
|||||||
@@ -43,6 +43,25 @@ function updateBlock(blocks: PageBlocks, blockId: string, next: Partial<PageBloc
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function moveBlock(blocks: PageBlocks, blockId: string, direction: "up" | "down"): PageBlocks {
|
||||||
|
const index = blocks.findIndex((entry) => entry.id === blockId)
|
||||||
|
|
||||||
|
if (index < 0) {
|
||||||
|
return blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
const nextIndex = direction === "up" ? index - 1 : index + 1
|
||||||
|
if (nextIndex < 0 || nextIndex >= blocks.length) {
|
||||||
|
return blocks
|
||||||
|
}
|
||||||
|
|
||||||
|
const next = [...blocks]
|
||||||
|
const current = next[index]
|
||||||
|
next[index] = next[nextIndex]
|
||||||
|
next[nextIndex] = current
|
||||||
|
return next
|
||||||
|
}
|
||||||
|
|
||||||
export function PageBlockEditor({
|
export function PageBlockEditor({
|
||||||
name,
|
name,
|
||||||
initialContent,
|
initialContent,
|
||||||
@@ -156,6 +175,21 @@ export function PageBlockEditor({
|
|||||||
<span>
|
<span>
|
||||||
#{index + 1} {block.type}
|
#{index + 1} {block.type}
|
||||||
</span>
|
</span>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1"
|
||||||
|
onClick={() => setBlocks((prev) => moveBlock(prev, block.id, "up"))}
|
||||||
|
>
|
||||||
|
Up
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="rounded border px-2 py-1"
|
||||||
|
onClick={() => setBlocks((prev) => moveBlock(prev, block.id, "down"))}
|
||||||
|
>
|
||||||
|
Down
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="rounded border px-2 py-1"
|
className="rounded border px-2 py-1"
|
||||||
@@ -164,6 +198,7 @@ export function PageBlockEditor({
|
|||||||
Remove
|
Remove
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{block.type === "hero" ? (
|
{block.type === "hero" ? (
|
||||||
<div className="grid gap-2 md:grid-cols-2">
|
<div className="grid gap-2 md:grid-cols-2">
|
||||||
@@ -187,6 +222,26 @@ export function PageBlockEditor({
|
|||||||
placeholder="Subheading"
|
placeholder="Subheading"
|
||||||
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
<input
|
||||||
|
value={block.ctaLabel ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { ctaLabel: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="CTA label"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
<input
|
||||||
|
value={block.ctaHref ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { ctaHref: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="CTA href"
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
@@ -203,6 +258,17 @@ export function PageBlockEditor({
|
|||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{block.type === "gallery" ? (
|
{block.type === "gallery" ? (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<input
|
||||||
|
value={block.title ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { title: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Gallery title"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
rows={3}
|
rows={3}
|
||||||
value={block.imageIds.join(",")}
|
value={block.imageIds.join(",")}
|
||||||
@@ -219,6 +285,7 @@ export function PageBlockEditor({
|
|||||||
placeholder="Media asset IDs (comma separated UUIDs)"
|
placeholder="Media asset IDs (comma separated UUIDs)"
|
||||||
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{block.type === "cta" ? (
|
{block.type === "cta" ? (
|
||||||
@@ -239,21 +306,71 @@ export function PageBlockEditor({
|
|||||||
placeholder="Link href"
|
placeholder="Link href"
|
||||||
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
<select
|
||||||
|
value={block.variant}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, {
|
||||||
|
variant: event.target.value as "primary" | "secondary",
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
className="rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
>
|
||||||
|
<option value="primary">Primary</option>
|
||||||
|
<option value="secondary">Secondary</option>
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{block.type === "form" ? (
|
{block.type === "form" ? (
|
||||||
|
<div className="space-y-2">
|
||||||
<input
|
<input
|
||||||
value={block.formKey}
|
value={block.formKey}
|
||||||
onChange={(event) =>
|
onChange={(event) =>
|
||||||
setBlocks((prev) => updateBlock(prev, block.id, { formKey: event.target.value }))
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { formKey: event.target.value }),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
placeholder="Form key (e.g. contact, commission)"
|
placeholder="Form key (e.g. contact, commission)"
|
||||||
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
<input
|
||||||
|
value={block.title ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { title: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Form title"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
<textarea
|
||||||
|
rows={2}
|
||||||
|
value={block.description ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { description: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Form description"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
{block.type === "price_cards" ? (
|
{block.type === "price_cards" ? (
|
||||||
|
<div className="space-y-2">
|
||||||
|
<input
|
||||||
|
value={block.title ?? ""}
|
||||||
|
onChange={(event) =>
|
||||||
|
setBlocks((prev) =>
|
||||||
|
updateBlock(prev, block.id, { title: event.target.value || null }),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
placeholder="Price card section title"
|
||||||
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
|
/>
|
||||||
<textarea
|
<textarea
|
||||||
rows={4}
|
rows={4}
|
||||||
value={block.cards
|
value={block.cards
|
||||||
@@ -283,6 +400,7 @@ export function PageBlockEditor({
|
|||||||
placeholder="One card per line: Name|Price|Description"
|
placeholder="One card per line: Name|Price|Description"
|
||||||
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
className="w-full rounded border border-neutral-300 px-2 py-1 text-sm"
|
||||||
/>
|
/>
|
||||||
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
</article>
|
</article>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -12,6 +12,16 @@ type PublicPageViewProps = {
|
|||||||
page: PageEntity
|
page: PageEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveFormLink(formKey: string): { href: string; label: string } {
|
||||||
|
const normalized = formKey.trim().toLowerCase()
|
||||||
|
|
||||||
|
if (normalized === "commission" || normalized === "commissions") {
|
||||||
|
return { href: "/commissions", label: "Open commission form" }
|
||||||
|
}
|
||||||
|
|
||||||
|
return { href: `/#form-${normalized || "contact"}`, label: "Open contact form" }
|
||||||
|
}
|
||||||
|
|
||||||
export function PublicPageView({ page }: PublicPageViewProps) {
|
export function PublicPageView({ page }: PublicPageViewProps) {
|
||||||
const blocks = (() => {
|
const blocks = (() => {
|
||||||
try {
|
try {
|
||||||
@@ -106,6 +116,7 @@ export function PublicPageView({ page }: PublicPageViewProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (block.type === "form") {
|
if (block.type === "form") {
|
||||||
|
const formLink = resolveFormLink(block.formKey)
|
||||||
return (
|
return (
|
||||||
<section key={block.id} className="space-y-2 rounded border border-neutral-200 p-4">
|
<section key={block.id} className="space-y-2 rounded border border-neutral-200 p-4">
|
||||||
<h3 className="text-lg font-medium">{block.title || "Form block"}</h3>
|
<h3 className="text-lg font-medium">{block.title || "Form block"}</h3>
|
||||||
@@ -113,6 +124,12 @@ export function PublicPageView({ page }: PublicPageViewProps) {
|
|||||||
{block.description || "Form integration pending."}
|
{block.description || "Form integration pending."}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-xs text-neutral-500">formKey: {block.formKey}</p>
|
<p className="text-xs text-neutral-500">formKey: {block.formKey}</p>
|
||||||
|
<a
|
||||||
|
href={formLink.href}
|
||||||
|
className="inline-flex rounded border border-neutral-300 px-3 py-1.5 text-sm"
|
||||||
|
>
|
||||||
|
{formLink.label}
|
||||||
|
</a>
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user