@bigmistqke/workpad 0.0.0-stage → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +781 -2
- package/bin/workpad.ts +1509 -0
- package/dist/_virtual/_@oxc-project_runtime@0.156.0/helpers/esm/taggedTemplateLiteral.js +5 -0
- package/dist/bin/workpad.js +1190 -0
- package/dist/client/runtime.js +1194 -0
- package/dist/define.js +27 -0
- package/dist/plugins/alert/README.md +18 -0
- package/dist/plugins/alert/index.js +40 -0
- package/dist/plugins/alert/public/style.css +40 -0
- package/dist/plugins/ansi/README.md +36 -0
- package/dist/plugins/ansi/index.js +63 -0
- package/dist/plugins/ansi/public/style.css +28 -0
- package/dist/plugins/badge/README.md +32 -0
- package/dist/plugins/badge/index.js +28 -0
- package/dist/plugins/badge/public/style.css +30 -0
- package/dist/plugins/chat/README.md +81 -0
- package/dist/plugins/chat/index.js +96 -0
- package/dist/plugins/chat/public/client.js +3 -0
- package/dist/plugins/chat/public/style.css +143 -0
- package/dist/plugins/claude/README.md +116 -0
- package/dist/plugins/claude/channel.js +130 -0
- package/dist/plugins/claude/doctor.js +316 -0
- package/dist/plugins/claude/index.js +199 -0
- package/dist/plugins/claude/session.js +68 -0
- package/dist/plugins/code/README.md +54 -0
- package/dist/plugins/code/diff.js +75 -0
- package/dist/plugins/code/index.js +105 -0
- package/dist/plugins/code/public/client.js +1 -0
- package/dist/plugins/code/public/style.css +99 -0
- package/dist/plugins/comments/README.md +30 -0
- package/dist/plugins/comments/index.js +39 -0
- package/dist/plugins/comments/public/client.js +24 -0
- package/dist/plugins/comments/public/style.css +224 -0
- package/dist/plugins/details/README.md +24 -0
- package/dist/plugins/details/index.js +28 -0
- package/dist/plugins/details/public/style.css +7 -0
- package/dist/plugins/draft/README.md +14 -0
- package/dist/plugins/draft/index.js +27 -0
- package/dist/plugins/draft/public/style.css +21 -0
- package/dist/plugins/forge/README.md +22 -0
- package/dist/plugins/forge/index.js +83 -0
- package/dist/plugins/form/README.md +126 -0
- package/dist/plugins/form/index.js +179 -0
- package/dist/plugins/form/public/style.css +172 -0
- package/dist/plugins/grid/README.md +45 -0
- package/dist/plugins/grid/index.js +35 -0
- package/dist/plugins/grid/public/style.css +98 -0
- package/dist/plugins/iframe/README.md +18 -0
- package/dist/plugins/iframe/index.js +49 -0
- package/dist/plugins/iframe/public/style.css +28 -0
- package/dist/plugins/index.js +44 -0
- package/dist/plugins/lightbox/README.md +24 -0
- package/dist/plugins/lightbox/index.js +20 -0
- package/dist/plugins/lightbox/public/client.js +4 -0
- package/dist/plugins/lightbox/public/style.css +66 -0
- package/dist/plugins/mermaid/README.md +21 -0
- package/dist/plugins/mermaid/index.js +42 -0
- package/dist/plugins/mermaid/public/style.css +21 -0
- package/dist/plugins/opencode/README.md +48 -0
- package/dist/plugins/opencode/channel.js +92 -0
- package/dist/plugins/opencode/index.js +64 -0
- package/dist/plugins/opencode/shim.js +150 -0
- package/dist/plugins/quiet/README.md +26 -0
- package/dist/plugins/quiet/index.js +23 -0
- package/dist/plugins/tabs/README.md +44 -0
- package/dist/plugins/tabs/index.js +75 -0
- package/dist/plugins/tabs/public/client.js +1 -0
- package/dist/plugins/tabs/public/style.css +98 -0
- package/dist/plugins/terminal/README.md +63 -0
- package/dist/plugins/terminal/host.js +338 -0
- package/dist/plugins/terminal/index.js +170 -0
- package/dist/plugins/terminal/modes.js +32 -0
- package/dist/plugins/terminal/public/client.js +41 -0
- package/dist/plugins/terminal/public/style.css +511 -0
- package/dist/plugins/terminal/server.js +256 -0
- package/dist/plugins/terminal/sizes.js +58 -0
- package/dist/plugins/timeline/README.md +48 -0
- package/dist/plugins/timeline/index.js +83 -0
- package/dist/plugins/timeline/public/style.css +138 -0
- package/dist/plugins/toc/README.md +40 -0
- package/dist/plugins/toc/index.js +29 -0
- package/dist/plugins/toc/public/client.js +1 -0
- package/dist/plugins/toc/public/style.css +117 -0
- package/dist/plugins/window/README.md +51 -0
- package/dist/plugins/window/index.js +91 -0
- package/dist/solid/index.js +41 -0
- package/dist/src/agents.js +81 -0
- package/dist/src/anchors.js +52 -0
- package/dist/src/api.js +282 -0
- package/dist/src/archive.js +49 -0
- package/dist/src/auth.js +67 -0
- package/dist/src/build.js +159 -0
- package/dist/src/client/page/base.css +1762 -0
- package/dist/src/client/page/main.js +2098 -0
- package/dist/src/config.js +76 -0
- package/dist/src/document.js +93 -0
- package/dist/src/entries.js +264 -0
- package/dist/src/events.js +322 -0
- package/dist/src/files.js +47 -0
- package/dist/src/formstate.js +65 -0
- package/dist/src/help.js +211 -0
- package/dist/src/html.js +34 -0
- package/dist/src/hub.js +341 -0
- package/dist/src/icons.js +6 -0
- package/dist/src/listen.js +132 -0
- package/dist/src/listeners.js +64 -0
- package/dist/src/load.js +81 -0
- package/dist/src/loader.js +179 -0
- package/dist/src/migrate.js +314 -0
- package/dist/src/package.js +52 -0
- package/dist/src/pages/blocks.js +67 -0
- package/dist/src/pages/board.js +59 -0
- package/dist/src/pages/index.js +27 -0
- package/dist/src/pages/markdown.js +863 -0
- package/dist/src/pages/render.js +665 -0
- package/dist/src/pages/window.js +29 -0
- package/dist/src/plugins.js +283 -0
- package/dist/src/public.js +24 -0
- package/dist/src/rename.js +130 -0
- package/dist/src/running.js +146 -0
- package/dist/src/serve.js +188 -0
- package/dist/src/server.js +1105 -0
- package/dist/src/site.js +179 -0
- package/dist/src/state.js +155 -0
- package/dist/src/status.js +323 -0
- package/dist/src/thread.js +68 -0
- package/dist/src/watchdog.js +38 -0
- package/dist/src/ws.js +128 -0
- package/package.json +154 -4
- package/plugins/README.md +304 -0
- package/plugins/alert/README.md +18 -0
- package/plugins/alert/index.ts +50 -0
- package/plugins/alert/public/style.css +40 -0
- package/plugins/ansi/README.md +36 -0
- package/plugins/ansi/index.ts +95 -0
- package/plugins/ansi/public/style.css +28 -0
- package/plugins/badge/README.md +32 -0
- package/plugins/badge/index.ts +36 -0
- package/plugins/badge/public/style.css +30 -0
- package/plugins/chat/README.md +81 -0
- package/plugins/chat/autosize.ts +139 -0
- package/plugins/chat/client.tsx +187 -0
- package/plugins/chat/index.ts +146 -0
- package/plugins/chat/public/style.css +143 -0
- package/plugins/claude/README.md +116 -0
- package/plugins/claude/channel.ts +136 -0
- package/plugins/claude/doctor.ts +274 -0
- package/plugins/claude/index.ts +248 -0
- package/plugins/claude/session.ts +70 -0
- package/plugins/code/README.md +54 -0
- package/plugins/code/client.ts +73 -0
- package/plugins/code/diff.ts +96 -0
- package/plugins/code/index.ts +136 -0
- package/plugins/code/public/style.css +99 -0
- package/plugins/comments/README.md +30 -0
- package/plugins/comments/client.ts +723 -0
- package/plugins/comments/index.ts +48 -0
- package/plugins/comments/public/style.css +224 -0
- package/plugins/details/README.md +24 -0
- package/plugins/details/index.ts +30 -0
- package/plugins/details/public/style.css +7 -0
- package/plugins/draft/README.md +14 -0
- package/plugins/draft/index.ts +23 -0
- package/plugins/draft/public/style.css +21 -0
- package/plugins/forge/README.md +22 -0
- package/plugins/forge/index.ts +84 -0
- package/plugins/form/README.md +126 -0
- package/plugins/form/index.ts +199 -0
- package/plugins/form/public/style.css +172 -0
- package/plugins/grid/README.md +45 -0
- package/plugins/grid/index.ts +41 -0
- package/plugins/grid/public/style.css +98 -0
- package/plugins/iframe/README.md +18 -0
- package/plugins/iframe/index.ts +53 -0
- package/plugins/iframe/public/style.css +28 -0
- package/plugins/index.ts +49 -0
- package/plugins/lightbox/README.md +24 -0
- package/plugins/lightbox/client.ts +109 -0
- package/plugins/lightbox/index.ts +25 -0
- package/plugins/lightbox/public/style.css +66 -0
- package/plugins/mermaid/README.md +21 -0
- package/plugins/mermaid/index.ts +46 -0
- package/plugins/mermaid/public/style.css +21 -0
- package/plugins/opencode/README.md +48 -0
- package/plugins/opencode/channel.ts +112 -0
- package/plugins/opencode/index.ts +91 -0
- package/plugins/opencode/shim.ts +166 -0
- package/plugins/quiet/README.md +26 -0
- package/plugins/quiet/index.ts +28 -0
- package/plugins/tabs/README.md +44 -0
- package/plugins/tabs/client.ts +96 -0
- package/plugins/tabs/index.ts +103 -0
- package/plugins/tabs/public/style.css +98 -0
- package/plugins/terminal/README.md +63 -0
- package/plugins/terminal/client.ts +391 -0
- package/plugins/terminal/host.ts +434 -0
- package/plugins/terminal/index.ts +199 -0
- package/plugins/terminal/modes.ts +30 -0
- package/plugins/terminal/public/style.css +225 -0
- package/plugins/terminal/server.ts +266 -0
- package/plugins/terminal/sizes.ts +72 -0
- package/plugins/timeline/README.md +48 -0
- package/plugins/timeline/index.ts +82 -0
- package/plugins/timeline/public/style.css +138 -0
- package/plugins/toc/README.md +40 -0
- package/plugins/toc/client.ts +236 -0
- package/plugins/toc/index.ts +55 -0
- package/plugins/toc/public/style.css +117 -0
- package/plugins/window/README.md +51 -0
- package/plugins/window/index.ts +92 -0
- package/skills/workpad/SKILL.md +588 -0
- package/solid/index.tsx +80 -0
- package/src/agents.ts +133 -0
- package/src/anchors.ts +85 -0
- package/src/api.ts +444 -0
- package/src/archive.ts +75 -0
- package/src/auth.ts +99 -0
- package/src/build.ts +213 -0
- package/src/client/base.ts +19 -0
- package/src/client/forms.ts +420 -0
- package/src/client/markdown.ts +147 -0
- package/src/client/page/base.css +1762 -0
- package/src/client/page/board.ts +137 -0
- package/src/client/page/elsewhere.ts +153 -0
- package/src/client/page/fresh.ts +343 -0
- package/src/client/page/heading-link.ts +32 -0
- package/src/client/page/live.ts +134 -0
- package/src/client/page/main.ts +398 -0
- package/src/client/page/orphans.ts +64 -0
- package/src/client/page/place.ts +260 -0
- package/src/client/page/sort.ts +49 -0
- package/src/client/page/sticky.ts +58 -0
- package/src/client/page/theme.ts +36 -0
- package/src/client/page/view.ts +9 -0
- package/src/client/page/waiting.ts +278 -0
- package/src/client/page/window.ts +40 -0
- package/src/client/reactive.ts +19 -0
- package/src/client/read.ts +111 -0
- package/src/client/runtime.ts +499 -0
- package/src/client/scroll.ts +90 -0
- package/src/client/toast.ts +99 -0
- package/src/config.ts +111 -0
- package/src/define.ts +997 -0
- package/src/document.ts +191 -0
- package/src/entries.ts +352 -0
- package/src/events.ts +463 -0
- package/src/files.ts +74 -0
- package/src/formstate.ts +72 -0
- package/src/help.ts +238 -0
- package/src/html.ts +44 -0
- package/src/hub.ts +426 -0
- package/src/icons.ts +18 -0
- package/src/listen.ts +171 -0
- package/src/listeners.ts +89 -0
- package/src/load.ts +113 -0
- package/src/loader.ts +227 -0
- package/src/migrate.ts +352 -0
- package/src/package.ts +62 -0
- package/src/pages/blocks.ts +106 -0
- package/src/pages/board.ts +89 -0
- package/src/pages/index.ts +79 -0
- package/src/pages/markdown.ts +976 -0
- package/src/pages/render.ts +748 -0
- package/src/pages/window.ts +69 -0
- package/src/plugins.ts +319 -0
- package/src/public.ts +39 -0
- package/src/rename.ts +147 -0
- package/src/running.ts +171 -0
- package/src/serve.ts +221 -0
- package/src/server.ts +1385 -0
- package/src/site.ts +170 -0
- package/src/state.ts +327 -0
- package/src/status.ts +466 -0
- package/src/thread.ts +98 -0
- package/src/watchdog.ts +53 -0
- package/src/ws.ts +155 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { builtinPublic } from "../../src/package.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { definePlugin, html, raw, slugText } from "@bigmistqke/workpad";
|
|
4
|
+
// plugins/details/index.ts
|
|
5
|
+
async function render(ctx) {
|
|
6
|
+
const id = ctx.anchor("details", slugText(ctx.labelText ?? "details"), { numbered: true });
|
|
7
|
+
return html`<details class="wp-details" ${id ? html` id="${id}"` : ""} ${"open" in ctx.attrs && raw(" open")}>
|
|
8
|
+
<summary>${ctx.label ? raw(ctx.label) : "Details"}</summary>
|
|
9
|
+
<div class="wp-details-body">${raw(await ctx.toHtml(ctx.children))}</div>
|
|
10
|
+
</details>`;
|
|
11
|
+
}
|
|
12
|
+
function details() {
|
|
13
|
+
return definePlugin({
|
|
14
|
+
name: "details",
|
|
15
|
+
public: builtinPublic("details"),
|
|
16
|
+
blocks: { details: {
|
|
17
|
+
menu: {
|
|
18
|
+
group: "arrange",
|
|
19
|
+
summary: "folded shut: depth the first view doesn't need"
|
|
20
|
+
},
|
|
21
|
+
attrs: ["open"],
|
|
22
|
+
html: render,
|
|
23
|
+
style: "style.css"
|
|
24
|
+
} },
|
|
25
|
+
docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
export { details as default, render };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
What is there while a page is written, and not once it is built: a note to
|
|
2
|
+
check something, two versions of a paragraph, a question for later. It shows
|
|
3
|
+
set apart, marked as a draft; `workpad build` leaves it out (it is in the
|
|
4
|
+
build's `skip` by default). The label is optional.
|
|
5
|
+
|
|
6
|
+
```markdown
|
|
7
|
+
:::draft[Check with the API]
|
|
8
|
+
Is `listen` really the only way to get answers?
|
|
9
|
+
:::
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
:::draft[Check with the API]
|
|
13
|
+
Is `listen` really the only way to get answers?
|
|
14
|
+
:::
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { builtinPublic } from "../../src/package.js";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { definePlugin, html, raw } from "@bigmistqke/workpad";
|
|
4
|
+
// plugins/draft/index.ts
|
|
5
|
+
async function render(ctx) {
|
|
6
|
+
const label = ctx.label != null && String(ctx.label) !== "" ? ctx.label : "draft";
|
|
7
|
+
return html`<aside class="wp-draft">
|
|
8
|
+
<div class="wp-draft-label">${raw(String(label))}</div>
|
|
9
|
+
${raw(await ctx.toHtml(ctx.children))}
|
|
10
|
+
</aside>`;
|
|
11
|
+
}
|
|
12
|
+
function draft() {
|
|
13
|
+
return definePlugin({
|
|
14
|
+
name: "draft",
|
|
15
|
+
public: builtinPublic("draft"),
|
|
16
|
+
style: "style.css",
|
|
17
|
+
blocks: { draft: {
|
|
18
|
+
html: render,
|
|
19
|
+
menu: {
|
|
20
|
+
group: "mark",
|
|
21
|
+
summary: "not built yet: a proposal"
|
|
22
|
+
}
|
|
23
|
+
} },
|
|
24
|
+
docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
export { draft as default, render };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/* A draft (index.ts): set apart, plainly not final */
|
|
2
|
+
.wp-draft {
|
|
3
|
+
margin: var(--gap-block) 0;
|
|
4
|
+
padding: var(--space-md) var(--space-xl) var(--space-xl);
|
|
5
|
+
border: var(--hairline) dashed color-mix(in srgb, var(--warn) var(--tint-strong), transparent);
|
|
6
|
+
border-radius: var(--radius);
|
|
7
|
+
background: color-mix(in srgb, var(--warn) var(--tint-faint), transparent);
|
|
8
|
+
}
|
|
9
|
+
.wp-draft-label {
|
|
10
|
+
font: var(--weight-strong) var(--ui-tiny) / var(--ui-line-height) var(--sans);
|
|
11
|
+
letter-spacing: var(--caps-spacing);
|
|
12
|
+
text-transform: uppercase;
|
|
13
|
+
color: var(--warn);
|
|
14
|
+
margin-bottom: var(--space-xs);
|
|
15
|
+
}
|
|
16
|
+
.wp-draft-label > * {
|
|
17
|
+
margin: 0;
|
|
18
|
+
}
|
|
19
|
+
.wp-draft > :last-child {
|
|
20
|
+
margin-bottom: 0;
|
|
21
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Issues and pull/merge requests of the project's GitHub or GitLab repository
|
|
2
|
+
link themselves: write `#12` for issue 12 and `!34` for pull or merge request
|
|
3
|
+
34, as plain text. `owner/repo#12` and `group/project!34` point into another
|
|
4
|
+
repository on the same host. Inside code (`` `#12` ``) they stay text.
|
|
5
|
+
|
|
6
|
+
The repository is read from the project's `origin` remote, so a self-hosted
|
|
7
|
+
GitLab works too. Without such a remote (a folder that is no git checkout)
|
|
8
|
+
they stay text; the project's config can say which:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import forge from '@bigmistqke/workpad/forge'
|
|
12
|
+
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
plugins: [forge({ host: 'gitlab.com', repo: 'group/project' })],
|
|
15
|
+
})
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
`kind: 'github' | 'gitlab'` is needed only for a host whose name says neither.
|
|
19
|
+
|
|
20
|
+
```markdown
|
|
21
|
+
Fixed in !34, which closes #12 (see also bigmistqke/other#3).
|
|
22
|
+
```
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { definePlugin } from "@bigmistqke/workpad";
|
|
4
|
+
// plugins/forge/index.ts
|
|
5
|
+
/** A git remote's URL → its host and repository path: https, ssh (`git@host:path`), ssh://. */
|
|
6
|
+
function parseRemote(url) {
|
|
7
|
+
const u = url.trim();
|
|
8
|
+
const scp = /^[\w.-]+@([^:/]+):(.+?)(?:\.git)?\/?$/.exec(u);
|
|
9
|
+
if (scp) return {
|
|
10
|
+
host: scp[1],
|
|
11
|
+
repo: scp[2]
|
|
12
|
+
};
|
|
13
|
+
const full = /^(?:https?|ssh|git):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+?)(?:\.git)?\/?$/.exec(u);
|
|
14
|
+
if (full) return {
|
|
15
|
+
host: full[1],
|
|
16
|
+
repo: full[2]
|
|
17
|
+
};
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
/** GitHub or GitLab, by the host's name; null for any other. */
|
|
21
|
+
const kindOf = (host) => /(^|\.)github\./.test(host) ? "github" : /(^|\.)gitlab\./.test(host) || /^gitlab/.test(host) ? "gitlab" : null;
|
|
22
|
+
/** The links for one forge: issues (`#n`) and pull or merge requests (`!n`), here or in `owner/repo`. */
|
|
23
|
+
function forgeLinks({ kind, host, repo }) {
|
|
24
|
+
const base = (path) => `https://${host}/${path ?? repo}`;
|
|
25
|
+
const ref = (sign) => new RegExp(`(?<![\\w/.#!-])(?:([\\w.-]+(?:/[\\w.-]+)+))?${sign}(\\d+)(?![\\w-])`, "g");
|
|
26
|
+
const issue = kind === "github" ? "issues" : "-/issues";
|
|
27
|
+
const change = kind === "github" ? "pull" : "-/merge_requests";
|
|
28
|
+
const what = kind === "github" ? "pull request" : "merge request";
|
|
29
|
+
return [{
|
|
30
|
+
pattern: ref("#"),
|
|
31
|
+
href: (m) => `${base(m[1])}/${issue}/${m[2]}`,
|
|
32
|
+
title: (m) => `issue ${m[1] ?? repo}#${m[2]}`
|
|
33
|
+
}, {
|
|
34
|
+
pattern: ref("!"),
|
|
35
|
+
href: (m) => `${base(m[1])}/${change}/${m[2]}`,
|
|
36
|
+
title: (m) => `${what} ${m[1] ?? repo}!${m[2]}`
|
|
37
|
+
}];
|
|
38
|
+
}
|
|
39
|
+
/** The project's forge, from its `origin` remote; null without one it knows. */
|
|
40
|
+
function detect(dir) {
|
|
41
|
+
let url;
|
|
42
|
+
try {
|
|
43
|
+
url = execFileSync("git", [
|
|
44
|
+
"remote",
|
|
45
|
+
"get-url",
|
|
46
|
+
"origin"
|
|
47
|
+
], {
|
|
48
|
+
cwd: dir,
|
|
49
|
+
encoding: "utf8",
|
|
50
|
+
stdio: [
|
|
51
|
+
"ignore",
|
|
52
|
+
"pipe",
|
|
53
|
+
"ignore"
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
} catch {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
const remote = parseRemote(url);
|
|
60
|
+
const kind = remote && kindOf(remote.host);
|
|
61
|
+
return remote && kind ? {
|
|
62
|
+
kind,
|
|
63
|
+
...remote
|
|
64
|
+
} : null;
|
|
65
|
+
}
|
|
66
|
+
function forge(options = {}) {
|
|
67
|
+
return definePlugin({
|
|
68
|
+
name: "forge",
|
|
69
|
+
links({ dir }) {
|
|
70
|
+
const found = detect(dir);
|
|
71
|
+
const host = options.host ?? found?.host;
|
|
72
|
+
const repo = options.repo ?? found?.repo;
|
|
73
|
+
const kind = options.kind ?? (options.host ? kindOf(options.host) : null) ?? found?.kind;
|
|
74
|
+
return host && repo && kind ? forgeLinks({
|
|
75
|
+
kind,
|
|
76
|
+
host,
|
|
77
|
+
repo
|
|
78
|
+
}) : [];
|
|
79
|
+
},
|
|
80
|
+
docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export { forge as default, detect, forgeLinks, kindOf, parseRemote };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
A named form, written as markdown. Submitting it appends
|
|
2
|
+
`{ id, ts, page, type, action, data }` to the events log, where `type` is the
|
|
3
|
+
form's `name`, `action` is the button that was pressed and `data` holds the
|
|
4
|
+
inputs. The form starts from its last answer. A link to it is `#form:<name>`; a
|
|
5
|
+
second form with the same name on a page gets no link and says so. A name has
|
|
6
|
+
no `:` (those are event types') and no `/` (those are forms in a chat message,
|
|
7
|
+
`<chat>/<name>`: see the chat plugin).
|
|
8
|
+
|
|
9
|
+
The body of `:::form{name=…}` is ordinary markdown, and inputs are inline
|
|
10
|
+
directives that can sit anywhere in it: in a paragraph, a list, a table
|
|
11
|
+
cell, a heading, a grid card. So a question sits with everything that
|
|
12
|
+
explains it.
|
|
13
|
+
|
|
14
|
+
| input | written as | sends |
|
|
15
|
+
| --- | --- | --- |
|
|
16
|
+
| one choice | `:radio[This week]{name=when}` per option | the picked label's text, or `null` |
|
|
17
|
+
| an answer not on the list | `:radio[Other]{name=when other}` (or `:checkbox[…]{… other}`) | what the reader typed in its box |
|
|
18
|
+
| several choices | `:checkbox[Android]{name=phones}` per option | an array of the checked labels |
|
|
19
|
+
| one checkbox | `:checkbox[I read it]{name=read}` | `true` or `false` |
|
|
20
|
+
| text | `:text[Title]{name=title placeholder="a short name"}` | the text |
|
|
21
|
+
| more text | `:textarea[Notes]{name=notes}` | the text |
|
|
22
|
+
| number, date, range | `:number[Count]{name=count min=0 max=10}`, `:date[Due]{name=due}`, `:range[…]{name=… min=0 max=100}` | the value |
|
|
23
|
+
| dropdown | `:select[Target]{name=env options="staging, production"}` | the picked option |
|
|
24
|
+
| fixed value | `:hidden{name=version value=2.3}` | the value |
|
|
25
|
+
| buttons | `:button[Approve]` `:button[Hold]` | which one is `action` |
|
|
26
|
+
|
|
27
|
+
- The label in `[…]` is markdown. An option sends its label as plain text
|
|
28
|
+
(`:radio[This **week**]` sends `This week`), unless `value=…` says what
|
|
29
|
+
to send instead.
|
|
30
|
+
- `other` makes an option for an answer not on the list: it has a text box,
|
|
31
|
+
typing in it picks the option, and it sends what was typed (`placeholder`
|
|
32
|
+
says what goes in the box). Prefer it to a separate free-text field.
|
|
33
|
+
- `recommended` tags an option as the writer's recommendation; it is never
|
|
34
|
+
preselected, so a choice is only made by picking it. `checked` does
|
|
35
|
+
preselect one; use it for defaults, not for decisions.
|
|
36
|
+
- Without a `:button`, the form gets one `Send` button. The first button is
|
|
37
|
+
the primary one.
|
|
38
|
+
- `value=…` on `:text`, `:textarea`, `:select` and the others sets what
|
|
39
|
+
they start with.
|
|
40
|
+
|
|
41
|
+
**Options with what they mean.** When the options of a decision need
|
|
42
|
+
explaining, put each one at the start of a list item, with its explanation
|
|
43
|
+
under it. Such an item reads as a row to pick:
|
|
44
|
+
|
|
45
|
+
````markdown
|
|
46
|
+
:::form{name=storage}
|
|
47
|
+
**Where are answers kept?**
|
|
48
|
+
|
|
49
|
+
- :radio[One log per project]{name=where recommended}
|
|
50
|
+
Simple, and the agent waits on one file.
|
|
51
|
+
- :radio[One log per page]{name=where}
|
|
52
|
+
Pages can be moved with their answers.
|
|
53
|
+
- :radio[Somewhere else]{name=where other placeholder="where?"}
|
|
54
|
+
:::
|
|
55
|
+
````
|
|
56
|
+
|
|
57
|
+
:::form{name=storage}
|
|
58
|
+
**Where are answers kept?**
|
|
59
|
+
|
|
60
|
+
- :radio[One log per project]{name=where recommended}
|
|
61
|
+
Simple, and the agent waits on one file.
|
|
62
|
+
- :radio[One log per page]{name=where}
|
|
63
|
+
Pages can be moved with their answers.
|
|
64
|
+
- :radio[Somewhere else]{name=where other placeholder="where?"}
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
An option's explanation can be any markdown: a code block, a table, a
|
|
68
|
+
picture, a `:::details` block. Indent it under the item, and mind the
|
|
69
|
+
colons: a container inside the form needs fewer colons than the form, so
|
|
70
|
+
write the form as `::::form` around a `:::details`.
|
|
71
|
+
|
|
72
|
+
**Inputs anywhere.** Since an input is a word-sized element, any layout
|
|
73
|
+
can hold one: a card per option in a grid, a checkbox per row of a table.
|
|
74
|
+
|
|
75
|
+
`````markdown
|
|
76
|
+
:::::form{name=deploy-review}
|
|
77
|
+
Ship **v2.3** to production?
|
|
78
|
+
|
|
79
|
+
::::grid{cols=2}
|
|
80
|
+
:::item[:radio[Staging]{name=env}]
|
|
81
|
+
Runs the migration on a copy first.
|
|
82
|
+
:::
|
|
83
|
+
|
|
84
|
+
:::item[:radio[Production]{name=env recommended}]
|
|
85
|
+
The migration is reversible.
|
|
86
|
+
:::
|
|
87
|
+
::::
|
|
88
|
+
|
|
89
|
+
:button[Approve] :button[Hold]
|
|
90
|
+
:::::
|
|
91
|
+
`````
|
|
92
|
+
|
|
93
|
+
:::::form{name=deploy-review}
|
|
94
|
+
Ship **v2.3** to production?
|
|
95
|
+
|
|
96
|
+
::::grid{cols=2}
|
|
97
|
+
:::item[:radio[Staging]{name=env}]
|
|
98
|
+
Runs the migration on a copy first.
|
|
99
|
+
:::
|
|
100
|
+
|
|
101
|
+
:::item[:radio[Production]{name=env recommended}]
|
|
102
|
+
The migration is reversible.
|
|
103
|
+
:::
|
|
104
|
+
::::
|
|
105
|
+
|
|
106
|
+
:button[Approve] :button[Hold]
|
|
107
|
+
:::::
|
|
108
|
+
|
|
109
|
+
**A form as a card.** A form's label is its title, `:::form[Title]{name=…}`.
|
|
110
|
+
Directly in a grid, tabs or a timeline, a form is an item as it is, the
|
|
111
|
+
label its title: in a grid the form is the card, not a card around a form.
|
|
112
|
+
|
|
113
|
+
Forms don't nest, and inputs belong inside a form: outside one they show
|
|
114
|
+
but send nothing.
|
|
115
|
+
|
|
116
|
+
**A chat under every form.** The reader can ask about a question without
|
|
117
|
+
answering it: under every form is a chat (see the chat plugin), named
|
|
118
|
+
after the form, whose messages are never a submit, so talking about a choice
|
|
119
|
+
never makes it. Answer there with `workpad append --type chat:message
|
|
120
|
+
--data '{"chat":"<form name>","text":"…"}'`, and don't add a free-text field
|
|
121
|
+
for questions to a decision form. A form that asks nothing to talk about (a
|
|
122
|
+
lone button that starts something) can leave its chat out:
|
|
123
|
+
`:::form{name=start chat=false}`.
|
|
124
|
+
|
|
125
|
+
A hand-written `<form name="…">` (no `action` attribute) is recorded the same
|
|
126
|
+
way; this block only saves typing.
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { chatThread } from "../chat/index.js";
|
|
2
|
+
import { isQuestionName } from "../../src/status.js";
|
|
3
|
+
import { builtinPublic } from "../../src/package.js";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import { anchorTaken, definePlugin, html, raw } from "@bigmistqke/workpad";
|
|
6
|
+
// plugins/form/index.ts
|
|
7
|
+
const style = "style.css";
|
|
8
|
+
const CHOICES = /* @__PURE__ */ new Set([
|
|
9
|
+
"radio",
|
|
10
|
+
"checkbox",
|
|
11
|
+
"select",
|
|
12
|
+
"hidden"
|
|
13
|
+
]);
|
|
14
|
+
/** The inputs written inside a form's markdown (forms inside it excluded: forms don't nest). */
|
|
15
|
+
function inputsOf(nodes) {
|
|
16
|
+
const found = [];
|
|
17
|
+
const walk = (node) => {
|
|
18
|
+
if ((node.type === "textDirective" || node.type === "leafDirective") && node.name) found.push({
|
|
19
|
+
name: node.name,
|
|
20
|
+
attrs: node.attributes ?? {}
|
|
21
|
+
});
|
|
22
|
+
if (node.type === "containerDirective" && node.name === "form") return;
|
|
23
|
+
for (const child of node.children ?? []) walk(child);
|
|
24
|
+
};
|
|
25
|
+
nodes.forEach(walk);
|
|
26
|
+
return found;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Marks the list items that start with an option and say more under it (`data-wp-explained`): rows
|
|
30
|
+
* to pick with an explanation are spaced apart, plain ones sit close. The explanation is text in the
|
|
31
|
+
* item, which a stylesheet can't tell from nothing, so the markdown is looked at instead.
|
|
32
|
+
*/
|
|
33
|
+
function markExplained(nodes) {
|
|
34
|
+
const walk = (node) => {
|
|
35
|
+
if (node.type === "containerDirective" && node.name === "form") return;
|
|
36
|
+
if (node.type === "listItem") {
|
|
37
|
+
const [first, ...rest] = node.children ?? [];
|
|
38
|
+
const lead = first?.type === "paragraph" ? first.children ?? [] : [];
|
|
39
|
+
const option = lead[0]?.type === "textDirective" && (lead[0].name === "radio" || lead[0].name === "checkbox");
|
|
40
|
+
const more = rest.length > 0 || lead.slice(1).some((n) => n.type !== "text" || !!n.value?.trim());
|
|
41
|
+
if (option && more) node.data = {
|
|
42
|
+
...node.data,
|
|
43
|
+
hProperties: {
|
|
44
|
+
...node.data?.hProperties,
|
|
45
|
+
dataWpExplained: ""
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
for (const child of node.children ?? []) walk(child);
|
|
50
|
+
};
|
|
51
|
+
nodes.forEach(walk);
|
|
52
|
+
}
|
|
53
|
+
const recommendedTag = html`<span class="wp-form-recommended">recommended</span>`;
|
|
54
|
+
const form = {
|
|
55
|
+
style,
|
|
56
|
+
async html(ctx) {
|
|
57
|
+
const c = ctx;
|
|
58
|
+
const written = c.attrs.name || c.attrs.id || "";
|
|
59
|
+
if (written && !isQuestionName(written)) throw new Error(`form name "${written}" has a colon: those names are reserved for events of workpad and plugins`);
|
|
60
|
+
if (written.includes("/")) throw new Error(`form name "${written}" has a slash: those names are a chat message's forms, \`<chat>/<name>\``);
|
|
61
|
+
const name = c.chat ? `${c.chat.name}/${written || c.chat.next()}` : written || "form";
|
|
62
|
+
const inputs = inputsOf(c.children);
|
|
63
|
+
markExplained(c.children);
|
|
64
|
+
const choices = [...new Set(inputs.filter((i) => CHOICES.has(i.name) && i.attrs.name).map((i) => i.attrs.name))];
|
|
65
|
+
const hasButton = inputs.some((i) => i.name === "button");
|
|
66
|
+
const body = (await c.toHtml(c.children)).replace("<button name=\"action\"", "<button class=\"wp-primary\" name=\"action\"");
|
|
67
|
+
const id = c.anchor("form", name);
|
|
68
|
+
const thread = c.chat || c.attrs.chat === "false" ? "" : await chatThread(c, name, {
|
|
69
|
+
choices,
|
|
70
|
+
anchor: c.anchor("chat", name)
|
|
71
|
+
});
|
|
72
|
+
const title = c.label && html`<div class="wp-form-title" data-wp-title>${raw(c.label)}</div>`;
|
|
73
|
+
return html`${!id ? anchorTaken("form", name) : ""}
|
|
74
|
+
<form name="${name}" class="wp-form" ${id ? html` id="${id}"` : ""}>
|
|
75
|
+
${title}${raw(body)}${!hasButton && html`<p><button class="wp-primary">Send</button></p>`}${raw(thread)}
|
|
76
|
+
</form>`;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
/** The label of an inline input as HTML, else its fallback. */
|
|
80
|
+
const labelOf = (c, fallback = "") => c.label ? raw(c.label) : fallback;
|
|
81
|
+
/**
|
|
82
|
+
* :radio[label]{name=… value=… recommended checked} and :checkbox[…]{…}. With `other`, an answer not on
|
|
83
|
+
* the list: the option has a text box, typing in it picks the option, and it sends what was typed
|
|
84
|
+
* (the core's forms.ts, `data-wp-other`).
|
|
85
|
+
*/
|
|
86
|
+
const option = (type) => (ctx) => {
|
|
87
|
+
const c = ctx;
|
|
88
|
+
if ("other" in c.attrs) {
|
|
89
|
+
const placeholder = c.attrs.placeholder ?? "something else";
|
|
90
|
+
return html`<label class="wp-form-option wp-form-other"
|
|
91
|
+
><input type="${type}" name="${c.attrs.name}" value="" data-wp-other /><span class="wp-form-option-label"
|
|
92
|
+
>${labelOf(c, "Other")}</span
|
|
93
|
+
><input
|
|
94
|
+
type="text"
|
|
95
|
+
class="wp-form-other-text"
|
|
96
|
+
data-wp-other-text
|
|
97
|
+
placeholder="${placeholder}"
|
|
98
|
+
aria-label="${c.labelText ?? "Other"}"
|
|
99
|
+
/></label>`;
|
|
100
|
+
}
|
|
101
|
+
const value = c.attrs.value ?? c.labelText ?? "";
|
|
102
|
+
return html`<label class="wp-form-option"
|
|
103
|
+
><input type="${type}" name="${c.attrs.name}" value="${value}" ${"checked" in c.attrs && raw(" checked")} /><span
|
|
104
|
+
class="wp-form-option-label"
|
|
105
|
+
>${labelOf(c, value)}</span
|
|
106
|
+
>${"recommended" in c.attrs && recommendedTag}</label
|
|
107
|
+
>`;
|
|
108
|
+
};
|
|
109
|
+
/** :text[label]{name=… placeholder=…}, and number, date, range */
|
|
110
|
+
const field = (type) => (ctx) => {
|
|
111
|
+
const c = ctx;
|
|
112
|
+
const extra = [
|
|
113
|
+
"placeholder",
|
|
114
|
+
"min",
|
|
115
|
+
"max",
|
|
116
|
+
"step",
|
|
117
|
+
"value"
|
|
118
|
+
].filter((k) => k in c.attrs).map((k) => html` ${raw(k)}="${c.attrs[k]}"`);
|
|
119
|
+
return html`<label class="wp-form-field"
|
|
120
|
+
><span class="wp-form-label">${labelOf(c)}</span><input type="${type}" name="${c.attrs.name}" ${extra}
|
|
121
|
+
/></label>`;
|
|
122
|
+
};
|
|
123
|
+
const input = (name, render) => [name, {
|
|
124
|
+
html: render,
|
|
125
|
+
style
|
|
126
|
+
}];
|
|
127
|
+
const inputs = [
|
|
128
|
+
input("radio", option("radio")),
|
|
129
|
+
input("checkbox", option("checkbox")),
|
|
130
|
+
input("text", field("text")),
|
|
131
|
+
input("number", field("number")),
|
|
132
|
+
input("date", field("date")),
|
|
133
|
+
input("range", field("range")),
|
|
134
|
+
input("textarea", (ctx) => {
|
|
135
|
+
const c = ctx;
|
|
136
|
+
return html`<label class="wp-form-field"
|
|
137
|
+
><span class="wp-form-label">${labelOf(c)}</span
|
|
138
|
+
><textarea name="${c.attrs.name}" rows="3" placeholder="${c.attrs.placeholder ?? ""}">
|
|
139
|
+
${c.attrs.value ?? ""}</textarea>
|
|
140
|
+
</label>`;
|
|
141
|
+
}),
|
|
142
|
+
input("select", (ctx) => {
|
|
143
|
+
const c = ctx;
|
|
144
|
+
const options = (c.attrs.options ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
145
|
+
return html`<label class="wp-form-field"
|
|
146
|
+
><span class="wp-form-label">${labelOf(c)}</span
|
|
147
|
+
><select name="${c.attrs.name}">
|
|
148
|
+
${options.map((o) => html`<option${o === c.attrs.value && raw(" selected")}>${o}</option>`)}
|
|
149
|
+
</select></label
|
|
150
|
+
>`;
|
|
151
|
+
}),
|
|
152
|
+
input("hidden", (ctx) => {
|
|
153
|
+
const c = ctx;
|
|
154
|
+
return html`<input type="hidden" name="${c.attrs.name}" value="${c.attrs.value ?? ""}" />`;
|
|
155
|
+
}),
|
|
156
|
+
input("button", (ctx) => {
|
|
157
|
+
const c = ctx;
|
|
158
|
+
const value = c.labelText ?? "Send";
|
|
159
|
+
return html`<button name="action" value="${value}">${labelOf(c, "Send")}</button>`;
|
|
160
|
+
})
|
|
161
|
+
];
|
|
162
|
+
function formPlugin() {
|
|
163
|
+
return definePlugin({
|
|
164
|
+
name: "form",
|
|
165
|
+
public: builtinPublic("form"),
|
|
166
|
+
blocks: {
|
|
167
|
+
form: {
|
|
168
|
+
...form,
|
|
169
|
+
menu: {
|
|
170
|
+
group: "ask",
|
|
171
|
+
summary: "questions: radios, checkboxes, text, buttons; one form per decision"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
...Object.fromEntries(inputs)
|
|
175
|
+
},
|
|
176
|
+
docs: () => fs.readFileSync(new URL("./README.md", import.meta.url), "utf8")
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
export { formPlugin as default };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/* a form reads as a set-off part of the article: hairline rules above and below, no box */
|
|
2
|
+
.wp-form {
|
|
3
|
+
/* a block; ringed (open, waiting, sending, failed), plus the ring's distance (base.css) */
|
|
4
|
+
margin: var(--gap-block) 0;
|
|
5
|
+
padding: 1.6em 0 1.7em;
|
|
6
|
+
border-top: var(--hairline) solid var(--border);
|
|
7
|
+
border-bottom: var(--hairline) solid var(--border);
|
|
8
|
+
display: grid;
|
|
9
|
+
/* one column, as wide as the form: wide content (a code block) scrolls inside it, not past it */
|
|
10
|
+
grid-template-columns: minmax(0, 1fr);
|
|
11
|
+
gap: var(--space-2xl);
|
|
12
|
+
/* taller than its content (a card a grid's row stretches): the content packs at the top, the
|
|
13
|
+
room is left below it, instead of spread between its parts */
|
|
14
|
+
align-content: start;
|
|
15
|
+
}
|
|
16
|
+
.wp-form-pending {
|
|
17
|
+
min-height: 72px;
|
|
18
|
+
}
|
|
19
|
+
/* the form's body is markdown: its first and last blocks sit flush with the rules */
|
|
20
|
+
.wp-form > :first-child {
|
|
21
|
+
margin-top: 0;
|
|
22
|
+
}
|
|
23
|
+
.wp-form > :last-child {
|
|
24
|
+
margin-bottom: 0;
|
|
25
|
+
}
|
|
26
|
+
.wp-form > :is(p, ul, ol, table, .wp-grid, div) {
|
|
27
|
+
margin-top: 0;
|
|
28
|
+
margin-bottom: 0;
|
|
29
|
+
}
|
|
30
|
+
/* its label, `:::form[Title]`: its title, as a heading of the page's third level (base.css) */
|
|
31
|
+
.wp-form-title {
|
|
32
|
+
font-family: var(--serif);
|
|
33
|
+
font-weight: 500;
|
|
34
|
+
font-size: calc(var(--text-size) * 1.4);
|
|
35
|
+
line-height: 1.2;
|
|
36
|
+
letter-spacing: -0.01em;
|
|
37
|
+
margin: 0;
|
|
38
|
+
}
|
|
39
|
+
/* the question: a first paragraph all in bold, as the form's docs write it, reads as its title */
|
|
40
|
+
.wp-form > p:first-child:has(> strong:only-child) {
|
|
41
|
+
font-size: 1.3em;
|
|
42
|
+
line-height: 1.3;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* an inline option, :radio[…] or :checkbox[…]: the input and its label read as one */
|
|
46
|
+
.wp-form-option {
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
gap: var(--space-md);
|
|
49
|
+
align-items: baseline;
|
|
50
|
+
cursor: pointer;
|
|
51
|
+
}
|
|
52
|
+
.wp-form-option + .wp-form-option {
|
|
53
|
+
margin-left: var(--space-2xl);
|
|
54
|
+
}
|
|
55
|
+
.wp-form-option input {
|
|
56
|
+
margin: 0;
|
|
57
|
+
translate: 0 0.1em;
|
|
58
|
+
}
|
|
59
|
+
.wp-form-option-label {
|
|
60
|
+
font-weight: var(--weight-strong);
|
|
61
|
+
}
|
|
62
|
+
/* an answer not on the list: a text box in the option's line (`other`) */
|
|
63
|
+
.wp-form-other {
|
|
64
|
+
align-items: center;
|
|
65
|
+
}
|
|
66
|
+
.wp-form-other .wp-form-other-text {
|
|
67
|
+
translate: none;
|
|
68
|
+
font: inherit;
|
|
69
|
+
padding: var(--space-2xs) var(--space-md);
|
|
70
|
+
min-width: 12em;
|
|
71
|
+
border: var(--hairline) solid var(--border);
|
|
72
|
+
border-radius: var(--radius-sm);
|
|
73
|
+
background: var(--bg);
|
|
74
|
+
color: var(--text);
|
|
75
|
+
}
|
|
76
|
+
.wp-form-recommended {
|
|
77
|
+
font: 500 var(--ui-tiny)/var(--ui-line-height) var(--sans);
|
|
78
|
+
color: var(--muted);
|
|
79
|
+
letter-spacing: var(--caps-spacing);
|
|
80
|
+
text-transform: uppercase;
|
|
81
|
+
margin-left: var(--space-lg);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* a list item that starts with an option is a row to pick: no bullet, the picked one tinted, and
|
|
85
|
+
the rest of the item reads as what the option means */
|
|
86
|
+
.wp-form li:has(> p:first-child > .wp-form-option:first-child),
|
|
87
|
+
.wp-form li:has(> .wp-form-option:first-child) {
|
|
88
|
+
list-style: none;
|
|
89
|
+
margin-left: -1.2em;
|
|
90
|
+
/* --wp-hang: how far an explained row's text hangs in (below) */
|
|
91
|
+
padding: var(--space-2xs) var(--space-lg) var(--space-2xs) calc(var(--space-lg) + var(--wp-hang, 0px));
|
|
92
|
+
border-radius: var(--radius-sm);
|
|
93
|
+
}
|
|
94
|
+
/* rows to pick sit close: their padding (the room for the tint) is the space between them */
|
|
95
|
+
.wp-form :where(li:has(> p:first-child > .wp-form-option:first-child)) + li,
|
|
96
|
+
.wp-form :where(li:has(> .wp-form-option:first-child)) + li {
|
|
97
|
+
margin-top: 0;
|
|
98
|
+
}
|
|
99
|
+
/* a row with an explanation under its option (marked by the form block) stands apart from the
|
|
100
|
+
next, and what it says hangs under the option's label, past the radio or checkbox, so the
|
|
101
|
+
option and its explanation read as one */
|
|
102
|
+
.wp-form li[data-wp-explained] + li,
|
|
103
|
+
.wp-form li + li[data-wp-explained] {
|
|
104
|
+
/* as far as a heading is from what it heads: each option is a small section of its own */
|
|
105
|
+
margin-top: var(--gap-heading);
|
|
106
|
+
}
|
|
107
|
+
.wp-form li[data-wp-explained] {
|
|
108
|
+
--wp-hang: calc(12px + var(--space-md));
|
|
109
|
+
}
|
|
110
|
+
.wp-form li[data-wp-explained] > .wp-form-option:first-child,
|
|
111
|
+
.wp-form li[data-wp-explained] > p:first-child > .wp-form-option:first-child {
|
|
112
|
+
margin-left: calc(0px - var(--wp-hang));
|
|
113
|
+
margin-bottom: var(--gap-attach);
|
|
114
|
+
}
|
|
115
|
+
.wp-form li:has(> p:first-child > .wp-form-option:first-child):hover,
|
|
116
|
+
.wp-form li:has(> .wp-form-option:first-child):hover {
|
|
117
|
+
background: var(--tint);
|
|
118
|
+
}
|
|
119
|
+
.wp-form li:has(> p:first-child > .wp-form-option:first-child input:checked),
|
|
120
|
+
.wp-form li:has(> .wp-form-option:first-child input:checked) {
|
|
121
|
+
background: color-mix(in srgb, var(--accent) var(--tint-faint), transparent);
|
|
122
|
+
}
|
|
123
|
+
.wp-form li > p:first-child {
|
|
124
|
+
margin-bottom: 0.2em;
|
|
125
|
+
}
|
|
126
|
+
.wp-form li > p:first-child > .wp-form-option:first-child,
|
|
127
|
+
.wp-form li > .wp-form-option:first-child {
|
|
128
|
+
display: flex;
|
|
129
|
+
margin-bottom: 0.15em;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* fields: the label above the input */
|
|
133
|
+
.wp-form-field {
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-direction: column;
|
|
136
|
+
gap: var(--space-xs);
|
|
137
|
+
margin: 0;
|
|
138
|
+
min-width: 0;
|
|
139
|
+
}
|
|
140
|
+
.wp-form-field :is(input:not([type='range']), textarea, select) {
|
|
141
|
+
width: 100%;
|
|
142
|
+
}
|
|
143
|
+
.wp-form-field textarea {
|
|
144
|
+
resize: vertical;
|
|
145
|
+
}
|
|
146
|
+
/* a field's label reads like an option's: the text's face and size, in bold */
|
|
147
|
+
.wp-form-label {
|
|
148
|
+
font-weight: var(--weight-strong);
|
|
149
|
+
line-height: var(--ui-line-height);
|
|
150
|
+
}
|
|
151
|
+
/* fields one after another (on lines of one paragraph): apart, each label with its own input */
|
|
152
|
+
.wp-form-field + .wp-form-field {
|
|
153
|
+
margin-top: var(--gap-prose);
|
|
154
|
+
}
|
|
155
|
+
.wp-form-label:empty {
|
|
156
|
+
display: none;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/* buttons: the first one of a form is its primary one */
|
|
160
|
+
.wp-form button[name='action'] + button[name='action'] {
|
|
161
|
+
margin-left: var(--space-md);
|
|
162
|
+
}
|
|
163
|
+
.wp-form button.wp-primary {
|
|
164
|
+
background: var(--accent);
|
|
165
|
+
color: var(--accent-text);
|
|
166
|
+
border-color: var(--accent);
|
|
167
|
+
}
|
|
168
|
+
.wp-card .wp-form {
|
|
169
|
+
padding: 0;
|
|
170
|
+
border: 0;
|
|
171
|
+
margin: 0.6em 0 0;
|
|
172
|
+
}
|