@tjakoen/grain 0.1.12 → 0.1.14
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/PLAN.md +1 -1
- package/README.md +9 -0
- package/components/molecules/data-table/data-table.css +47 -0
- package/components/molecules/data-table/data-table.md +65 -0
- package/components/molecules/data-table/data-table.test.ts +54 -0
- package/components/molecules/nav-item/nav-item.css +12 -0
- package/components/molecules/nav-item/nav-item.md +11 -0
- package/components/molecules/table/table.md +3 -0
- package/components/organisms/drawer/drawer.css +59 -0
- package/components/organisms/drawer/drawer.md +69 -0
- package/components/organisms/drawer/drawer.test.ts +43 -0
- package/components/organisms/presentation/presentation.css +265 -0
- package/components/organisms/presentation/presentation.md +128 -0
- package/components/organisms/presentation/presentation.test.ts +75 -0
- package/components/organisms/side-rail/side-rail.css +40 -0
- package/components/organisms/side-rail/side-rail.md +30 -0
- package/components/organisms/topbar/topbar.css +30 -0
- package/components/organisms/topbar/topbar.md +22 -0
- package/package.json +1 -1
- package/scripts/drawer.js +113 -0
- package/scripts/drawer.test.ts +70 -0
- package/scripts/presentation.js +315 -0
- package/scripts/presentation.test.ts +77 -0
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/* grain/components/organisms/presentation: the PRESENTATION organism.
|
|
2
|
+
*
|
|
3
|
+
* A deck: full-bleed slides, staged fragments, a fit-to-box pass, an overview grid, present mode,
|
|
4
|
+
* a speaker-notes strip, a synced presenter window, and a print sheet. It knows nothing about any
|
|
5
|
+
* particular talk: the app owns the slides and every figure on them.
|
|
6
|
+
*
|
|
7
|
+
* Sizing is one number. `--u0` is derived from the deck's own box with container query units, and
|
|
8
|
+
* `--u` is that times `--fit`, the shrink factor the script computes per slide. Every size below is
|
|
9
|
+
* a multiple of `--u`, so a slide that is too tall scales as one piece instead of reflowing.
|
|
10
|
+
*
|
|
11
|
+
* Behaviour: grain/scripts/presentation.js. Opt a deck in with `data-deck` on the root; without
|
|
12
|
+
* the script the markup still renders whichever slide carries `data-current`, which is what the
|
|
13
|
+
* static export and a print run get.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
.presentation {
|
|
17
|
+
container-type: size;
|
|
18
|
+
/* tuned for a deck that owns the whole window. A deck docked in a pane can raise this. */
|
|
19
|
+
--u0: min(0.86cqw, 1.44cqh);
|
|
20
|
+
--fit: 1;
|
|
21
|
+
--u: calc(var(--u0) * var(--fit));
|
|
22
|
+
position: relative;
|
|
23
|
+
height: 100%;
|
|
24
|
+
min-height: 0;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
background: var(--color-bg);
|
|
27
|
+
color: var(--color-fg);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
.presentation[data-present] {
|
|
32
|
+
position: fixed; inset: 0; z-index: var(--z-presentation, 8000);
|
|
33
|
+
height: 100dvh;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
.presentation__slide {
|
|
38
|
+
position: absolute; inset: 0;
|
|
39
|
+
display: none;
|
|
40
|
+
flex-direction: column; justify-content: center;
|
|
41
|
+
|
|
42
|
+
padding: calc(var(--u) * 8) calc(var(--u) * 9) calc(var(--u) * 8);
|
|
43
|
+
box-sizing: border-box; overflow: hidden;
|
|
44
|
+
|
|
45
|
+
--u: calc(var(--u0) * var(--fit, 1));
|
|
46
|
+
}
|
|
47
|
+
.presentation__slide[data-current] { display: flex; }
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
.presentation__body { display: flex; flex-direction: column; width: 100%; min-width: 0; }
|
|
51
|
+
.presentation__slide[data-align="top"] { justify-content: flex-start; }
|
|
52
|
+
.presentation__slide[data-align="center"] { align-items: center; text-align: center; }
|
|
53
|
+
.presentation__slide[data-align="center"] .presentation__body { align-items: center; text-align: center; }
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
.presentation .slide-eyebrow {
|
|
58
|
+
font-size: calc(var(--u) * 1.55); letter-spacing: 0.14em; text-transform: uppercase;
|
|
59
|
+
color: var(--color-muted); margin: 0 0 calc(var(--u) * 3);
|
|
60
|
+
}
|
|
61
|
+
.presentation .slide-head {
|
|
62
|
+
font-size: calc(var(--u) * 6.2); line-height: var(--leading-tight); letter-spacing: -0.015em;
|
|
63
|
+
font-weight: var(--font-weight-regular); margin: 0; max-width: 20ch;
|
|
64
|
+
}
|
|
65
|
+
.presentation .slide-head[data-size="sm"] { font-size: calc(var(--u) * 4.4); max-width: 26ch; }
|
|
66
|
+
.presentation .slide-head[data-size="xl"] { font-size: calc(var(--u) * 8.4); max-width: 15ch; }
|
|
67
|
+
.presentation .slide-lede {
|
|
68
|
+
font-size: calc(var(--u) * 2.5); line-height: 1.45; color: var(--color-muted);
|
|
69
|
+
max-width: 46ch; margin: calc(var(--u) * 4) 0 0;
|
|
70
|
+
}
|
|
71
|
+
.presentation .slide-lede[data-tone="loud"] { color: var(--color-fg); }
|
|
72
|
+
.presentation .slide-rule { border: 0; border-top: var(--rule); margin: calc(var(--u) * 3.5) 0 0;
|
|
73
|
+
max-width: calc(var(--u) * 60); }
|
|
74
|
+
.presentation .slide-sig { font-size: calc(var(--u) * 1.9); color: var(--color-muted); margin: calc(var(--u) * 3) 0 0; }
|
|
75
|
+
.presentation .slide-sig b { color: var(--color-fg); font-weight: var(--font-weight-regular); }
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
.presentation .quote { font-size: calc(var(--u) * 6.6); line-height: 1.15; letter-spacing: -0.01em;
|
|
79
|
+
max-width: 22ch; margin: 0; text-wrap: balance; }
|
|
80
|
+
.presentation .quote-mark { display: block; font-size: calc(var(--u) * 2); color: var(--color-muted);
|
|
81
|
+
letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: calc(var(--u) * 3); }
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
.presentation .beats { list-style: none; margin: calc(var(--u) * 4) 0 0; padding: 0;
|
|
85
|
+
display: flex; flex-direction: column; gap: calc(var(--u) * 2.4); }
|
|
86
|
+
.presentation .beats li { font-size: calc(var(--u) * 3.4); line-height: 1.25; max-width: 30ch; }
|
|
87
|
+
.presentation .beats[data-size="sm"] li { font-size: calc(var(--u) * 2.6); }
|
|
88
|
+
|
|
89
|
+
.presentation .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
|
|
90
|
+
overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
.presentation__slide[data-current] { animation: pres-in 0.34s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
|
|
95
|
+
.presentation[data-dir="back"] .presentation__slide[data-current] { animation-name: pres-in-back; }
|
|
96
|
+
@keyframes pres-in { from { opacity: 0; transform: translateX(calc(var(--u) * 2.2)); } }
|
|
97
|
+
@keyframes pres-in-back { from { opacity: 0; transform: translateX(calc(var(--u) * -2.2)); } }
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
/* No type swap on arrival. An earlier build faded and re-faced every landing slide for a third of
|
|
101
|
+
a second, and from the back of a room that reads as a rendering glitch rather than a signal. The
|
|
102
|
+
script still sets [data-settling] on arrival, so a consumer that wants the effect can style it.
|
|
103
|
+
Deliberate grain, on [data-grade="grain"], is untouched and is the honest signal. */
|
|
104
|
+
|
|
105
|
+
.presentation__slide [data-grade="grain"] { --type-font: var(--font-grain); }
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
.presentation .frag { opacity: 0; transition: opacity 0.32s ease, transform 0.32s ease; }
|
|
110
|
+
.presentation .frag.is-on { opacity: 1; transform: none; }
|
|
111
|
+
.presentation .frag[data-frag="rise"], .presentation .frag:not([data-frag]) { transform: translateY(calc(var(--u) * 0.9)); }
|
|
112
|
+
.presentation .frag[data-frag="fade"] { transform: none; }
|
|
113
|
+
.presentation .frag[data-frag="grow"] { transform: scaleX(0.82); transform-origin: left center; }
|
|
114
|
+
.presentation .frag[data-frag="dim"].is-on { opacity: 0.55; }
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
.presentation [data-draw] {
|
|
118
|
+
stroke-dasharray: var(--draw-len, 1000);
|
|
119
|
+
stroke-dashoffset: var(--draw-len, 1000);
|
|
120
|
+
transition: stroke-dashoffset 0.9s cubic-bezier(0.4, 0, 0.2, 1);
|
|
121
|
+
}
|
|
122
|
+
.presentation [data-draw].is-drawn { stroke-dashoffset: 0; }
|
|
123
|
+
|
|
124
|
+
.presentation [data-lit] { opacity: 0; transition: opacity 0.4s ease 0.35s; }
|
|
125
|
+
.presentation [data-lit].is-drawn { opacity: 1; }
|
|
126
|
+
|
|
127
|
+
@media (prefers-reduced-motion: reduce) {
|
|
128
|
+
.presentation__slide[data-current] { animation: none; }
|
|
129
|
+
.presentation .frag, .presentation [data-draw], .presentation [data-lit] { transition: none; }
|
|
130
|
+
.presentation .frag { transform: none; }
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
.presentation__dots {
|
|
136
|
+
position: absolute; left: calc(var(--u) * 11.7); bottom: calc(var(--u) * 3.4);
|
|
137
|
+
display: flex; gap: calc(var(--u) * 0.85); align-items: center;
|
|
138
|
+
}
|
|
139
|
+
.presentation__dot {
|
|
140
|
+
width: calc(var(--u) * 0.62); height: calc(var(--u) * 0.62); border-radius: 50%;
|
|
141
|
+
background: var(--ink-faint); border: 0; padding: 0; cursor: pointer;
|
|
142
|
+
transition: transform 0.24s ease, background 0.24s ease;
|
|
143
|
+
}
|
|
144
|
+
.presentation__dot[data-seen] { background: var(--color-muted); }
|
|
145
|
+
.presentation__dot[data-now] { background: var(--color-accent); transform: scale(1.9); }
|
|
146
|
+
.presentation__dot:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
.presentation__bar {
|
|
150
|
+
position: absolute; left: calc(var(--u) * 11.7); right: calc(var(--u) * 11.7); top: calc(var(--u) * 3);
|
|
151
|
+
display: flex; justify-content: space-between; align-items: baseline;
|
|
152
|
+
gap: calc(var(--u) * 3); min-width: 0;
|
|
153
|
+
}
|
|
154
|
+
.presentation__meta, .presentation__hint, .presentation__legend {
|
|
155
|
+
margin: 0; font-size: calc(var(--u) * 1.4); color: var(--ink-faint);
|
|
156
|
+
display: flex; gap: calc(var(--u) * 2.2); align-items: baseline; min-width: 0;
|
|
157
|
+
}
|
|
158
|
+
.presentation__hint { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
|
|
159
|
+
.presentation__legend { justify-content: flex-end; flex-wrap: wrap; row-gap: calc(var(--u) * 0.6); }
|
|
160
|
+
|
|
161
|
+
.presentation__meta { flex: 0 0 auto; }
|
|
162
|
+
.presentation__hint kbd { font-family: var(--font-mono); font-size: 0.95em; }
|
|
163
|
+
.presentation__legend b, .presentation__meta b { font-weight: var(--font-weight-regular); color: var(--color-muted); }
|
|
164
|
+
.presentation__meta a { color: inherit; text-decoration: none; }
|
|
165
|
+
.presentation__meta a:hover { color: var(--color-muted); text-decoration: underline; }
|
|
166
|
+
|
|
167
|
+
.presentation__controls {
|
|
168
|
+
position: absolute; right: calc(var(--u) * 11.7); bottom: calc(var(--u) * 2.4);
|
|
169
|
+
display: flex; align-items: center; gap: calc(var(--u) * 0.8);
|
|
170
|
+
}
|
|
171
|
+
.presentation__ctl {
|
|
172
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
173
|
+
min-width: calc(var(--u) * 3.4); height: calc(var(--u) * 3.4); padding: 0 calc(var(--u) * 1.1);
|
|
174
|
+
background: transparent; border: 1px solid var(--color-line); border-radius: var(--radius-sm);
|
|
175
|
+
color: var(--color-muted); font: inherit; font-size: calc(var(--u) * 1.5); line-height: 1; cursor: pointer;
|
|
176
|
+
transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
|
|
177
|
+
}
|
|
178
|
+
.presentation__ctl:hover { border-color: var(--hairline); color: var(--color-fg); background: var(--paper-2); }
|
|
179
|
+
.presentation__ctl:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
|
|
180
|
+
.presentation__ctl[aria-pressed="true"] { border-color: var(--color-accent); color: var(--color-accent); }
|
|
181
|
+
.presentation__ctl:disabled { opacity: 0.3; cursor: default; }
|
|
182
|
+
.presentation__ctl[data-wide] { font-family: var(--font-mono); font-size: calc(var(--u) * 1.35);
|
|
183
|
+
letter-spacing: 0.04em; border-color: transparent; }
|
|
184
|
+
.presentation__ctl[data-wide]:hover { background: transparent; border-color: transparent; }
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
.presentation[data-present] .presentation__hint { display: none; }
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
[data-present-toggle] .on-present { display: none; }
|
|
191
|
+
.presentation[data-present] [data-present-toggle] .off-present { display: none; }
|
|
192
|
+
.presentation[data-present] [data-present-toggle] .on-present { display: inline; }
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
.presentation__grid {
|
|
196
|
+
position: absolute; inset: 0; overflow: auto; padding: calc(var(--u) * 4);
|
|
197
|
+
display: none; grid-template-columns: repeat(auto-fill, minmax(calc(var(--u) * 22), 1fr));
|
|
198
|
+
gap: calc(var(--u) * 2); background: var(--color-bg); align-content: start;
|
|
199
|
+
}
|
|
200
|
+
.presentation[data-view="grid"] .presentation__slide { display: none; }
|
|
201
|
+
.presentation[data-view="grid"] .presentation__grid { display: grid; }
|
|
202
|
+
.presentation__cell {
|
|
203
|
+
border: 1px solid var(--color-line); border-radius: var(--radius-md);
|
|
204
|
+
padding: calc(var(--u) * 1.8); text-align: left; background: transparent;
|
|
205
|
+
font: inherit; color: inherit; cursor: pointer; transition: border-color 0.2s ease;
|
|
206
|
+
}
|
|
207
|
+
.presentation__cell:hover { border-color: var(--hairline); }
|
|
208
|
+
.presentation__cell[data-now] { border-color: var(--color-accent); }
|
|
209
|
+
.presentation__n { font-family: var(--font-mono); font-size: calc(var(--u) * 1.3); color: var(--color-muted); }
|
|
210
|
+
.presentation__t { font-size: calc(var(--u) * 1.7); margin-top: calc(var(--u) * 0.8); line-height: 1.25; }
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
.presentation__notes {
|
|
215
|
+
position: absolute; left: 0; right: 0; bottom: 0; display: none;
|
|
216
|
+
background: var(--panel); border-top: 1px solid var(--color-line);
|
|
217
|
+
padding: calc(var(--u) * 2) calc(var(--u) * 11.7); max-height: 32cqh; overflow: auto;
|
|
218
|
+
}
|
|
219
|
+
.presentation[data-notes] .presentation__notes { display: block; }
|
|
220
|
+
.presentation__notes li { font-size: calc(var(--u) * 1.7); line-height: 1.5; color: var(--color-muted); }
|
|
221
|
+
.presentation__slide .slide-notes { display: none; }
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
.presenter { display: none; }
|
|
225
|
+
[data-mode="presenter"] .presenter {
|
|
226
|
+
display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto 1fr;
|
|
227
|
+
align-content: start; gap: 1.5rem; padding: 1.5rem; min-height: 100dvh;
|
|
228
|
+
box-sizing: border-box; font-size: 1rem;
|
|
229
|
+
}
|
|
230
|
+
.presenter__now { grid-column: 1 / -1; display: flex; justify-content: space-between;
|
|
231
|
+
align-items: baseline; border-bottom: var(--rule); padding-bottom: 0.75rem; }
|
|
232
|
+
.presenter__clock { font-family: var(--font-mono); font-size: 2.6rem; }
|
|
233
|
+
.presenter__clock[data-over] { color: var(--color-accent); }
|
|
234
|
+
.presenter__pos { font-family: var(--font-mono); color: var(--color-muted); }
|
|
235
|
+
.presenter__title { font-size: 1.8rem; margin: 0 0 0.75rem; }
|
|
236
|
+
.presenter__notes li { font-size: 1.15rem; line-height: 1.55; margin-bottom: 0.55rem; }
|
|
237
|
+
.presenter__next h3 { font-size: 0.95rem; letter-spacing: 0.12em; text-transform: uppercase;
|
|
238
|
+
color: var(--color-muted); margin: 0 0 0.5rem; }
|
|
239
|
+
.presenter__next p { color: var(--color-muted); }
|
|
240
|
+
.presenter__hint { grid-column: 1 / -1; margin: 0; font-size: 0.85rem; color: var(--ink-faint);
|
|
241
|
+
letter-spacing: 0.08em; text-transform: uppercase; }
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
@media print {
|
|
246
|
+
.presentation {
|
|
247
|
+
position: static; height: auto; overflow: visible; container-type: normal;
|
|
248
|
+
--u0: min(1.05vw, 1.75vh);
|
|
249
|
+
}
|
|
250
|
+
.presentation__dots, .presentation__meta, .presentation__hint, .presentation__legend,
|
|
251
|
+
.presentation__notes, .presentation__grid, .presentation__controls, .presentation__bar { display: none !important; }
|
|
252
|
+
.presentation__slide {
|
|
253
|
+
display: flex !important; position: relative; inset: auto;
|
|
254
|
+
width: 100%; height: 100vh; box-sizing: border-box;
|
|
255
|
+
|
|
256
|
+
padding: calc(var(--u) * 7) calc(var(--u) * 9);
|
|
257
|
+
page-break-after: always; break-after: page; animation: none !important;
|
|
258
|
+
}
|
|
259
|
+
.presentation__slide:last-of-type { page-break-after: auto; break-after: auto; }
|
|
260
|
+
.presentation .frag { opacity: 1 !important; transform: none !important; }
|
|
261
|
+
.presentation [data-draw] { stroke-dashoffset: 0 !important; }
|
|
262
|
+
.presentation [data-lit] { opacity: 1 !important; }
|
|
263
|
+
|
|
264
|
+
body::before { display: none !important; }
|
|
265
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Presentation
|
|
2
|
+
|
|
3
|
+
A **deck**. Full-bleed slides, staged fragments, an overview grid, present mode, a speaker-notes
|
|
4
|
+
strip, a second-window presenter view, and a print sheet that lands everything first.
|
|
5
|
+
|
|
6
|
+
It knows nothing about any particular talk. The organism owns *which slide is up and how far into
|
|
7
|
+
it we are*; the app owns the slides, the figures, and every animation on them. That split is the
|
|
8
|
+
whole design: one seam, no registry, no per-slide config.
|
|
9
|
+
|
|
10
|
+
CSS plus one island, `grain/scripts/presentation.js`. Load it and the markup below is live with no
|
|
11
|
+
per-page wiring.
|
|
12
|
+
|
|
13
|
+
## Markup
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<div class="presentation" data-present data-deck data-hash data-minutes="20" data-channel="my-talk">
|
|
17
|
+
|
|
18
|
+
<div class="presentation__bar">
|
|
19
|
+
<p class="presentation__hint">← → move · <kbd>D</kbd> light/dark · <kbd>.</kbd> blank</p>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<section class="presentation__slide" data-title="Title">
|
|
23
|
+
<p class="slide-eyebrow">An eyebrow</p>
|
|
24
|
+
<h1 class="slide-head" data-size="xl">The claim</h1>
|
|
25
|
+
<ul class="beats">
|
|
26
|
+
<li class="frag">Lands on the first press</li>
|
|
27
|
+
<li class="frag">Then this one</li>
|
|
28
|
+
</ul>
|
|
29
|
+
<ul class="slide-notes" hidden>
|
|
30
|
+
<li>What to say here. Never rendered on the slide.</li>
|
|
31
|
+
</ul>
|
|
32
|
+
</section>
|
|
33
|
+
|
|
34
|
+
<nav class="presentation__dots" data-dots aria-label="Slides"></nav>
|
|
35
|
+
<div class="presentation__controls">
|
|
36
|
+
<button class="presentation__ctl" type="button" data-ctl="prev" aria-label="Back">‹</button>
|
|
37
|
+
<span class="presentation__ctl" data-wide aria-hidden="true"><span data-pos>1 / 1</span></span>
|
|
38
|
+
<button class="presentation__ctl" type="button" data-ctl="next" aria-label="Forward">›</button>
|
|
39
|
+
<button class="presentation__ctl" type="button" data-ctl="grid" aria-pressed="false">⊞</button>
|
|
40
|
+
<button class="presentation__ctl" type="button" data-ctl="notes" aria-pressed="false">☰</button>
|
|
41
|
+
<button class="presentation__ctl" type="button" data-ctl="presenter">◫</button>
|
|
42
|
+
<button class="presentation__ctl" type="button" data-present-toggle>⤢</button>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="presentation__notes" data-inline-notes aria-live="polite"></div>
|
|
45
|
+
<div class="presentation__grid" data-grid></div>
|
|
46
|
+
</div>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
The dot strip and the overview grid are filled by the script from the slides themselves, so a deck
|
|
50
|
+
never maintains two lists that can disagree. `data-title` is what shows in both, and in the
|
|
51
|
+
presenter window.
|
|
52
|
+
|
|
53
|
+
The catalog renders this example flat rather than live, and that is the honest thing to do: a deck
|
|
54
|
+
sizes itself from its own box with `container-type: size` and lays its slides out absolutely, so
|
|
55
|
+
one dropped into a catalog panel collapses to nothing. Read the code, or open a real deck.
|
|
56
|
+
|
|
57
|
+
**Opt in with `data-deck`.** Without the script the markup still renders whichever slide carries
|
|
58
|
+
`data-current`, which is what a static export and a print run get.
|
|
59
|
+
|
|
60
|
+
## Sizing is one number
|
|
61
|
+
|
|
62
|
+
`--u0` comes from the deck's own box in container query units, and `--u` is `--u0 × --fit`. Every
|
|
63
|
+
size in the component is a multiple of `--u`.
|
|
64
|
+
|
|
65
|
+
`--fit` is the shrink factor the script measures per slide: it drops the factor until the slide's
|
|
66
|
+
body fits its box, so a dense slide scales as one piece instead of reflowing into a mess. Anything
|
|
67
|
+
marked `aria-expanded="false"` is measured **open**, so clicking a card on stage can never overflow
|
|
68
|
+
a slide that fit a moment ago.
|
|
69
|
+
|
|
70
|
+
Two consequences worth knowing. A slide sitting near `--fit: 0.6` is not a rendering bug, it is the
|
|
71
|
+
component telling you the slide carries two ideas and wants to be two slides. And fragments only
|
|
72
|
+
change opacity and transform, never layout, so one measurement per slide holds for every step.
|
|
73
|
+
|
|
74
|
+
## Fragments and figures
|
|
75
|
+
|
|
76
|
+
`.frag` starts hidden and lands on a press. `data-frag` picks how: `rise` (the default), `fade`,
|
|
77
|
+
`grow`, or `dim` for a beat that lands quieter than the ones above it.
|
|
78
|
+
|
|
79
|
+
Figures get two hooks that need no per-deck script. `[data-draw]` draws an SVG stroke in, using a
|
|
80
|
+
`--draw-len` set to the path length. `[data-lit]` fades an element up once its slide arrives, or
|
|
81
|
+
once its own fragment lands if it sits inside one.
|
|
82
|
+
|
|
83
|
+
Slides can also declare steps that no fragment represents, for an app-driven animation:
|
|
84
|
+
`data-steps="1"` adds a press that fires the seam without changing the markup.
|
|
85
|
+
|
|
86
|
+
## The seam
|
|
87
|
+
|
|
88
|
+
One event on the deck element, and it is the entire contract:
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
deck.addEventListener("presentation:slide", (e) => {
|
|
92
|
+
const { index, step, slide, title, entered, total } = e.detail;
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
`entered` is true on the first event for a slide and false on later steps within it, so an app can
|
|
97
|
+
start an animation once and advance a figure per step. A second event, `presentation:print`, fires
|
|
98
|
+
before printing so an app can land its own figures in their final state.
|
|
99
|
+
|
|
100
|
+
## Keys, and giving one back
|
|
101
|
+
|
|
102
|
+
Arrows and space move, `Home` and `End` jump, `O` opens the overview, `N` toggles notes, `P` opens
|
|
103
|
+
the presenter window, `F` presents, and `.` blanks the screen. A swipe is an arrow key.
|
|
104
|
+
|
|
105
|
+
A slide can claim a key for its own control with `data-cede="ArrowUp ArrowDown"`, and the deck
|
|
106
|
+
yields it while that slide is current. A guess marker the room drives with the up and down arrows
|
|
107
|
+
is the case this exists for.
|
|
108
|
+
|
|
109
|
+
## The presenter window
|
|
110
|
+
|
|
111
|
+
`P` opens the same page again with `?presenter=1`. It shows the current title, its notes, what is
|
|
112
|
+
next, and a clock that turns accent past `data-minutes`. The two windows stay in step over a
|
|
113
|
+
`BroadcastChannel` named by `data-channel`, and arrows pressed in the presenter window drive the
|
|
114
|
+
main one. The audience never sees it.
|
|
115
|
+
|
|
116
|
+
## Print
|
|
117
|
+
|
|
118
|
+
`Cmd+P` lands every fragment and every figure first, then lays one slide per page. The component
|
|
119
|
+
re-runs its fit pass under print rules, because print swaps `--u0` to viewport units and a deck
|
|
120
|
+
that skipped that step would print every slide at the screen's factor.
|
|
121
|
+
|
|
122
|
+
## Grade
|
|
123
|
+
|
|
124
|
+
A deck follows grain's grade mechanism like anything else: `data-grade="grain"` on a line the
|
|
125
|
+
machine drafted. The organism deliberately does **not** re-face type on arrival. An earlier build
|
|
126
|
+
did, and from the back of a room a third of a second of shifting letterforms reads as a glitch
|
|
127
|
+
rather than a signal. The script still sets `data-settling` while a slide lands, so a consumer that
|
|
128
|
+
wants the effect can style it.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// grain/components/organisms/presentation/presentation.test.ts — DRIFT GUARD for the deck's CSS.
|
|
2
|
+
//
|
|
3
|
+
// Scope, stated honestly: this package has no DOM in test, so these are grep-style contract guards
|
|
4
|
+
// in the drawer.test.ts mould. They catch an obligation being DELETED, which is the realistic
|
|
5
|
+
// regression here, not one being subtly wrong. Whether a slide actually fits its box on a
|
|
6
|
+
// projector is measured in a browser against a consumer, and no assertion in this file claims
|
|
7
|
+
// otherwise.
|
|
8
|
+
import { test, expect } from "bun:test";
|
|
9
|
+
import { readFileSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
|
|
12
|
+
const here = new URL(".", import.meta.url).pathname;
|
|
13
|
+
const css = readFileSync(join(here, "presentation.css"), "utf8");
|
|
14
|
+
const md = readFileSync(join(here, "presentation.md"), "utf8");
|
|
15
|
+
|
|
16
|
+
test("every size is a multiple of --u, so a dense slide scales as one piece", () => {
|
|
17
|
+
expect(css).toMatch(/--u:\s*calc\(var\(--u0\)\s*\*\s*var\(--fit/);
|
|
18
|
+
// a raw px or rem font-size inside a slide would survive the fit pass and break the scaling
|
|
19
|
+
const slideBlock = css.slice(css.indexOf(".presentation .slide-eyebrow"), css.indexOf(".presentation .sr-only"));
|
|
20
|
+
expect(slideBlock).not.toMatch(/font-size:\s*\d+(\.\d+)?(px|rem)/);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("the deck is its own container, or the container query units size against the page", () => {
|
|
24
|
+
expect(css).toMatch(/\.presentation\s*\{[^}]*container-type:\s*size/);
|
|
25
|
+
expect(css).toMatch(/--u0:\s*min\([\d.]+cqw,\s*[\d.]+cqh\)/);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
test("a slide with no JS still renders: display is driven by [data-current]", () => {
|
|
29
|
+
expect(css).toMatch(/\.presentation__slide\s*\{[^}]*display:\s*none/);
|
|
30
|
+
expect(css).toMatch(/\.presentation__slide\[data-current\]\s*\{\s*display:\s*flex/);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
test("fragments move opacity and transform only, never layout", () => {
|
|
34
|
+
const frag = css.match(/\.presentation \.frag\s*\{([^}]*)\}/);
|
|
35
|
+
expect(frag).not.toBeNull();
|
|
36
|
+
expect(frag![1]).toMatch(/transition:\s*opacity[^;]*transform/);
|
|
37
|
+
expect(frag![1]).not.toMatch(/display|height|margin|padding/);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("speaker notes never render on the slide itself", () => {
|
|
41
|
+
expect(css).toMatch(/\.presentation__slide \.slide-notes\s*\{\s*display:\s*none/);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("print lands the figures and re-derives the unit from the page, not the screen", () => {
|
|
45
|
+
const printBlock = css.slice(css.indexOf("@media print"));
|
|
46
|
+
expect(printBlock).toMatch(/--u0:\s*min\([\d.]+vw,\s*[\d.]+vh\)/);
|
|
47
|
+
expect(printBlock).toMatch(/\.presentation \.frag\s*\{\s*opacity:\s*1\s*!important/);
|
|
48
|
+
expect(printBlock).toMatch(/\[data-draw\]\s*\{\s*stroke-dashoffset:\s*0\s*!important/);
|
|
49
|
+
expect(printBlock).toMatch(/page-break-after:\s*always/);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("the chrome is hidden in print, so a printed deck is slides and nothing else", () => {
|
|
53
|
+
const printBlock = css.slice(css.indexOf("@media print"));
|
|
54
|
+
for (const part of ["__dots", "__controls", "__notes", "__grid", "__bar"]) {
|
|
55
|
+
expect(printBlock).toContain(`.presentation${part}`);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("arrival does not re-face type, and the .md says why", () => {
|
|
60
|
+
// a consumer may style [data-settling]; the component must not ship the swap itself
|
|
61
|
+
expect(css).not.toMatch(/\[data-settling\][^{]*\{[^}]*font-family/);
|
|
62
|
+
expect(md).toMatch(/data-settling/);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("the .md documents the one seam an app is allowed to use", () => {
|
|
66
|
+
expect(md).toMatch(/presentation:slide/);
|
|
67
|
+
expect(md).toMatch(/presentation:print/);
|
|
68
|
+
expect(md).toMatch(/entered/);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test("no em-dashes and no hardcoded colors, per the standards this package follows", () => {
|
|
72
|
+
expect(css).not.toContain("\u2014");
|
|
73
|
+
expect(md).not.toContain("\u2014");
|
|
74
|
+
expect(css).not.toMatch(/:\s*#[0-9a-fA-F]{3,8}\b/);
|
|
75
|
+
});
|
|
@@ -29,6 +29,40 @@
|
|
|
29
29
|
.side-rail__brand > b-icon { color: var(--color-accent); }
|
|
30
30
|
.side-rail__spacer { flex: 1 1 auto; }
|
|
31
31
|
|
|
32
|
+
/* ---- OPTIONAL: a section heading between runs of items — for a rail with more destinations
|
|
33
|
+
than a flat list reads well as. Not a `__group` (that's a collapsible <details>); this only
|
|
34
|
+
separates. Indented past the gutter so it aligns with the LABELS, not the glyph column. ---- */
|
|
35
|
+
.side-rail__label {
|
|
36
|
+
padding: var(--space-4) 0 var(--space-1) calc(var(--rail-icon-col, 2.5rem) + var(--space-2));
|
|
37
|
+
font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em;
|
|
38
|
+
color: var(--color-muted); white-space: nowrap;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/* ---- OPTIONAL: the foot — a mark plus two lines of identity, pinned under the spacer. Grain
|
|
42
|
+
ships the SHAPE only; who it names (an account, a workspace, "signed out") is the consumer's,
|
|
43
|
+
like the topbar's presence label. Same two-column grid as the brand, so the mark lands in the
|
|
44
|
+
gutter and the text lines up with every label above it. ---- */
|
|
45
|
+
.side-rail__foot {
|
|
46
|
+
display: grid; grid-template-columns: var(--rail-icon-col, 2.5rem) 1fr;
|
|
47
|
+
align-items: center; column-gap: var(--space-2);
|
|
48
|
+
margin-top: var(--space-2); padding-top: var(--space-3);
|
|
49
|
+
border-top: 1px solid var(--color-line); white-space: nowrap;
|
|
50
|
+
}
|
|
51
|
+
.side-rail__avatar {
|
|
52
|
+
width: 1.75rem; height: 1.75rem; border-radius: 50%; justify-self: center;
|
|
53
|
+
display: grid; place-items: center;
|
|
54
|
+
background: var(--color-accent-soft); color: var(--color-accent);
|
|
55
|
+
font-size: var(--text-xs); font-weight: var(--font-weight-semibold);
|
|
56
|
+
}
|
|
57
|
+
.side-rail__foot > b-icon, .side-rail__foot > .icon { justify-self: center; }
|
|
58
|
+
/* min-width:0 lets the ellipsis below actually fire — a grid item's default `auto` minimum
|
|
59
|
+
would let a long account name push the rail wider instead of truncating. */
|
|
60
|
+
.side-rail__who { min-width: 0; font-size: var(--text-xs); color: var(--color-muted); line-height: 1.2; }
|
|
61
|
+
.side-rail__who strong {
|
|
62
|
+
display: block; overflow: hidden; text-overflow: ellipsis;
|
|
63
|
+
font-size: var(--text-sm); font-weight: var(--font-weight-semibold); color: var(--color-fg);
|
|
64
|
+
}
|
|
65
|
+
|
|
32
66
|
/* ---- grouped nav — a collapsible section for nested navigation (e.g. a BREAD group over
|
|
33
67
|
BATCH / GRAIN / MILL). Native <details>/<summary>, no JS: the summary IS a nav-item, the
|
|
34
68
|
sub-items indent under it. Open/closed is the browser's; a rotating chevron shows state. ---- */
|
|
@@ -53,3 +87,9 @@
|
|
|
53
87
|
[data-rail-collapsed="true"] .side-rail__brand { grid-template-columns: var(--rail-icon-col, 2.5rem); }
|
|
54
88
|
[data-rail-collapsed="true"] .side-rail__group > summary .nav-item__chev { display: none; }
|
|
55
89
|
[data-rail-collapsed="true"] .side-rail__sub .nav-item { padding-left: 0; }
|
|
90
|
+
/* the optional pieces collapse the same way: text goes, glyphs stay. A section label is ONLY
|
|
91
|
+
text, so it goes entirely; the foot keeps its mark (the one thing still legible at 3.25rem). */
|
|
92
|
+
[data-rail-collapsed="true"] .side-rail__label { display: none; }
|
|
93
|
+
[data-rail-collapsed="true"] .side-rail__who { display: none; }
|
|
94
|
+
[data-rail-collapsed="true"] .nav-item__count { display: none; }
|
|
95
|
+
[data-rail-collapsed="true"] .side-rail__foot { grid-template-columns: var(--rail-icon-col, 2.5rem); }
|
|
@@ -22,3 +22,33 @@ icon column (see `activity-bar.md`).
|
|
|
22
22
|
<a class="nav-item"><b-icon sym="/assets/sprite.svg#settings"></b-icon><span class="nav-item__label">Settings</span></a>
|
|
23
23
|
</aside>
|
|
24
24
|
```
|
|
25
|
+
|
|
26
|
+
## Grouped, counted, and signed
|
|
27
|
+
|
|
28
|
+
Three optional pieces for a rail with more in it than a handful of destinations — a workspace
|
|
29
|
+
app rather than a site. All three collapse with the rail: the label goes entirely, the counts
|
|
30
|
+
go with the nav-item labels, and the foot keeps its mark and drops its text.
|
|
31
|
+
|
|
32
|
+
- `.side-rail__label` — a section heading between runs of items. Not a `.side-rail__group`
|
|
33
|
+
(that's a collapsible `<details>`); this only separates.
|
|
34
|
+
- `.nav-item__count` — how much is waiting in a destination (see `nav-item.md`). The value is
|
|
35
|
+
the consumer's to keep current.
|
|
36
|
+
- `.side-rail__foot` — a mark plus two lines of identity, pinned under the spacer.
|
|
37
|
+
**Persona-neutral:** grain ships the shape; who it names — an account, a workspace,
|
|
38
|
+
"signed out" — is the consumer's, exactly like the topbar's presence label.
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<aside class="side-rail" style="height:280px;border:1px solid var(--color-line)">
|
|
42
|
+
<div class="side-rail__brand"><b-icon sym="/assets/sprite.svg#spark"></b-icon><span>Grain</span></div>
|
|
43
|
+
<a class="nav-item"><b-icon sym="/assets/sprite.svg#loop"></b-icon><span class="nav-item__label">Home</span></a>
|
|
44
|
+
<span class="side-rail__label">Workspace</span>
|
|
45
|
+
<a class="nav-item" aria-current="page"><b-icon sym="/assets/sprite.svg#tasks"></b-icon><span class="nav-item__label">Tickets</span><span class="nav-item__count">12</span></a>
|
|
46
|
+
<a class="nav-item"><b-icon sym="/assets/sprite.svg#knowledge"></b-icon><span class="nav-item__label">Clients</span><span class="nav-item__count">3</span></a>
|
|
47
|
+
<div class="side-rail__spacer"></div>
|
|
48
|
+
<a class="nav-item"><b-icon sym="/assets/sprite.svg#settings"></b-icon><span class="nav-item__label">Settings</span></a>
|
|
49
|
+
<div class="side-rail__foot">
|
|
50
|
+
<span class="side-rail__avatar">TS</span>
|
|
51
|
+
<span class="side-rail__who"><strong>Local workspace</strong>no account</span>
|
|
52
|
+
</div>
|
|
53
|
+
</aside>
|
|
54
|
+
```
|
|
@@ -6,3 +6,33 @@
|
|
|
6
6
|
brand/presence text. See topbar.md. */
|
|
7
7
|
.topbar-ctl { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; padding: 0 var(--space-4); }
|
|
8
8
|
.presence { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--color-muted); font-size: var(--text-sm); }
|
|
9
|
+
|
|
10
|
+
/* ---- the LEFT slot: WHERE you are (a breadcrumb trail, a record title). Pairs with
|
|
11
|
+
`.topbar-ctl`'s `margin-left: auto` with no change to it — put both in the region and the
|
|
12
|
+
crumbs sit left, the controls right. `min-width: 0` so a long trail truncates instead of
|
|
13
|
+
pushing the control cluster off the bar. ---- */
|
|
14
|
+
.topbar-crumbs {
|
|
15
|
+
display: flex; align-items: center; gap: var(--space-2); min-width: 0;
|
|
16
|
+
padding: 0 var(--space-4); font-size: var(--text-sm); color: var(--color-muted);
|
|
17
|
+
}
|
|
18
|
+
.topbar-crumbs strong { color: var(--color-fg); font-weight: var(--font-weight-semibold); }
|
|
19
|
+
.topbar-crumbs a { color: var(--color-muted); }
|
|
20
|
+
.topbar-crumbs a:hover { color: var(--color-fg); }
|
|
21
|
+
|
|
22
|
+
/* ---- a search / filter box for the bar. GRAIN SHIPS THE BOX AND NOTHING ELSE: whether typing
|
|
23
|
+
in it filters rows on the page, queries a server, or opens a palette is the consumer's, wired
|
|
24
|
+
to the input. That split is deliberate — a component that LOOKS like it searches but ships no
|
|
25
|
+
search is a contract that fails silently (CLAUDE.md lesson 3), so the promise here is only
|
|
26
|
+
"an input that belongs in a topbar". ---- */
|
|
27
|
+
.topbar-search { position: relative; flex: 1 1 auto; max-width: 22rem; align-self: center; }
|
|
28
|
+
.topbar-search input {
|
|
29
|
+
width: 100%; font: inherit; font-size: var(--text-sm);
|
|
30
|
+
padding: var(--space-2) var(--space-3) var(--space-2) 1.9rem;
|
|
31
|
+
border: 1px solid var(--color-line); border-radius: var(--radius-md);
|
|
32
|
+
background: var(--color-bg); color: var(--color-fg);
|
|
33
|
+
}
|
|
34
|
+
.topbar-search input:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
|
|
35
|
+
.topbar-search::before {
|
|
36
|
+
content: "⌕"; position: absolute; left: var(--space-2); top: 50%; transform: translateY(-50%);
|
|
37
|
+
color: var(--color-muted); pointer-events: none;
|
|
38
|
+
}
|
|
@@ -24,3 +24,25 @@ CSS-only (no `.html`): compose the markup in your frame.
|
|
|
24
24
|
|
|
25
25
|
Persona-neutral: the presence label ("online", a product name, "Acme's assistant") is the consumer's — the
|
|
26
26
|
primitive ships no persona. The flavor list the cycle rotates is declared on `<html data-themes="…">`.
|
|
27
|
+
|
|
28
|
+
## The left slot, and a search box
|
|
29
|
+
|
|
30
|
+
A workspace bar usually says **where you are** on the left and **what you can do here** on the
|
|
31
|
+
right. `.topbar-crumbs` is that left slot; it needs no coordination with `.topbar-ctl`, which
|
|
32
|
+
pushes itself right on its own. A long trail truncates rather than shoving the controls off
|
|
33
|
+
the bar.
|
|
34
|
+
|
|
35
|
+
`.topbar-search` is the optional box between them. **Grain ships the box and nothing else** —
|
|
36
|
+
whether typing filters rows already on the page, queries a server, or opens a palette is yours
|
|
37
|
+
to wire to the input. A box that looks like it searches but ships no search is a contract that
|
|
38
|
+
fails silently, so the promise here is only "an input that belongs in a topbar".
|
|
39
|
+
|
|
40
|
+
```html
|
|
41
|
+
<header class="app-shell__topbar">
|
|
42
|
+
<span class="topbar-crumbs"><a href="/tickets">Tickets</a> / <strong>Annual Review</strong></span>
|
|
43
|
+
<div class="topbar-search"><input type="search" placeholder="Filter…" aria-label="Filter"></div>
|
|
44
|
+
<div class="topbar-ctl">
|
|
45
|
+
<button class="icon-btn" data-variant="ghost" data-toggle-scheme aria-label="Toggle light / dark">◐</button>
|
|
46
|
+
</div>
|
|
47
|
+
</header>
|
|
48
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tjakoen/grain",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "GRAIN — an AI-interaction design system where every surface is operable by both a human and an AI through one shared vocabulary.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|