@tjakoen/grain 0.1.12
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 +202 -0
- package/PLAN.md +27 -0
- package/README.md +243 -0
- package/ai/accepts.test.ts +69 -0
- package/ai/accepts.ts +57 -0
- package/ai/ai.css +127 -0
- package/ai/client-door.test.ts +70 -0
- package/ai/client-door.ts +56 -0
- package/ai/contract.test.ts +158 -0
- package/ai/contract.ts +285 -0
- package/ai/interaction-layer.test.ts +270 -0
- package/ai/interaction-layer.ts +138 -0
- package/ai/manifest-dom.test.ts +176 -0
- package/ai/manifest-dom.ts +187 -0
- package/ai/manifest.test.ts +71 -0
- package/ai/manifest.ts +57 -0
- package/ai/markdown.test.ts +68 -0
- package/ai/markdown.ts +74 -0
- package/ai/model-chat.test.ts +131 -0
- package/ai/model-chat.ts +151 -0
- package/ai/model-reasoner.test.ts +152 -0
- package/ai/model-reasoner.ts +146 -0
- package/ai/model.test.ts +148 -0
- package/ai/model.ts +200 -0
- package/ai/reasoner-kit.test.ts +142 -0
- package/ai/reasoner-kit.ts +159 -0
- package/ai/reasoner.test.ts +227 -0
- package/ai/reasoner.ts +446 -0
- package/ai/timeline-log.test.ts +55 -0
- package/ai/timeline-log.ts +50 -0
- package/ai/vocab-reference.test.ts +43 -0
- package/ai/vocab-reference.ts +107 -0
- package/ai/webllm.test.ts +79 -0
- package/ai/webllm.ts +125 -0
- package/assets/figure-sample.svg +14 -0
- package/assets/sprite.svg +22 -0
- package/catalog/catalog.test.ts +37 -0
- package/catalog/catalog.ts +424 -0
- package/components/atoms/action-badge/action-badge.css +17 -0
- package/components/atoms/action-badge/action-badge.html +6 -0
- package/components/atoms/action-badge/action-badge.md +23 -0
- package/components/atoms/b-badge/b-badge.css +15 -0
- package/components/atoms/b-badge/b-badge.html +2 -0
- package/components/atoms/b-badge/b-badge.md +16 -0
- package/components/atoms/b-button/b-button.ai.md +22 -0
- package/components/atoms/b-button/b-button.css +87 -0
- package/components/atoms/b-button/b-button.html +5 -0
- package/components/atoms/b-button/b-button.md +77 -0
- package/components/atoms/b-icon/b-icon.css +10 -0
- package/components/atoms/b-icon/b-icon.html +5 -0
- package/components/atoms/b-icon/b-icon.md +36 -0
- package/components/atoms/b-icon-button/b-icon-button.ai.md +11 -0
- package/components/atoms/b-icon-button/b-icon-button.css +43 -0
- package/components/atoms/b-icon-button/b-icon-button.html +8 -0
- package/components/atoms/b-icon-button/b-icon-button.md +33 -0
- package/components/atoms/b-input/b-input.css +36 -0
- package/components/atoms/b-input/b-input.html +8 -0
- package/components/atoms/b-input/b-input.md +59 -0
- package/components/atoms/b-kbd/b-kbd.css +11 -0
- package/components/atoms/b-kbd/b-kbd.html +3 -0
- package/components/atoms/b-kbd/b-kbd.md +13 -0
- package/components/atoms/b-list/b-list.css +21 -0
- package/components/atoms/b-list/b-list.html +6 -0
- package/components/atoms/b-list/b-list.md +24 -0
- package/components/atoms/b-meter/b-meter.css +39 -0
- package/components/atoms/b-meter/b-meter.md +44 -0
- package/components/atoms/b-select/b-select.css +35 -0
- package/components/atoms/b-select/b-select.md +75 -0
- package/components/atoms/b-switch/b-switch.css +61 -0
- package/components/atoms/b-switch/b-switch.html +6 -0
- package/components/atoms/b-switch/b-switch.md +40 -0
- package/components/atoms/b-text/b-text.ai.md +29 -0
- package/components/atoms/b-text/b-text.css +2 -0
- package/components/atoms/b-text/b-text.html +3 -0
- package/components/atoms/b-text/b-text.md +23 -0
- package/components/atoms/code-block/code-block.css +42 -0
- package/components/atoms/code-block/code-block.md +23 -0
- package/components/examples.test.ts +23 -0
- package/components/molecules/callout/callout.css +19 -0
- package/components/molecules/callout/callout.md +15 -0
- package/components/molecules/card/card.css +28 -0
- package/components/molecules/card/card.md +30 -0
- package/components/molecules/chat-message/chat-message.css +83 -0
- package/components/molecules/chat-message/chat-message.md +52 -0
- package/components/molecules/chip-group/chip-group.css +35 -0
- package/components/molecules/chip-group/chip-group.md +42 -0
- package/components/molecules/content-index/content-index.css +87 -0
- package/components/molecules/content-index/content-index.md +27 -0
- package/components/molecules/content-source/content-source.css +6 -0
- package/components/molecules/content-source/content-source.md +13 -0
- package/components/molecules/figure/figure.css +19 -0
- package/components/molecules/figure/figure.md +20 -0
- package/components/molecules/lede/lede.css +17 -0
- package/components/molecules/lede/lede.md +17 -0
- package/components/molecules/made-with/made-with.css +25 -0
- package/components/molecules/made-with/made-with.md +35 -0
- package/components/molecules/nav-item/nav-item.css +19 -0
- package/components/molecules/nav-item/nav-item.md +21 -0
- package/components/molecules/stat-tile/stat-tile.css +34 -0
- package/components/molecules/stat-tile/stat-tile.md +50 -0
- package/components/molecules/status-list/status-list.css +47 -0
- package/components/molecules/status-list/status-list.md +62 -0
- package/components/molecules/tab/tab.css +32 -0
- package/components/molecules/tab/tab.md +27 -0
- package/components/molecules/table/table.css +23 -0
- package/components/molecules/table/table.md +18 -0
- package/components/organisms/activity-bar/activity-bar.css +36 -0
- package/components/organisms/activity-bar/activity-bar.md +43 -0
- package/components/organisms/app-shell/app-shell.css +193 -0
- package/components/organisms/app-shell/app-shell.md +58 -0
- package/components/organisms/app-shell/app-shell.test.ts +74 -0
- package/components/organisms/app-window/app-window.css +111 -0
- package/components/organisms/app-window/app-window.md +53 -0
- package/components/organisms/chat-log/chat-log.css +5 -0
- package/components/organisms/chat-log/chat-log.md +14 -0
- package/components/organisms/code-editor/code-editor.ai.md +31 -0
- package/components/organisms/code-editor/code-editor.css +111 -0
- package/components/organisms/code-editor/code-editor.md +122 -0
- package/components/organisms/console/console.css +112 -0
- package/components/organisms/console/console.md +66 -0
- package/components/organisms/file-tree/file-tree.css +85 -0
- package/components/organisms/file-tree/file-tree.md +49 -0
- package/components/organisms/note/note.css +19 -0
- package/components/organisms/note/note.md +20 -0
- package/components/organisms/notepad/notepad.css +60 -0
- package/components/organisms/notepad/notepad.md +40 -0
- package/components/organisms/side-rail/side-rail.css +55 -0
- package/components/organisms/side-rail/side-rail.md +24 -0
- package/components/organisms/sidebar-panel/sidebar-panel.css +69 -0
- package/components/organisms/sidebar-panel/sidebar-panel.md +47 -0
- package/components/organisms/status-bar/status-bar.css +33 -0
- package/components/organisms/status-bar/status-bar.md +28 -0
- package/components/organisms/tab-bar/tab-bar.css +48 -0
- package/components/organisms/tab-bar/tab-bar.md +26 -0
- package/components/organisms/timeline/timeline.css +51 -0
- package/components/organisms/timeline/timeline.md +42 -0
- package/components/organisms/topbar/topbar.css +8 -0
- package/components/organisms/topbar/topbar.md +26 -0
- package/components/responsive-polish.test.ts +43 -0
- package/components/tokens.test.ts +39 -0
- package/fonts/redaction-35-400.woff2 +0 -0
- package/fonts/redaction-400.woff2 +0 -0
- package/fonts/redaction-50-400.woff2 +0 -0
- package/fonts/redaction-70-400.woff2 +0 -0
- package/package.json +46 -0
- package/scripts/ai-dispatch.js +583 -0
- package/scripts/ai-dispatch.test.ts +85 -0
- package/scripts/ai-spotlight.d.ts +23 -0
- package/scripts/ai-spotlight.js +139 -0
- package/scripts/ai-spotlight.test.ts +31 -0
- package/scripts/catalog-peek.js +156 -0
- package/scripts/catalog-peek.test.ts +31 -0
- package/scripts/cmdk.js +159 -0
- package/scripts/demo-box.js +53 -0
- package/scripts/handoff.js +64 -0
- package/scripts/handoff.test.ts +36 -0
- package/scripts/lightbox.js +144 -0
- package/scripts/lightbox.test.ts +23 -0
- package/scripts/made-with.d.ts +2 -0
- package/scripts/made-with.js +22 -0
- package/scripts/made-with.test.ts +25 -0
- package/scripts/notepad.js +100 -0
- package/scripts/shell.js +204 -0
- package/scripts/shell.test.ts +50 -0
- package/scripts/tabs.js +127 -0
- package/scripts/tabs.test.ts +40 -0
- package/scripts/terminal.js +271 -0
- package/scripts/terminal.test.ts +36 -0
- package/scripts/theme-boot.js +15 -0
- package/scripts/theme.js +87 -0
- package/scripts/type-effect.js +25 -0
- package/scripts/xray.js +79 -0
- package/scripts/xray.test.ts +43 -0
- package/styles/cmdk.css +65 -0
- package/styles/global.css +80 -0
- package/styles/grain.css +47 -0
- package/styles/lightbox.css +78 -0
- package/styles/themes/_template.css +48 -0
- package/styles/themes/baguette.css +30 -0
- package/styles/themes/brioche.css +30 -0
- package/styles/variables.css +217 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/* organisms/code-editor — the interactive tier ABOVE code-block (atoms/code-block). Where
|
|
2
|
+
code-block is a static, hand-composed <pre> for MILL's blog prose, code-editor is the EDIT
|
|
3
|
+
surface: a framed panel with a toolbar, a mount slot a real editor (Monaco) is injected into,
|
|
4
|
+
a validation status strip, a diagnostics list, and a version-history drawer.
|
|
5
|
+
|
|
6
|
+
CSS-ONLY, like every grain component — grain ships no JS bundler, so this component bundles NO
|
|
7
|
+
editor. The consumer lazy-loads its own editor into `.code-editor__mount` (keeping Monaco's
|
|
8
|
+
weight off every page that isn't editing) and toggles the state data-attrs below. That's the
|
|
9
|
+
deliberate seam: grain owns the chrome + the monochrome grammar; the app owns the engine.
|
|
10
|
+
|
|
11
|
+
Shares code-block's mono/surface tokens on purpose — code in a MILL blog and code in the
|
|
12
|
+
editor read as ONE system. Signal is grain-monochrome throughout: no hue, states come from
|
|
13
|
+
weight/opacity/dashed-edge, never colour (DESIGN-SYSTEM §2). */
|
|
14
|
+
|
|
15
|
+
.code-editor {
|
|
16
|
+
display: flex; flex-direction: column; min-height: 0; /* flex child that can shrink for the mount to scroll */
|
|
17
|
+
background: var(--color-surface);
|
|
18
|
+
border: 1px solid var(--color-line);
|
|
19
|
+
border-radius: var(--radius-md);
|
|
20
|
+
overflow: hidden; /* clip the mount + drawer to the rounded frame */
|
|
21
|
+
font-family: var(--font-mono); /* the editing surface is code — mono in either grade */
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* ---- toolbar: the file identity on the left, actions on the right ------------------------- */
|
|
25
|
+
.code-editor__bar {
|
|
26
|
+
display: flex; align-items: center; gap: var(--space-2); flex: 0 0 auto;
|
|
27
|
+
padding: var(--space-2) var(--space-3);
|
|
28
|
+
border-bottom: 1px solid var(--color-line);
|
|
29
|
+
background: var(--color-bg);
|
|
30
|
+
font-family: var(--font-grain); /* chrome is machine-voice; only the code itself is mono */
|
|
31
|
+
font-size: var(--text-sm);
|
|
32
|
+
}
|
|
33
|
+
.code-editor__title { color: var(--color-fg); font-family: var(--font-mono); min-width: 0;
|
|
34
|
+
overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } /* long paths truncate, never wrap the bar */
|
|
35
|
+
/* a quiet "• unsaved" marker the app shows by flipping data-dirty on the root */
|
|
36
|
+
.code-editor__dirty { color: var(--color-muted); font-size: var(--text-xs); display: none; }
|
|
37
|
+
.code-editor[data-dirty="true"] .code-editor__dirty { display: inline; }
|
|
38
|
+
.code-editor__actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; flex: 0 0 auto; }
|
|
39
|
+
|
|
40
|
+
/* ---- mount: where the app injects the editor. Empty, it reads as a quiet code surface so the
|
|
41
|
+
panel never looks broken before the engine loads (progressive: SSR a <pre class="code-block">
|
|
42
|
+
here and Monaco replaces it). ---------------------------------------------------------------- */
|
|
43
|
+
.code-editor__mount {
|
|
44
|
+
flex: 1 1 0; min-height: 0; /* fills the frame beyond bar+strip; owns the scroll */
|
|
45
|
+
overflow: auto;
|
|
46
|
+
background: var(--color-surface);
|
|
47
|
+
font-family: var(--font-mono); font-size: var(--text-sm); line-height: var(--leading-normal);
|
|
48
|
+
color: var(--color-fg);
|
|
49
|
+
}
|
|
50
|
+
.code-editor__mount:focus-within { outline: 2px solid var(--color-accent); outline-offset: -2px; } /* inset — the frame already clips */
|
|
51
|
+
/* a code-block dropped inside the mount (the pre-engine fallback) loses its own frame — the panel
|
|
52
|
+
is the frame now. */
|
|
53
|
+
.code-editor__mount .code-block { margin: 0; border: 0; border-radius: 0; height: 100%; }
|
|
54
|
+
|
|
55
|
+
/* ---- status strip: one line under the mount, driven by data-state on the root. Monochrome:
|
|
56
|
+
the WORD carries the signal (via ::before glyph), invalid adds WEIGHT not colour. ------------ */
|
|
57
|
+
.code-editor__status {
|
|
58
|
+
flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-2);
|
|
59
|
+
padding: var(--space-1) var(--space-3);
|
|
60
|
+
border-top: 1px solid var(--color-line);
|
|
61
|
+
font-family: var(--font-grain); font-size: var(--text-xs); color: var(--color-muted);
|
|
62
|
+
}
|
|
63
|
+
.code-editor__status::before { content: ""; color: var(--color-fg); }
|
|
64
|
+
.code-editor[data-state="validating"] .code-editor__status::before { content: "◐ "; }
|
|
65
|
+
.code-editor[data-state="valid"] .code-editor__status::before { content: "✓ "; }
|
|
66
|
+
.code-editor[data-state="invalid"] .code-editor__status::before { content: "✕ "; }
|
|
67
|
+
.code-editor[data-state="saved"] .code-editor__status::before { content: "✓ "; }
|
|
68
|
+
/* invalid is louder, not redder — heavier ink + weight, mirroring b-select:user-invalid's 2px */
|
|
69
|
+
.code-editor[data-state="invalid"] .code-editor__status { color: var(--color-fg); font-weight: var(--font-weight-medium); }
|
|
70
|
+
.code-editor[data-state="invalid"] { border-width: 2px; }
|
|
71
|
+
|
|
72
|
+
/* ---- diagnostics: the parse/validate errors, listed under the strip. Hidden until there are
|
|
73
|
+
any (app sets data-state="invalid" / fills the list). Each row is line:col + message. -------- */
|
|
74
|
+
.code-editor__diagnostics { flex: 0 0 auto; display: none; max-height: 9rem; overflow: auto;
|
|
75
|
+
border-top: 1px solid var(--color-line); padding: var(--space-2) var(--space-3);
|
|
76
|
+
font-family: var(--font-mono); font-size: var(--text-xs); }
|
|
77
|
+
.code-editor[data-state="invalid"] .code-editor__diagnostics:not(:empty) { display: block; }
|
|
78
|
+
.code-editor__diag { display: flex; gap: var(--space-2); padding: var(--space-1) 0; color: var(--color-fg); }
|
|
79
|
+
.code-editor__diag-loc { color: var(--color-muted); flex: 0 0 auto; } /* e.g. "12:4" — the click target the app wires to jump the caret */
|
|
80
|
+
.code-editor__diag[data-clickable] { cursor: pointer; }
|
|
81
|
+
.code-editor__diag[data-clickable]:hover .code-editor__diag-loc { color: var(--color-accent); text-decoration: underline; }
|
|
82
|
+
|
|
83
|
+
/* ---- history drawer: versions of this spec, newest first. Off-canvas to the right, revealed by
|
|
84
|
+
data-history on the root (the app toggles it from a toolbar button). Each row: author + time +
|
|
85
|
+
message; restore is a button the app wires (restore = write a NEW version, never mutate). ---- */
|
|
86
|
+
.code-editor__history {
|
|
87
|
+
position: absolute; top: 0; right: 0; bottom: 0; width: min(20rem, 80%);
|
|
88
|
+
transform: translateX(100%); transition: transform 0.2s ease;
|
|
89
|
+
background: var(--color-bg); border-left: 1px solid var(--color-line);
|
|
90
|
+
display: flex; flex-direction: column; overflow: auto;
|
|
91
|
+
font-family: var(--font-grain); font-size: var(--text-sm);
|
|
92
|
+
}
|
|
93
|
+
.code-editor { position: relative; } /* the drawer anchors to the panel */
|
|
94
|
+
.code-editor[data-history="open"] .code-editor__history { transform: translateX(0); }
|
|
95
|
+
.code-editor__history-head { flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-2);
|
|
96
|
+
padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-line);
|
|
97
|
+
text-transform: uppercase; letter-spacing: 0.06em; font-size: var(--text-xs); color: var(--ink-faint); }
|
|
98
|
+
.code-editor__version { display: flex; flex-direction: column; gap: 2px;
|
|
99
|
+
padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-line); cursor: pointer; }
|
|
100
|
+
.code-editor__version:hover { background: var(--paper-2); }
|
|
101
|
+
.code-editor__version[data-current] { border-left: 2px solid var(--color-accent); } /* the live version */
|
|
102
|
+
.code-editor__version-meta { display: flex; gap: var(--space-2); color: var(--color-muted); font-size: var(--text-xs); }
|
|
103
|
+
.code-editor__version-msg { color: var(--color-fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
104
|
+
|
|
105
|
+
@media (prefers-reduced-motion: reduce) { .code-editor__history { transition: none; } }
|
|
106
|
+
|
|
107
|
+
/* ---- AI / in-transit: same vocabulary as code-block + the atoms (CONVENTIONS §4). An editor the
|
|
108
|
+
AI is writing into wears the dashed "terminal" edge (non-text grain). Human editing never
|
|
109
|
+
triggers it; the catalog grain-flip demonstrates it. ---------------------------------------- */
|
|
110
|
+
.code-editor[data-commit="pending"],
|
|
111
|
+
[data-grade="grain"] .code-editor { border-style: dashed; border-color: var(--ink); }
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Code editor
|
|
2
|
+
|
|
3
|
+
The interactive tier above [code-block](../../atoms/code-block/code-block.md): a framed edit
|
|
4
|
+
surface with a toolbar, a **mount slot** a real editor is injected into, a validation status
|
|
5
|
+
strip, a diagnostics list, and a version-history drawer. CSS-only like every grain component —
|
|
6
|
+
it bundles **no** editor. The consumer lazy-loads its own (Monaco, CodeMirror, a plain
|
|
7
|
+
`<textarea>`) into `.code-editor__mount` and toggles the `data-state` / `data-history` /
|
|
8
|
+
`data-dirty` attributes; grain owns the chrome and the monochrome grammar, the app owns the
|
|
9
|
+
engine. Shares code-block's mono/surface tokens so code in a blog and code in the editor read as
|
|
10
|
+
one system. Give the panel a height (grid/flex parent) — the mount owns the scroll.
|
|
11
|
+
|
|
12
|
+
## Frame
|
|
13
|
+
|
|
14
|
+
### Empty (pre-engine fallback)
|
|
15
|
+
The mount holds a plain code-block until the engine mounts, so the panel never looks broken.
|
|
16
|
+
```html
|
|
17
|
+
<div class="code-editor" style="height:20rem">
|
|
18
|
+
<div class="code-editor__bar">
|
|
19
|
+
<span class="code-editor__title">tests/checkout.spec.ts</span>
|
|
20
|
+
<span class="code-editor__dirty">• unsaved</span>
|
|
21
|
+
<span class="code-editor__actions">
|
|
22
|
+
<button class="btn" data-size="sm" data-variant="soft">Validate</button>
|
|
23
|
+
<button class="btn" data-size="sm">Save</button>
|
|
24
|
+
</span>
|
|
25
|
+
</div>
|
|
26
|
+
<div class="code-editor__mount">
|
|
27
|
+
<pre class="code-block"><code>import { test, expect } from '@playwright/test';</code></pre>
|
|
28
|
+
</div>
|
|
29
|
+
<div class="code-editor__status">Ready</div>
|
|
30
|
+
</div>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Dirty
|
|
34
|
+
Flip `data-dirty="true"` to reveal the unsaved marker.
|
|
35
|
+
```html
|
|
36
|
+
<div class="code-editor" data-dirty="true" style="height:12rem">
|
|
37
|
+
<div class="code-editor__bar">
|
|
38
|
+
<span class="code-editor__title">tests/checkout.spec.ts</span>
|
|
39
|
+
<span class="code-editor__dirty">• unsaved</span>
|
|
40
|
+
<span class="code-editor__actions">
|
|
41
|
+
<button class="btn" data-size="sm">Save</button>
|
|
42
|
+
</span>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="code-editor__mount"><pre class="code-block"><code>// edited…</code></pre></div>
|
|
45
|
+
<div class="code-editor__status">Ready</div>
|
|
46
|
+
</div>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Validation
|
|
50
|
+
|
|
51
|
+
The status strip reads `data-state` on the root. Monochrome: the glyph + word carry the signal,
|
|
52
|
+
`invalid` adds weight and a heavier frame — never colour.
|
|
53
|
+
|
|
54
|
+
### Validating
|
|
55
|
+
```html
|
|
56
|
+
<div class="code-editor" data-state="validating" style="height:8rem">
|
|
57
|
+
<div class="code-editor__bar"><span class="code-editor__title">spec.ts</span></div>
|
|
58
|
+
<div class="code-editor__mount"></div>
|
|
59
|
+
<div class="code-editor__status">Validating…</div>
|
|
60
|
+
</div>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Valid
|
|
64
|
+
```html
|
|
65
|
+
<div class="code-editor" data-state="valid" style="height:8rem">
|
|
66
|
+
<div class="code-editor__bar"><span class="code-editor__title">spec.ts</span></div>
|
|
67
|
+
<div class="code-editor__mount"></div>
|
|
68
|
+
<div class="code-editor__status">Compiles — 0 problems</div>
|
|
69
|
+
</div>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Invalid (with diagnostics)
|
|
73
|
+
The diagnostics list shows when `data-state="invalid"` and the list is non-empty. Each row is a
|
|
74
|
+
`__diag-loc` (line:col — the app wires it to jump the caret) plus the message.
|
|
75
|
+
```html
|
|
76
|
+
<div class="code-editor" data-state="invalid" style="height:12rem">
|
|
77
|
+
<div class="code-editor__bar"><span class="code-editor__title">spec.ts</span></div>
|
|
78
|
+
<div class="code-editor__mount"></div>
|
|
79
|
+
<div class="code-editor__status">1 problem</div>
|
|
80
|
+
<div class="code-editor__diagnostics">
|
|
81
|
+
<div class="code-editor__diag" data-clickable>
|
|
82
|
+
<span class="code-editor__diag-loc">12:4</span>
|
|
83
|
+
<span>Cannot find name 'expcet'. Did you mean 'expect'?</span>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Saved
|
|
90
|
+
```html
|
|
91
|
+
<div class="code-editor" data-state="saved" style="height:8rem">
|
|
92
|
+
<div class="code-editor__bar"><span class="code-editor__title">spec.ts</span></div>
|
|
93
|
+
<div class="code-editor__mount"></div>
|
|
94
|
+
<div class="code-editor__status">Saved as version 4</div>
|
|
95
|
+
</div>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## History
|
|
99
|
+
|
|
100
|
+
Toggle `data-history="open"` to slide the version drawer in. Rows are newest-first; the live one
|
|
101
|
+
carries `data-current`. Restore writes a new version — history is never mutated.
|
|
102
|
+
```html
|
|
103
|
+
<div class="code-editor" data-history="open" style="height:16rem">
|
|
104
|
+
<div class="code-editor__bar">
|
|
105
|
+
<span class="code-editor__title">spec.ts</span>
|
|
106
|
+
<span class="code-editor__actions"><button class="btn" data-size="sm" data-variant="soft">History</button></span>
|
|
107
|
+
</div>
|
|
108
|
+
<div class="code-editor__mount"></div>
|
|
109
|
+
<div class="code-editor__status">Ready</div>
|
|
110
|
+
<aside class="code-editor__history">
|
|
111
|
+
<div class="code-editor__history-head">History</div>
|
|
112
|
+
<div class="code-editor__version" data-current>
|
|
113
|
+
<div class="code-editor__version-msg">tighten the checkout assertion</div>
|
|
114
|
+
<div class="code-editor__version-meta"><span>maria</span><span>2m ago</span></div>
|
|
115
|
+
</div>
|
|
116
|
+
<div class="code-editor__version">
|
|
117
|
+
<div class="code-editor__version-msg">initial spec</div>
|
|
118
|
+
<div class="code-editor__version-meta"><span>maria</span><span>yesterday</span></div>
|
|
119
|
+
</div>
|
|
120
|
+
</aside>
|
|
121
|
+
</div>
|
|
122
|
+
```
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/* organisms/console — the AI's narration TERMINAL, a DOCKED bottom panel (VS Code style): it
|
|
2
|
+
lives in the shell's `console` grid row under main, not floating. At rest it's a slim clickable
|
|
3
|
+
bar ("Terminal ▸"); clicking it — or the AI taking over (`data-acting`) — opens the feed in
|
|
4
|
+
place (the grid row grows to a fixed band). A second control (`console__grow`) expands that
|
|
5
|
+
band further, to fill most of the shell's height. It narrates the AI's steps as `action-badge`
|
|
6
|
+
lines. Persona-neutral. CSS-only pattern: compose `.console__box` inside `.app-shell__console`;
|
|
7
|
+
see console.md. (Loads after app-shell.css in the sorted bundle.) */
|
|
8
|
+
|
|
9
|
+
.app-shell__console { display: flex; flex-direction: column; min-height: 0; background: var(--color-bg); }
|
|
10
|
+
/* the box fills the console grid row (whose HEIGHT is what animates, in app-shell.css); the bar is
|
|
11
|
+
fixed, the feed flex-grows into the rest — so the row height alone drives open/expand and the
|
|
12
|
+
feed carries no intrinsic height (see the feed's `flex: 1 1 0` below). */
|
|
13
|
+
.console__box { display: flex; flex-direction: column; width: 100%; flex: 1 1 auto; min-height: 0; overflow: hidden; background: var(--color-bg); }
|
|
14
|
+
.console__bar { display: flex; align-items: center; gap: var(--space-2); flex: 0 0 auto;
|
|
15
|
+
padding: var(--space-2) var(--space-4); font-family: var(--font-grain); font-size: var(--text-sm); color: var(--color-muted); }
|
|
16
|
+
/* the expand control: a transparent, keyboard-operable button that looks like the bar text */
|
|
17
|
+
.console__expand { display: flex; align-items: center; gap: var(--space-2); flex: 1; min-width: 0;
|
|
18
|
+
background: transparent; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
|
|
19
|
+
.console__expand:focus-visible, .console__grow:focus-visible, .chat-thinking__toggle:focus-visible {
|
|
20
|
+
outline: 2px solid var(--color-accent); outline-offset: 2px; }
|
|
21
|
+
.console__label { color: var(--color-fg); }
|
|
22
|
+
.console__acting { display: none; color: var(--color-fg); } /* shown only while acting */
|
|
23
|
+
.console__chev { color: var(--ink-faint); transition: transform 0.2s ease; } /* ▾ open · ▸ collapsed */
|
|
24
|
+
.app-shell:not([data-console-open]):not([data-acting="true"]) .console__chev { transform: rotate(-90deg); }
|
|
25
|
+
/* the feed carries NO intrinsic height (`flex: 1 1 0`) — it simply fills whatever the console grid
|
|
26
|
+
row gives it beyond the bar. So closed (row = bar height) → feed 0 → hidden; open (row = the
|
|
27
|
+
16rem band) → feed ~13rem; expanded (row = 1fr) → feed fills the screen. All the animation lives
|
|
28
|
+
in the grid ROW height (app-shell.css), which glides because its endpoints are all lengths/fr —
|
|
29
|
+
the feed just follows. This replaced a `max-height` reveal that snapped on the auto↔fr expand. */
|
|
30
|
+
.console__feed { display: flex; flex-direction: column; gap: var(--space-2); flex: 1 1 0;
|
|
31
|
+
min-height: 0; overflow: auto; scroll-behavior: smooth;
|
|
32
|
+
border-top: 0 solid var(--color-line);
|
|
33
|
+
padding: 0 var(--space-4); font-family: var(--font-grain); font-size: var(--text-sm); }
|
|
34
|
+
/* fully CLOSED = the feed is genuinely gone (not a 1-2px sliver that reads as "visible"): the row
|
|
35
|
+
is just the bar. It reappears when open/expanded, sliding in as the grid row grows around it.
|
|
36
|
+
(A run alone — data-acting — keeps it closed; the chat previews instead.) */
|
|
37
|
+
.app-shell:not([data-console-open]):not([data-console-expanded]) .console__feed { display: none; }
|
|
38
|
+
/* border + vertical padding appear once there's a feed to show (open / expanded) */
|
|
39
|
+
.app-shell[data-console-open] .console__feed,
|
|
40
|
+
.app-shell[data-console-expanded] .console__feed { border-top-width: 1px; padding-top: var(--space-2); padding-bottom: var(--space-2); }
|
|
41
|
+
/* v3.1 tried boxing each line individually (mirrors chat-message) — reverted (owner, 2026-07-06):
|
|
42
|
+
it read as harder to scan, not easier, and doubled up with the chat-thinking box's own border
|
|
43
|
+
around the whole run's preview. A flowing stream, one row per line, is the readable form; the
|
|
44
|
+
OUTPUT-level grouping (one bordered box per run) already comes from the surrounding container
|
|
45
|
+
(.console__feed's border-top in the terminal, .chat-thinking's border in the chat preview). */
|
|
46
|
+
.console__line { display: flex; align-items: baseline; gap: var(--space-2); padding: var(--space-1) 0; }
|
|
47
|
+
.console__desc { color: var(--color-fg); }
|
|
48
|
+
.console__line[data-variant="cmd"] .console__prompt { color: var(--color-accent); } /* the echoed human command */
|
|
49
|
+
.console__line[data-state="error"] .console__desc { color: var(--color-danger, var(--color-accent)); }
|
|
50
|
+
.console__line a { color: var(--color-accent); text-decoration: none; }
|
|
51
|
+
.console__line a:hover { text-decoration: underline; }
|
|
52
|
+
.console__pre { margin: 0; white-space: pre-wrap; word-break: break-word;
|
|
53
|
+
font-family: var(--font-grain); font-size: var(--text-xs); color: var(--color-fg); line-height: 1.5; }
|
|
54
|
+
|
|
55
|
+
/* the INTERACTIVE command line (grain/scripts/terminal.js injects it into a
|
|
56
|
+
`.console__box[data-terminal="interactive"]`). Shown only when the terminal is open — it rides
|
|
57
|
+
the same open/close as the feed. The prompt is grain (machine), the typed text is clean (human,
|
|
58
|
+
via .field-like grade); tokens only. */
|
|
59
|
+
.console__input { display: none; align-items: baseline; gap: var(--space-2); flex: 0 0 auto;
|
|
60
|
+
border-top: 1px solid var(--color-line); padding: var(--space-2) var(--space-4);
|
|
61
|
+
font-family: var(--font-grain); font-size: var(--text-sm); }
|
|
62
|
+
.app-shell[data-console-open] .console__box[data-terminal="interactive"] .console__input { display: flex; }
|
|
63
|
+
.console__prompt { color: var(--color-muted); flex: 0 0 auto; }
|
|
64
|
+
.console__cmd { flex: 1; min-width: 0; background: transparent; border: 0; padding: 0; margin: 0;
|
|
65
|
+
color: var(--color-fg); font-family: var(--font-smooth); font-size: var(--text-sm); }
|
|
66
|
+
.console__cmd::placeholder { color: var(--ink-faint); }
|
|
67
|
+
.console__cmd:focus { outline: none; }
|
|
68
|
+
.console__input:focus-within .console__prompt { color: var(--color-accent); }
|
|
69
|
+
|
|
70
|
+
/* the chat's mid-run "thinking" box: a compact indicator + a small LIVE PREVIEW of the terminal
|
|
71
|
+
output (the last few lines, mirrored by shell.js), with a button to expand the full terminal. */
|
|
72
|
+
.chat-thinking { display: none; flex-direction: column; margin: 0 var(--space-4) var(--space-3);
|
|
73
|
+
border: 1px dashed var(--ink-faint); border-radius: var(--radius-md); padding: var(--space-2) var(--space-3);
|
|
74
|
+
background: color-mix(in srgb, var(--ink) 4%, transparent); }
|
|
75
|
+
.chat-thinking__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-1); }
|
|
76
|
+
.chat-thinking__who { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
|
|
77
|
+
/* compact icon button (saves space in the run-time thinking box) */
|
|
78
|
+
.chat-thinking__toggle { cursor: pointer; font: inherit; color: var(--color-fg);
|
|
79
|
+
display: inline-flex; align-items: center; justify-content: center; width: 1.5rem; height: 1.5rem; padding: 0;
|
|
80
|
+
background: transparent; border: 1px solid var(--color-line); border-radius: var(--radius-sm); }
|
|
81
|
+
.chat-thinking__toggle:hover { background: var(--paper-2); }
|
|
82
|
+
/* holds CLONED narration lines (each action in its own box, mirrored from the terminal) */
|
|
83
|
+
.chat-thinking__preview { display: flex; flex-direction: column; gap: var(--space-1);
|
|
84
|
+
max-height: 6em; overflow: hidden; font-size: var(--text-xs); }
|
|
85
|
+
.chat-thinking__preview:empty { display: none; }
|
|
86
|
+
|
|
87
|
+
/* the GROW toggle: expand the docked terminal to fill most of the shell's vertical space (owner,
|
|
88
|
+
2026-07-06) instead of the fixed 11rem band — for reading a long run back. Label via ::before,
|
|
89
|
+
so it stays correct even when the state is reset externally. Repurposes the slot of the old
|
|
90
|
+
chat⇄terminal toggle, dead since the chat and terminal started coexisting (owner, 2026-07-05). */
|
|
91
|
+
.console__grow { display: inline-flex; align-items: center; margin-left: auto; cursor: pointer;
|
|
92
|
+
font: inherit; font-size: var(--text-xs); color: var(--color-fg); background: transparent;
|
|
93
|
+
border: 1px solid var(--color-line); border-radius: var(--radius-sm); padding: 2px var(--space-2); }
|
|
94
|
+
.console__grow::before { content: "⤢ expand"; }
|
|
95
|
+
.app-shell[data-console-expanded] .console__grow::before { content: "⤡ collapse"; }
|
|
96
|
+
.console__grow:hover { background: var(--paper-2); }
|
|
97
|
+
|
|
98
|
+
/* TAKEOVER: on `data-acting` the docked terminal's bar becomes the "acting" indicator (grain's
|
|
99
|
+
top label is hidden) and the feed opens in place. The chat stays put alongside it — thinking
|
|
100
|
+
goes to the terminal, communication to the chat (owner, 2026-07-05). */
|
|
101
|
+
.app-shell[data-acting="true"] .console__acting { display: inline; }
|
|
102
|
+
.app-shell[data-acting="true"] ~ .ai-acting-label { display: none; }
|
|
103
|
+
/* the docked terminal stays ABOVE the spotlight veil so its narration is never dimmed/overlaid */
|
|
104
|
+
.app-shell[data-acting="true"] .app-shell__console { position: relative; z-index: var(--z-ai-surface, 9002); }
|
|
105
|
+
/* the chat shows a compact "thinking" indicator during a run (its full narration is the terminal) */
|
|
106
|
+
.app-shell[data-acting="true"] .chat-thinking { display: flex; }
|
|
107
|
+
|
|
108
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
109
|
+
.app-shell[data-acting="true"] .console__bar .icon { animation: console-blink 1s steps(1) infinite; }
|
|
110
|
+
}
|
|
111
|
+
@media (prefers-reduced-motion: reduce) { .console__feed, .console__chev { transition: none; } }
|
|
112
|
+
@keyframes console-blink { 50% { opacity: 0.25; } }
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# console
|
|
2
|
+
|
|
3
|
+
The AI's narration **terminal** — a **docked bottom panel** (VS Code style), not a floating box. At
|
|
4
|
+
rest it's a slim clickable bar (`Terminal ▸`); clicking `console-toggle` opens the feed **in place**
|
|
5
|
+
(`data-console-open` — the shell's `console` grid row grows to a fixed ~16rem band, so the main pane
|
|
6
|
+
shrinks and scrolls). A second control, `console-grow-toggle`, expands that band further to fill the
|
|
7
|
+
whole shell (`data-console-expanded`, main collapses to 0) — for reading a long run back. **Every
|
|
8
|
+
state change glides:** the row is a `minmax(<floor>, <fr>)` grid track whose endpoints are all
|
|
9
|
+
lengths/fr, so `grid-template-rows` interpolates (bar → band → full-screen) instead of snapping; the
|
|
10
|
+
feed is `flex: 1 1 0` and just fills the row (no `max-height` reveal). During a **run**
|
|
11
|
+
(`data-acting`) the terminal stays **collapsed** — the `sidebar-panel` (chat) shows a live preview
|
|
12
|
+
and the person clicks "open in terminal" (→ `data-console-open`) to see the full feed. It narrates
|
|
13
|
+
the AI's steps as `action-badge` lines, each a plain row (not individually boxed — a run's lines read
|
|
14
|
+
as one flowing entry). The terminal shows the AI's **thinking**; the chat is for **communication** —
|
|
15
|
+
the two coexist, so the chat no longer collapses during a run. CSS-only (no `.html`).
|
|
16
|
+
|
|
17
|
+
**Parent context (required):** lives inside the shell's `.app-shell__console` region (which docks
|
|
18
|
+
under `main`). Its height is driven by `--shell-console-min` / `--shell-console-fr` on the shell
|
|
19
|
+
(`data-console-open` raises the floor to the band; `data-console-expanded` grows the fr to fill).
|
|
20
|
+
`data-acting` (set by `grain/scripts/ai-dispatch.js` on a `spotlight` op) marks a run but does NOT
|
|
21
|
+
open the feed. The AI narrates by pushing
|
|
22
|
+
`append` ops at the `console` surface. Persona-neutral.
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<section class="app-shell__console">
|
|
26
|
+
<div class="console__box">
|
|
27
|
+
<div class="console__bar">
|
|
28
|
+
<button class="console__expand" data-shell="console-toggle">
|
|
29
|
+
<b-icon sym="…#spark" size="sm"></b-icon><span class="console__label">the AI</span>
|
|
30
|
+
<span class="console__acting">is acting…</span><span class="console__chev">▾</span>
|
|
31
|
+
</button>
|
|
32
|
+
<button class="console__grow" data-shell="console-grow-toggle"></button>
|
|
33
|
+
</div>
|
|
34
|
+
<div class="console__feed" data-surface="console"></div>
|
|
35
|
+
</div>
|
|
36
|
+
</section>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Interactive mode (opt-in) — the terminal takes a command line
|
|
40
|
+
|
|
41
|
+
Add `data-terminal="interactive"` to the `.console__box` and load `grain/scripts/terminal.js`
|
|
42
|
+
(`<script type="module">`). The island **injects the input row itself** (`.console__input` with a
|
|
43
|
+
`.console__prompt` + `.console__cmd`) — no markup to compose. The row shows whenever the console is
|
|
44
|
+
open (`data-console-open`) and rides the same open/close as the feed. A console *without* the
|
|
45
|
+
attribute (e.g. the product's `/loop` narration feed) stays display-only, untouched.
|
|
46
|
+
|
|
47
|
+
The terminal becomes a **third client of the one door**: a human types a command, and anything
|
|
48
|
+
AI-shaped (`ask`, `tour`, `stop`) is raised as a real Intent through `window.grain.door.submit` —
|
|
49
|
+
the same door a click or the AI uses (so it inherits the pending-trigger lifecycle + the ready-gate;
|
|
50
|
+
never a private `fetch`). Reads (`help`, `go`, `ls`, `grep`, `theme`, `context`, `xray`) run locally.
|
|
51
|
+
|
|
52
|
+
**Grade doctrine in the feed:** the feed defaults to grain (machine voice), so command *output*
|
|
53
|
+
stays grain; the human's **echoed command** carries `data-grade="smooth"` and settles clean. History
|
|
54
|
+
is `↑/↓` (localStorage), `Tab` completes commands + page slugs, `` Ctrl+` `` opens + focuses it.
|
|
55
|
+
|
|
56
|
+
**Extend it:** `window.grain.terminal.register({ name, args, help, run(ctx) })`. GRAIN ships the
|
|
57
|
+
generic builtins (`help`/`clear`/`exit`/`go`/`ls`/`grep`/`theme`/`ask`/`stop`/`context`/`xray`);
|
|
58
|
+
a consumer registers its own persona/tour commands in its own script (grain stays persona-neutral).
|
|
59
|
+
The `ctx` gives `{ argv, arg, raw, print, printHtml, printPre, printErr, clear, door, corpus }`.
|
|
60
|
+
|
|
61
|
+
```html
|
|
62
|
+
<div class="console__box" data-terminal="interactive"> … </div>
|
|
63
|
+
<script type="module" src="/scripts/terminal.js"></script>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
See `sidebar-panel` (its counterpart) and `app-shell` (the grid + takeover state).
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/* organisms/file-tree — an EXPLORER file tree (the editor-workspace metaphor): folders as native
|
|
2
|
+
<details>/<summary> (zero-JS collapse, COLLAPSED by default — author without `open`), files as
|
|
3
|
+
real <a> links. Mono type, hairline indent guides, a chevron that rotates on open — VS Code's
|
|
4
|
+
explorer re-spoken in GRAIN. A layout class composed of native elements, not a data-bound tag;
|
|
5
|
+
what the paths MEAN (which file produces which page) is the consumer's contract — this only
|
|
6
|
+
draws the tree. Lives naturally in the app-shell rail (side-rail[data-variant="explorer"]
|
|
7
|
+
drops the icon gutter for it), but works in any column. */
|
|
8
|
+
.file-tree {
|
|
9
|
+
display: flex; flex-direction: column;
|
|
10
|
+
min-height: 0; overflow-y: auto; overscroll-behavior: contain;
|
|
11
|
+
font-family: var(--font-mono); font-size: var(--text-xs); letter-spacing: 0.01em;
|
|
12
|
+
scrollbar-width: thin;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* ---- a folder: <details class="file-tree__dir"><summary>name/</summary><div class="file-tree__children">… ---- */
|
|
16
|
+
.file-tree__dir > summary {
|
|
17
|
+
display: flex; align-items: center; gap: var(--space-1);
|
|
18
|
+
padding: 0.28rem var(--space-2);
|
|
19
|
+
color: var(--color-muted); cursor: pointer; user-select: none;
|
|
20
|
+
list-style: none; white-space: nowrap;
|
|
21
|
+
}
|
|
22
|
+
.file-tree__dir > summary::-webkit-details-marker { display: none; }
|
|
23
|
+
.file-tree__dir > summary:hover { color: var(--color-fg); }
|
|
24
|
+
/* the chevron: one glyph, rotated by state — no per-state art */
|
|
25
|
+
.file-tree__dir > summary::before {
|
|
26
|
+
content: "▸"; flex: 0 0 auto; width: 0.9em;
|
|
27
|
+
color: var(--ink-faint); font-size: 0.9em;
|
|
28
|
+
transition: transform 0.15s ease;
|
|
29
|
+
}
|
|
30
|
+
.file-tree__dir[open] > summary::before { transform: rotate(90deg); }
|
|
31
|
+
@media (prefers-reduced-motion: reduce) { .file-tree__dir > summary::before { transition: none; } }
|
|
32
|
+
|
|
33
|
+
/* ---- children indent under a hairline guide (the VS Code indent line) ---- */
|
|
34
|
+
.file-tree__children {
|
|
35
|
+
display: flex; flex-direction: column;
|
|
36
|
+
margin-left: calc(var(--space-2) + 0.45em);
|
|
37
|
+
border-left: 1px solid color-mix(in srgb, var(--color-line) 60%, transparent);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* ---- a file: a real link (hypermedia — the tree navigates with zero JS) ---- */
|
|
41
|
+
.file-tree__file {
|
|
42
|
+
display: block; padding: 0.28rem var(--space-2);
|
|
43
|
+
color: var(--color-muted); text-decoration: none;
|
|
44
|
+
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
|
|
45
|
+
}
|
|
46
|
+
.file-tree__file:hover { color: var(--color-fg);
|
|
47
|
+
background: color-mix(in srgb, var(--color-surface) 70%, transparent); }
|
|
48
|
+
/* an index/entry file (a folder's own page, e.g. index.html) is DIMMED — the directory name
|
|
49
|
+
above it carries the meaning, so the filename recedes. Hover + current win by later position. */
|
|
50
|
+
.file-tree__file[data-variant="index"] { color: var(--ink-faint); }
|
|
51
|
+
/* the OPEN file: ink + a quiet accent edge (mirrors the rail's current-item bar) */
|
|
52
|
+
.file-tree__file[aria-current="page"] {
|
|
53
|
+
color: var(--color-fg); position: relative;
|
|
54
|
+
background: color-mix(in srgb, var(--color-surface) 85%, transparent);
|
|
55
|
+
}
|
|
56
|
+
.file-tree__file[aria-current="page"]::before {
|
|
57
|
+
content: ""; position: absolute; top: 0; bottom: 0; left: -1px;
|
|
58
|
+
width: 2px; background: var(--color-accent);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* a collection folder may make its NAME a link (the folder's index page): the summary's <a>
|
|
62
|
+
inherits the folder register; navigating is the link's, toggling stays the summary's. */
|
|
63
|
+
.file-tree__dir > summary > a { color: inherit; text-decoration: none; }
|
|
64
|
+
.file-tree__dir > summary > a:hover { color: var(--color-fg); }
|
|
65
|
+
|
|
66
|
+
/* ---- a file that's also an OPEN TAB gets a close affordance (tabs.js injects `.file-tree__close`
|
|
67
|
+
as a real child span, live-wired — mirrors `.tab__close`'s hidden-until-hover pattern). :has()
|
|
68
|
+
opts a single row into the flex/space-between layout; a plain file-tree__file is untouched. ---- */
|
|
69
|
+
.file-tree__file:has(.file-tree__close) { display: flex; align-items: center; justify-content: space-between; }
|
|
70
|
+
.file-tree__close {
|
|
71
|
+
display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
|
|
72
|
+
width: 1.15rem; height: 1.15rem; border-radius: var(--radius-sm);
|
|
73
|
+
color: transparent; pointer-events: none;
|
|
74
|
+
}
|
|
75
|
+
.file-tree__file:hover .file-tree__close, .file-tree__file[aria-current="page"] .file-tree__close {
|
|
76
|
+
color: var(--ink-faint);
|
|
77
|
+
}
|
|
78
|
+
.file-tree__close:hover { color: var(--color-fg); background: color-mix(in srgb, var(--color-surface) 70%, transparent); }
|
|
79
|
+
|
|
80
|
+
/* ---- inside a collapsed shell rail the labels are gone — a tree without labels is noise ---- */
|
|
81
|
+
[data-rail-collapsed="true"] .file-tree { display: none; }
|
|
82
|
+
|
|
83
|
+
/* ---- explorer variant of the rail: the icon gutter is the NAV rail's look; a tree brings its
|
|
84
|
+
own indent guides, so the host drops the gutter line ---- */
|
|
85
|
+
.side-rail[data-variant="explorer"]::before { display: none; }
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# file-tree
|
|
2
|
+
|
|
3
|
+
An EXPLORER file tree for the editor-workspace metaphor: folders are native
|
|
4
|
+
`<details class="file-tree__dir">` / `<summary>` (zero-JS collapse — ship them **collapsed**, no
|
|
5
|
+
`open` attribute; an island may open the current page's ancestors), files are real `<a
|
|
6
|
+
class="file-tree__file">` links, so the whole tree navigates as plain hypermedia. Mono type,
|
|
7
|
+
hairline indent guides, a rotating chevron. A layout class, not a data-bound tag.
|
|
8
|
+
|
|
9
|
+
**Honesty contract (consumer's job):** every entry should name a REAL source file and link to the
|
|
10
|
+
page that file produces — an invented filename in the tree is a lie in the UI. What maps to what
|
|
11
|
+
is the consumer's knowledge; this component only draws it.
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<nav class="file-tree" aria-label="Explorer">
|
|
15
|
+
<details class="file-tree__dir">
|
|
16
|
+
<summary>tjakoen.github.io/</summary>
|
|
17
|
+
<div class="file-tree__children">
|
|
18
|
+
<details class="file-tree__dir">
|
|
19
|
+
<summary><a href="/notes">notes/</a></summary> <!-- a collection folder may link its index -->
|
|
20
|
+
<div class="file-tree__children">
|
|
21
|
+
<a class="file-tree__file" href="/notes/ten-times-zero">ten-times-zero.md</a>
|
|
22
|
+
</div>
|
|
23
|
+
</details>
|
|
24
|
+
<a class="file-tree__file" href="/" aria-current="page">pages/index.html</a>
|
|
25
|
+
</div>
|
|
26
|
+
</details>
|
|
27
|
+
</nav>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
**Directories carry the meaning.** A folder's own page (its `index.html`) is an entry file, not
|
|
31
|
+
where the meaning lives — the *directory name* above it does. Dim such a file with
|
|
32
|
+
`data-variant="index"` so the eye reads the folder, and give it a `data-tab-label` so the open-tabs
|
|
33
|
+
strip shows the section name ("GRAIN") not "index.html".
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<a class="file-tree__file" href="/grain" data-variant="index" data-tab-label="GRAIN">index.html</a>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Parent-context notes (lesson 3 — say it here, don't let it fail silently):
|
|
40
|
+
- In the app-shell rail, put `data-variant="explorer"` on the `.side-rail` — the tree brings its
|
|
41
|
+
own indent guides, so the variant drops the rail's icon-gutter hairline.
|
|
42
|
+
- A collapsed rail (`data-rail-collapsed="true"`) hides the tree entirely (labels ARE the tree).
|
|
43
|
+
- Mark the open file with `aria-current="page"` (an island or the server); folders don't get it.
|
|
44
|
+
|
|
45
|
+
Pairs with `tab-bar`/`tab` + `scripts/tabs.js` (open-pages strip): give the tree
|
|
46
|
+
`data-tab-source` and the strip labels its tabs from the tree's link texts. The same script also
|
|
47
|
+
injects a close affordance (`.file-tree__close`, hidden until hover) onto any tree entry that's
|
|
48
|
+
currently an open (non-pinned) tab — closing it from the sidebar without switching to the page
|
|
49
|
+
first. Purely a projection of tab state; the tree itself carries no close markup at rest.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* organisms/note — the editorial content article MILL's default layout emits:
|
|
2
|
+
.note / .note__head / .note__lede / .note__tags. CSS-only (CONVENTIONS §4): composed by
|
|
3
|
+
MILL at request time, nothing data-binds it. MILL content is human-authored → the layout
|
|
4
|
+
stamps data-grade="smooth", so the AI-mode idiom never triggers from MILL itself; the
|
|
5
|
+
text grain would still apply if a consumer ever marked one in-transit. */
|
|
6
|
+
.note { max-width: 72ch; }
|
|
7
|
+
.note > p, .note > ul, .note > ol, .note > blockquote { line-height: var(--leading-relaxed); }
|
|
8
|
+
|
|
9
|
+
.note__head .eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: var(--text-xs); }
|
|
10
|
+
.note__head .masthead { font-size: var(--text-3xl); margin-bottom: var(--space-3); }
|
|
11
|
+
.note__lede {
|
|
12
|
+
color: var(--color-muted);
|
|
13
|
+
font-size: var(--text-lg);
|
|
14
|
+
line-height: var(--leading-relaxed);
|
|
15
|
+
max-width: 60ch;
|
|
16
|
+
margin: 0 0 var(--space-4);
|
|
17
|
+
}
|
|
18
|
+
.note__tags { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0 0 var(--space-4); }
|
|
19
|
+
.note__head > .rule { margin-top: var(--space-4); }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Note
|
|
2
|
+
|
|
3
|
+
The editorial content article — the layout MILL's default GRAIN adapter emits for a
|
|
4
|
+
rendered Markdown document (eyebrow meta → masthead → lede → tag badges → hairline rule →
|
|
5
|
+
prose). CSS-only: MILL composes the markup; nothing data-binds it. Human-authored content →
|
|
6
|
+
always clean ink (`data-grade="smooth"`; only the AI grains).
|
|
7
|
+
|
|
8
|
+
## Note article
|
|
9
|
+
```html
|
|
10
|
+
<article class="note" data-grade="smooth">
|
|
11
|
+
<header class="note__head">
|
|
12
|
+
<p class="eyebrow">2026-07-03 · ~13 min</p>
|
|
13
|
+
<h1 class="masthead">Ten Times Zero Is Still Zero</h1>
|
|
14
|
+
<p class="note__lede">How I actually work with AI, and why it holds up.</p>
|
|
15
|
+
<div class="note__tags"><span class="badge" data-status="active">ai</span> <span class="badge" data-status="active">workflow</span></div>
|
|
16
|
+
<hr class="rule">
|
|
17
|
+
</header>
|
|
18
|
+
<p>AI is a multiplier, not an addend…</p>
|
|
19
|
+
</article>
|
|
20
|
+
```
|