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:
@@ -1465,7 +1465,7 @@
|
||||
|
||||
@media (min-width: 40em) {
|
||||
border-radius: 0.75rem;
|
||||
max-width: 28rem;
|
||||
max-width: 36rem;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1493,9 +1493,10 @@
|
||||
}
|
||||
|
||||
.block-picker-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
display: grid;
|
||||
grid-template-columns: 1.25rem 1fr;
|
||||
gap: 0.25rem 0.5rem;
|
||||
align-items: start;
|
||||
padding: 0.625rem 0.75rem;
|
||||
border: 1px solid var(--t-border-default);
|
||||
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 {
|
||||
grid-column: 1 / -1;
|
||||
text-align: center;
|
||||
@@ -2280,6 +2293,20 @@
|
||||
|
||||
/* 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 {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
@@ -662,6 +662,24 @@ const EditorKeyboard = {
|
||||
}
|
||||
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 || ""
|
||||
this._keydown = (e) => {
|
||||
if ((e.ctrlKey || e.metaKey) && e.key === "z") {
|
||||
@@ -678,6 +696,7 @@ const EditorKeyboard = {
|
||||
|
||||
destroyed() {
|
||||
window.removeEventListener("beforeunload", this._beforeUnload)
|
||||
document.removeEventListener("click", this._clickGuard, true)
|
||||
document.removeEventListener("keydown", this._keydown)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user