add admin UX quick wins: nav guard, block descriptions, input labels
All checks were successful
deploy / deploy (push) Successful in 1m16s
All checks were successful
deploy / deploy (push) Successful in 1m16s
- rename "Providers" to "Print providers" in sidebar (#110) - add LiveView navigation guard to EditorKeyboard hook — intercepts link clicks in capture phase when editor has unsaved changes (#103) - add description field to all 26 block types, shown as subtitle in block picker; filter searches descriptions too (#104) - add visible column headers (Label / Path) and proper sr-only labels with for attributes on nav editor inputs (#106) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
f4bf9c13e6
commit
32cd642110
@ -1465,7 +1465,7 @@
|
|||||||
|
|
||||||
@media (min-width: 40em) {
|
@media (min-width: 40em) {
|
||||||
border-radius: 0.75rem;
|
border-radius: 0.75rem;
|
||||||
max-width: 28rem;
|
max-width: 36rem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1493,9 +1493,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.block-picker-item {
|
.block-picker-item {
|
||||||
display: flex;
|
display: grid;
|
||||||
align-items: center;
|
grid-template-columns: 1.25rem 1fr;
|
||||||
gap: 0.5rem;
|
gap: 0.25rem 0.5rem;
|
||||||
|
align-items: start;
|
||||||
padding: 0.625rem 0.75rem;
|
padding: 0.625rem 0.75rem;
|
||||||
border: 1px solid var(--t-border-default);
|
border: 1px solid var(--t-border-default);
|
||||||
border-radius: 0.375rem;
|
border-radius: 0.375rem;
|
||||||
@ -1513,6 +1514,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.block-picker-item > .size-5 {
|
||||||
|
grid-row: 1 / -1;
|
||||||
|
margin-top: 0.0625rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-picker-item-desc {
|
||||||
|
grid-column: 2;
|
||||||
|
font-size: 0.6875rem;
|
||||||
|
line-height: 1.3;
|
||||||
|
color: color-mix(in oklch, var(--t-text-primary) 55%, transparent);
|
||||||
|
}
|
||||||
|
|
||||||
.block-picker-empty {
|
.block-picker-empty {
|
||||||
grid-column: 1 / -1;
|
grid-column: 1 / -1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@ -2280,6 +2293,20 @@
|
|||||||
|
|
||||||
/* Navigation editor */
|
/* Navigation editor */
|
||||||
|
|
||||||
|
.nav-editor-labels {
|
||||||
|
display: flex;
|
||||||
|
gap: 0.5rem;
|
||||||
|
padding: 0 0.5rem;
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 500;
|
||||||
|
color: color-mix(in oklch, var(--t-text-primary) 55%, transparent);
|
||||||
|
|
||||||
|
& span {
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.nav-editor-item {
|
.nav-editor-item {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|||||||
@ -662,6 +662,24 @@ const EditorKeyboard = {
|
|||||||
}
|
}
|
||||||
window.addEventListener("beforeunload", this._beforeUnload)
|
window.addEventListener("beforeunload", this._beforeUnload)
|
||||||
|
|
||||||
|
// Intercept LiveView navigation clicks when editor has unsaved changes.
|
||||||
|
// Uses capture phase to fire before LiveView's own click handler.
|
||||||
|
this._clickGuard = (e) => {
|
||||||
|
if (this.el.dataset.dirty !== "true") return
|
||||||
|
|
||||||
|
const link = e.target.closest("a[data-phx-link]")
|
||||||
|
if (!link) return
|
||||||
|
|
||||||
|
// Don't block clicks inside the editor itself (e.g. block controls)
|
||||||
|
if (this.el.contains(link)) return
|
||||||
|
|
||||||
|
if (!window.confirm("You have unsaved changes that will be lost. Leave anyway?")) {
|
||||||
|
e.preventDefault()
|
||||||
|
e.stopImmediatePropagation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.addEventListener("click", this._clickGuard, true)
|
||||||
|
|
||||||
const prefix = this.el.dataset.eventPrefix || ""
|
const prefix = this.el.dataset.eventPrefix || ""
|
||||||
this._keydown = (e) => {
|
this._keydown = (e) => {
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key === "z") {
|
if ((e.ctrlKey || e.metaKey) && e.key === "z") {
|
||||||
@ -678,6 +696,7 @@ const EditorKeyboard = {
|
|||||||
|
|
||||||
destroyed() {
|
destroyed() {
|
||||||
window.removeEventListener("beforeunload", this._beforeUnload)
|
window.removeEventListener("beforeunload", this._beforeUnload)
|
||||||
|
document.removeEventListener("click", this._clickGuard, true)
|
||||||
document.removeEventListener("keydown", this._keydown)
|
document.removeEventListener("keydown", this._keydown)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,6 +16,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"hero" => %{
|
"hero" => %{
|
||||||
name: "Hero banner",
|
name: "Hero banner",
|
||||||
|
description: "Full-width banner with title, description and call-to-action buttons",
|
||||||
icon: "hero-megaphone",
|
icon: "hero-megaphone",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -46,6 +47,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"featured_products" => %{
|
"featured_products" => %{
|
||||||
name: "Featured products",
|
name: "Featured products",
|
||||||
|
description: "Grid of product cards — choose how many and which style",
|
||||||
icon: "hero-star",
|
icon: "hero-star",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -87,6 +89,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"image_text" => %{
|
"image_text" => %{
|
||||||
name: "Image + text",
|
name: "Image + text",
|
||||||
|
description: "Side-by-side image and text with optional link",
|
||||||
icon: "hero-photo",
|
icon: "hero-photo",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -100,24 +103,28 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"category_nav" => %{
|
"category_nav" => %{
|
||||||
name: "Category navigation",
|
name: "Category navigation",
|
||||||
|
description: "Clickable category pills linking to filtered product collections",
|
||||||
icon: "hero-squares-2x2",
|
icon: "hero-squares-2x2",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"newsletter_card" => %{
|
"newsletter_card" => %{
|
||||||
name: "Newsletter signup",
|
name: "Newsletter signup",
|
||||||
|
description: "Email signup form for collecting subscriber addresses",
|
||||||
icon: "hero-envelope",
|
icon: "hero-envelope",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"social_links_card" => %{
|
"social_links_card" => %{
|
||||||
name: "Social links",
|
name: "Social links",
|
||||||
|
description: "Icons linking to your social media profiles",
|
||||||
icon: "hero-share",
|
icon: "hero-share",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"info_card" => %{
|
"info_card" => %{
|
||||||
name: "Info card",
|
name: "Info card",
|
||||||
|
description: "Key-value list for shop details like materials, sizing or delivery info",
|
||||||
icon: "hero-information-circle",
|
icon: "hero-information-circle",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -136,12 +143,14 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"trust_badges" => %{
|
"trust_badges" => %{
|
||||||
name: "Trust badges",
|
name: "Trust badges",
|
||||||
|
description: "Icons for free shipping, secure payment and quality guarantees",
|
||||||
icon: "hero-shield-check",
|
icon: "hero-shield-check",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"reviews_section" => %{
|
"reviews_section" => %{
|
||||||
name: "Customer reviews",
|
name: "Customer reviews",
|
||||||
|
description: "Star ratings and customer testimonials",
|
||||||
icon: "hero-chat-bubble-left-right",
|
icon: "hero-chat-bubble-left-right",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [],
|
settings_schema: [],
|
||||||
@ -149,6 +158,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"spacer" => %{
|
"spacer" => %{
|
||||||
name: "Spacer",
|
name: "Spacer",
|
||||||
|
description: "Vertical breathing room between blocks",
|
||||||
icon: "hero-arrows-up-down",
|
icon: "hero-arrows-up-down",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -163,6 +173,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"divider" => %{
|
"divider" => %{
|
||||||
name: "Divider",
|
name: "Divider",
|
||||||
|
description: "Horizontal line, dots or fade to separate sections",
|
||||||
icon: "hero-minus",
|
icon: "hero-minus",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -177,6 +188,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"button" => %{
|
"button" => %{
|
||||||
name: "Button",
|
name: "Button",
|
||||||
|
description: "Standalone call-to-action button linking to any page",
|
||||||
icon: "hero-cursor-arrow-rays",
|
icon: "hero-cursor-arrow-rays",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -200,6 +212,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"video_embed" => %{
|
"video_embed" => %{
|
||||||
name: "Video embed",
|
name: "Video embed",
|
||||||
|
description: "Embedded YouTube or Vimeo video with optional caption",
|
||||||
icon: "hero-play",
|
icon: "hero-play",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -219,24 +232,28 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"product_hero" => %{
|
"product_hero" => %{
|
||||||
name: "Product hero",
|
name: "Product hero",
|
||||||
|
description: "Product image gallery, title, price and add-to-cart button",
|
||||||
icon: "hero-cube",
|
icon: "hero-cube",
|
||||||
allowed_on: ["pdp"],
|
allowed_on: ["pdp"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"breadcrumb" => %{
|
"breadcrumb" => %{
|
||||||
name: "Breadcrumb",
|
name: "Breadcrumb",
|
||||||
|
description: "Navigation trail showing Home > Category > Product",
|
||||||
icon: "hero-chevron-right",
|
icon: "hero-chevron-right",
|
||||||
allowed_on: ["pdp"],
|
allowed_on: ["pdp"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"product_details" => %{
|
"product_details" => %{
|
||||||
name: "Product details",
|
name: "Product details",
|
||||||
|
description: "Full product description text",
|
||||||
icon: "hero-document-text",
|
icon: "hero-document-text",
|
||||||
allowed_on: ["pdp"],
|
allowed_on: ["pdp"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"related_products" => %{
|
"related_products" => %{
|
||||||
name: "Related products",
|
name: "Related products",
|
||||||
|
description: "Products from the same category",
|
||||||
icon: "hero-squares-plus",
|
icon: "hero-squares-plus",
|
||||||
allowed_on: ["pdp"],
|
allowed_on: ["pdp"],
|
||||||
settings_schema: [],
|
settings_schema: [],
|
||||||
@ -247,18 +264,21 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"collection_header" => %{
|
"collection_header" => %{
|
||||||
name: "Collection header",
|
name: "Collection header",
|
||||||
|
description: "Category title and product count",
|
||||||
icon: "hero-tag",
|
icon: "hero-tag",
|
||||||
allowed_on: ["collection"],
|
allowed_on: ["collection"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"filter_bar" => %{
|
"filter_bar" => %{
|
||||||
name: "Filter bar",
|
name: "Filter bar",
|
||||||
|
description: "Category filter pills and sort dropdown",
|
||||||
icon: "hero-funnel",
|
icon: "hero-funnel",
|
||||||
allowed_on: ["collection"],
|
allowed_on: ["collection"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"product_grid" => %{
|
"product_grid" => %{
|
||||||
name: "Product grid",
|
name: "Product grid",
|
||||||
|
description: "Responsive grid of all products in the collection",
|
||||||
icon: "hero-squares-2x2",
|
icon: "hero-squares-2x2",
|
||||||
allowed_on: ["collection"],
|
allowed_on: ["collection"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
@ -268,12 +288,14 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"cart_items" => %{
|
"cart_items" => %{
|
||||||
name: "Cart items",
|
name: "Cart items",
|
||||||
|
description: "List of items in the customer's cart with quantity controls",
|
||||||
icon: "hero-shopping-cart",
|
icon: "hero-shopping-cart",
|
||||||
allowed_on: ["cart"],
|
allowed_on: ["cart"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
},
|
},
|
||||||
"order_summary" => %{
|
"order_summary" => %{
|
||||||
name: "Order summary",
|
name: "Order summary",
|
||||||
|
description: "Subtotal, shipping estimate and checkout button",
|
||||||
icon: "hero-calculator",
|
icon: "hero-calculator",
|
||||||
allowed_on: ["cart"],
|
allowed_on: ["cart"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
@ -283,6 +305,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"contact_form" => %{
|
"contact_form" => %{
|
||||||
name: "Contact form",
|
name: "Contact form",
|
||||||
|
description: "Name, email and message form that sends to your inbox",
|
||||||
icon: "hero-envelope",
|
icon: "hero-envelope",
|
||||||
allowed_on: ["contact"],
|
allowed_on: ["contact"],
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -291,6 +314,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
},
|
},
|
||||||
"order_tracking_card" => %{
|
"order_tracking_card" => %{
|
||||||
name: "Order tracking",
|
name: "Order tracking",
|
||||||
|
description: "Lets customers look up their order status",
|
||||||
icon: "hero-truck",
|
icon: "hero-truck",
|
||||||
allowed_on: ["contact"],
|
allowed_on: ["contact"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
@ -300,6 +324,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"content_body" => %{
|
"content_body" => %{
|
||||||
name: "Page content",
|
name: "Page content",
|
||||||
|
description: "Rich text block with optional image — the main body of a content page",
|
||||||
icon: "hero-document-text",
|
icon: "hero-document-text",
|
||||||
allowed_on: :all,
|
allowed_on: :all,
|
||||||
settings_schema: [
|
settings_schema: [
|
||||||
@ -319,6 +344,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"checkout_result" => %{
|
"checkout_result" => %{
|
||||||
name: "Checkout result",
|
name: "Checkout result",
|
||||||
|
description: "Order confirmation message with order number",
|
||||||
icon: "hero-check-circle",
|
icon: "hero-check-circle",
|
||||||
allowed_on: ["checkout_success"],
|
allowed_on: ["checkout_success"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
@ -328,6 +354,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"order_card" => %{
|
"order_card" => %{
|
||||||
name: "Order cards",
|
name: "Order cards",
|
||||||
|
description: "List of past orders with status and totals",
|
||||||
icon: "hero-clipboard-document-list",
|
icon: "hero-clipboard-document-list",
|
||||||
allowed_on: ["orders"],
|
allowed_on: ["orders"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
@ -337,6 +364,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"order_detail_card" => %{
|
"order_detail_card" => %{
|
||||||
name: "Order detail",
|
name: "Order detail",
|
||||||
|
description: "Full order breakdown with items, shipping and payment info",
|
||||||
icon: "hero-clipboard-document",
|
icon: "hero-clipboard-document",
|
||||||
allowed_on: ["order_detail"],
|
allowed_on: ["order_detail"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
@ -346,6 +374,7 @@ defmodule Berrypod.Pages.BlockTypes do
|
|||||||
|
|
||||||
"search_results" => %{
|
"search_results" => %{
|
||||||
name: "Search results",
|
name: "Search results",
|
||||||
|
description: "Product search results grid with thumbnails and prices",
|
||||||
icon: "hero-magnifying-glass",
|
icon: "hero-magnifying-glass",
|
||||||
allowed_on: ["search"],
|
allowed_on: ["search"],
|
||||||
settings_schema: []
|
settings_schema: []
|
||||||
|
|||||||
@ -416,7 +416,8 @@ defmodule BerrypodWeb.BlockEditorComponents do
|
|||||||
filtered =
|
filtered =
|
||||||
assigns.allowed_blocks
|
assigns.allowed_blocks
|
||||||
|> Enum.filter(fn {_type, def} ->
|
|> Enum.filter(fn {_type, def} ->
|
||||||
filter == "" or String.contains?(String.downcase(def.name), filter)
|
filter == "" or String.contains?(String.downcase(def.name), filter) or
|
||||||
|
String.contains?(String.downcase(Map.get(def, :description, "")), filter)
|
||||||
end)
|
end)
|
||||||
|> Enum.sort_by(fn {_type, def} -> def.name end)
|
|> Enum.sort_by(fn {_type, def} -> def.name end)
|
||||||
|
|
||||||
@ -454,7 +455,10 @@ defmodule BerrypodWeb.BlockEditorComponents do
|
|||||||
class="block-picker-item"
|
class="block-picker-item"
|
||||||
>
|
>
|
||||||
<.icon name={def.icon} class="size-5" />
|
<.icon name={def.icon} class="size-5" />
|
||||||
<span>{def.name}</span>
|
<span class="block-picker-item-name">{def.name}</span>
|
||||||
|
<span :if={def[:description]} class="block-picker-item-desc">
|
||||||
|
{def.description}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<p :if={@filtered_blocks == []} class="block-picker-empty">
|
<p :if={@filtered_blocks == []} class="block-picker-empty">
|
||||||
|
|||||||
@ -91,7 +91,7 @@
|
|||||||
navigate={~p"/admin/providers"}
|
navigate={~p"/admin/providers"}
|
||||||
class={admin_nav_active?(@current_path, "/admin/providers")}
|
class={admin_nav_active?(@current_path, "/admin/providers")}
|
||||||
>
|
>
|
||||||
<.icon name="hero-link" class="size-5" /> Providers
|
<.icon name="hero-link" class="size-5" /> Print providers
|
||||||
</.link>
|
</.link>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@ -158,13 +158,19 @@ defmodule BerrypodWeb.Admin.Navigation do
|
|||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
|
<div :if={@items != []} class="nav-editor-labels" aria-hidden="true">
|
||||||
|
<span>Label</span>
|
||||||
|
<span>Path</span>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
:for={{item, idx} <- Enum.with_index(@items)}
|
:for={{item, idx} <- Enum.with_index(@items)}
|
||||||
class="nav-editor-item"
|
class="nav-editor-item"
|
||||||
>
|
>
|
||||||
<div class="nav-editor-fields">
|
<div class="nav-editor-fields">
|
||||||
|
<label class="sr-only" for={"nav-#{@section}-#{idx}-label"}>Label</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
id={"nav-#{@section}-#{idx}-label"}
|
||||||
value={item["label"]}
|
value={item["label"]}
|
||||||
placeholder="Label"
|
placeholder="Label"
|
||||||
phx-blur="update_item"
|
phx-blur="update_item"
|
||||||
@ -173,8 +179,10 @@ defmodule BerrypodWeb.Admin.Navigation do
|
|||||||
phx-value-field="label"
|
phx-value-field="label"
|
||||||
class="admin-input nav-editor-input"
|
class="admin-input nav-editor-input"
|
||||||
/>
|
/>
|
||||||
|
<label class="sr-only" for={"nav-#{@section}-#{idx}-href"}>Path</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
|
id={"nav-#{@section}-#{idx}-href"}
|
||||||
value={item["href"]}
|
value={item["href"]}
|
||||||
placeholder="/path"
|
placeholder="/path"
|
||||||
phx-blur="update_item"
|
phx-blur="update_item"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user