Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions assets/css/builder.css
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@
/* One rail's worth of room, so the rail follows the work: the palette
while adding, the inspector the moment a field is selected — otherwise
a narrow window could select a field and have nowhere to edit it. */
/* The inspector keeps its own side of the room: canvas left, editor
right, exactly where it lives at full width — only the palette yields. */
.atfb--has-selection .atfb__body {
grid-template-columns: minmax( 220px, 260px ) 1fr;
grid-template-columns: minmax( 0, 1fr ) minmax( 220px, 280px );
}

.atfb--has-selection .atfb__palette {
Expand All @@ -250,7 +252,6 @@

.atfb--has-selection .atfb__inspector {
display: block;
order: -1;
}
}

Expand All @@ -267,7 +268,7 @@
/* Even here a selected field keeps its editor: the inspector takes the
rail back and the canvas keeps the rest. */
.atfb--has-selection .atfb__body {
grid-template-columns: minmax( 200px, 240px ) 1fr;
grid-template-columns: minmax( 0, 1fr ) minmax( 200px, 240px );
}
}

Expand Down
17 changes: 14 additions & 3 deletions assets/js/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,23 @@ var allTerrainFormsBuilder = function(exports) {
});
}
function row(label, control2, hint2) {
const id = control2.id || `atf-c-${Math.random().toString(36).slice(2, 9)}`;
control2.id = id;
const target = control2.matches("input, select, textarea, button") ? control2 : control2.querySelector("input, select, textarea");
if (target) {
const id = target.id || `atf-c-${Math.random().toString(36).slice(2, 9)}`;
target.id = id;
return el("div", {
class: "atfb-row",
children: [
el("label", { class: "atfb-row__label", text: label, attrs: { for: id } }),
control2,
hint2 ? el("p", { class: "atfb-row__hint", text: hint2 }) : null
]
});
}
return el("div", {
class: "atfb-row",
children: [
el("label", { class: "atfb-row__label", text: label, attrs: { for: id } }),
el("span", { class: "atfb-row__label", text: label }),
control2,
hint2 ? el("p", { class: "atfb-row__hint", text: hint2 }) : null
]
Expand Down
2 changes: 1 addition & 1 deletion assets/js/builder.min.js

Large diffs are not rendered by default.

33 changes: 28 additions & 5 deletions src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,39 @@ export function icon( slug: string ): HTMLElement {
} );
}

/** A labelled control row for the inspector. */
/**
* A labelled control row for the inspector.
*
* A `<label for>` may only point at a form control. When the control passed in
* is a wrapper — a flex of input-plus-button, a group of tick boxes — the id
* lands on the first real control inside it, and a wrapper holding none gets a
* plain heading span instead of a label, because a label bound to a `<div>` is
* the thing DevTools rightly flags on every field selection.
*/
export function row( label: string, control: HTMLElement, hint?: string ): HTMLElement {
const id = control.id || `atf-c-${ Math.random().toString( 36 ).slice( 2, 9 ) }`;

control.id = id;
const target = control.matches( 'input, select, textarea, button' )
? control
: control.querySelector< HTMLElement >( 'input, select, textarea' );

if ( target ) {
const id = target.id || `atf-c-${ Math.random().toString( 36 ).slice( 2, 9 ) }`;

target.id = id;

return el( 'div', {
class: 'atfb-row',
children: [
el( 'label', { class: 'atfb-row__label', text: label, attrs: { for: id } } ),
control,
hint ? el( 'p', { class: 'atfb-row__hint', text: hint } ) : null,
],
} );
}

return el( 'div', {
class: 'atfb-row',
children: [
el( 'label', { class: 'atfb-row__label', text: label, attrs: { for: id } } ),
el( 'span', { class: 'atfb-row__label', text: label } ),
control,
hint ? el( 'p', { class: 'atfb-row__hint', text: hint } ) : null,
],
Expand Down
Loading