diff --git a/form/css/form.css b/form/css/form.css index 0e54238..9fda7b0 100644 --- a/form/css/form.css +++ b/form/css/form.css @@ -198,3 +198,31 @@ opacity: 0.5; cursor: not-allowed; } + +/* Standalone welcome — shown when form.html is opened directly (no server-injected #form-context). */ +.form-welcome { + max-width: 36rem; + margin: 2rem auto; + padding: 1.5rem 1.75rem; + background: var(--bg); + border: 1px solid var(--border); + border-radius: var(--radius); +} +.form-welcome h2 { + margin-bottom: 0.5rem; + font-size: 1.25rem; +} +.form-welcome h3 { + margin: 1rem 0 0.35rem; + font-size: 0.95rem; +} +.form-welcome p { margin-bottom: 0.75rem; line-height: 1.5; } +.form-welcome ol { margin: 0 0 0.75rem 1.25rem; } +.form-welcome li { margin-bottom: 0.35rem; } +.form-welcome code { + font-family: var(--font-mono); + font-size: 0.85em; + background: var(--bg-secondary); + padding: 0.05em 0.3em; + border-radius: 3px; +} diff --git a/form/js/main.js b/form/js/main.js index 809d12f..ca1fbaf 100644 --- a/form/js/main.js +++ b/form/js/main.js @@ -1,6 +1,37 @@ (function (app) { 'use strict'; + // Friendly empty-state shown when the form is opened standalone + // (file:// or otherwise without a server-injected #form-context + // payload). The form renderer is always driven by the host — + // zddc-server's form handler injects schema+ui+data; the tool has + // no client-side picker because there's nothing it could pick from + // outside that contract. + function renderStandaloneWelcome(root) { + if (!root) return; + root.innerHTML = ''; + const wrap = document.createElement('div'); + wrap.className = 'form-welcome'; + wrap.innerHTML = [ + '

ZDDC Form Renderer

', + '

This tool renders a form spec injected by zddc-server', + ' at <name>.form.html URLs. There is no schema', + ' to render here — most likely you opened the standalone HTML directly.

', + '

To use it

', + '
    ', + '
  1. Run zddc-server against an archive that contains a', + ' <name>.form.yaml spec.
  2. ', + '
  3. Visit <path>/<name>.form.html in the browser.
  4. ', + '
', + '

See ', + 'zddc.varasys.io/reference.html for the full ZDDC reference.

' + ].join(''); + root.appendChild(wrap); + + const submitBtn = document.getElementById('submit-btn'); + if (submitBtn) submitBtn.hidden = true; + } + function boot() { // When this bundle is hosted by the unified tables.html, the // mode dispatcher decides which app paints. Skip when mode is @@ -32,6 +63,12 @@ app.context.ui || {}, app.context.data ); + } else if (root) { + // No schema — server-injected context is empty. Most common + // when the standalone form.html is opened from file:// without + // a host. Show a friendly explanation instead of a blank page. + renderStandaloneWelcome(root); + return; } if (app.context.errors && app.context.errors.length) {