@tjakoen/grain 0.1.20 → 0.1.21
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/assets/doc-sample.pdf +34 -0
- package/components/doc-links.test.ts +1 -0
- package/components/molecules/attachment/attachment.css +71 -0
- package/components/molecules/attachment/attachment.md +40 -0
- package/components/molecules/doc-frame/doc-frame.css +52 -0
- package/components/molecules/doc-frame/doc-frame.md +51 -0
- package/package.json +1 -1
- package/styles/vars-defined.test.ts +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
%PDF-1.4
|
|
2
|
+
1 0 obj
|
|
3
|
+
<< /Type /Catalog /Pages 2 0 R >>
|
|
4
|
+
endobj
|
|
5
|
+
2 0 obj
|
|
6
|
+
<< /Type /Pages /Kids [3 0 R] /Count 1 >>
|
|
7
|
+
endobj
|
|
8
|
+
3 0 obj
|
|
9
|
+
<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /Font << /F1 5 0 R >> >> /Contents 4 0 R >>
|
|
10
|
+
endobj
|
|
11
|
+
4 0 obj
|
|
12
|
+
<< /Length 209 >>
|
|
13
|
+
stream
|
|
14
|
+
BT /F1 24 Tf 72 680 Td (Sample document) Tj ET
|
|
15
|
+
BT /F1 12 Tf 72 650 Td (A one page PDF, shipped with GRAIN so the doc-frame) Tj ET
|
|
16
|
+
BT /F1 12 Tf 72 632 Td (example in the catalog renders a real document.) Tj ET
|
|
17
|
+
endstream
|
|
18
|
+
endobj
|
|
19
|
+
5 0 obj
|
|
20
|
+
<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>
|
|
21
|
+
endobj
|
|
22
|
+
xref
|
|
23
|
+
0 6
|
|
24
|
+
0000000000 65535 f
|
|
25
|
+
0000000009 00000 n
|
|
26
|
+
0000000058 00000 n
|
|
27
|
+
0000000115 00000 n
|
|
28
|
+
0000000241 00000 n
|
|
29
|
+
0000000500 00000 n
|
|
30
|
+
trailer
|
|
31
|
+
<< /Size 6 /Root 1 0 R >>
|
|
32
|
+
startxref
|
|
33
|
+
570
|
|
34
|
+
%%EOF
|
|
@@ -23,6 +23,7 @@ const here = new URL(".", import.meta.url).pathname;
|
|
|
23
23
|
// resolve for anyone who mounted the package the way the README says to.
|
|
24
24
|
const SHIPPED_ASSETS = new Set([
|
|
25
25
|
"/assets/figure-sample.svg",
|
|
26
|
+
"/assets/doc-sample.pdf",
|
|
26
27
|
"/scripts/terminal.js",
|
|
27
28
|
]);
|
|
28
29
|
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/* molecules/attachment — a document hanging off a page: a deck, a paper, a slide set. CSS-only
|
|
2
|
+
(CONVENTIONS §4), composed by hand, nothing data-binds it.
|
|
3
|
+
|
|
4
|
+
The shape is deliberately quiet and horizontal. An attachment is not the page's content, it is
|
|
5
|
+
the thing the page is about, offered on the way in — so it announces itself in one row near the
|
|
6
|
+
top and then gets out of the way. That is the whole reason it is not a media-card: a poster-sized
|
|
7
|
+
tile at the top of a note reads as the subject rather than the appendix.
|
|
8
|
+
|
|
9
|
+
The whole row is the link. Composed as an <a> with <span> children, so every child that must sit
|
|
10
|
+
on its own line declares display, because a <span> inside an <a> does not get one for free. Owns
|
|
11
|
+
no outer margin: where an attachment sits is the consumer's layout decision. */
|
|
12
|
+
.attachment {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: var(--space-4);
|
|
17
|
+
padding: var(--space-3) var(--space-4);
|
|
18
|
+
border: 1px solid var(--color-line);
|
|
19
|
+
border-radius: var(--radius-md);
|
|
20
|
+
text-decoration: none;
|
|
21
|
+
color: var(--color-fg);
|
|
22
|
+
transition: background-color 0.15s, border-color 0.15s;
|
|
23
|
+
}
|
|
24
|
+
.attachment:hover { background: var(--paper-2); border-color: var(--ink); }
|
|
25
|
+
|
|
26
|
+
/* the kind chip: PDF, DECK, SLIDES. Monospace and small, so it reads as a file type rather than
|
|
27
|
+
a heading, and fixed-width enough that a row of attachments lines up down the left. */
|
|
28
|
+
.attachment__kind {
|
|
29
|
+
flex: none;
|
|
30
|
+
min-width: 3.5rem;
|
|
31
|
+
padding: var(--space-1) var(--space-2);
|
|
32
|
+
border: 1px solid var(--color-line);
|
|
33
|
+
border-radius: var(--radius-sm);
|
|
34
|
+
font-family: var(--font-mono);
|
|
35
|
+
font-size: var(--text-xs);
|
|
36
|
+
text-transform: uppercase;
|
|
37
|
+
letter-spacing: .04em;
|
|
38
|
+
text-align: center;
|
|
39
|
+
color: var(--color-muted);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.attachment__body { flex: 1 1 12rem; min-width: 10rem; }
|
|
43
|
+
.attachment__title { display: block; font-size: var(--text-base); overflow-wrap: anywhere; }
|
|
44
|
+
.attachment__meta {
|
|
45
|
+
display: block;
|
|
46
|
+
margin-top: var(--space-1);
|
|
47
|
+
font-size: var(--text-xs);
|
|
48
|
+
color: var(--color-muted);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* the affordance on the right: says what the click does. Hidden on narrow screens, where the row
|
|
52
|
+
is obviously tappable and the words cost more than they carry.
|
|
53
|
+
|
|
54
|
+
The row WRAPS rather than squeezing (flex-wrap above, and a 12rem basis on the body). Without
|
|
55
|
+
that, a narrow container — the component catalog's preview column is the one that caught it —
|
|
56
|
+
crushes the title to one word per line while the chip and this label sit comfortably beside it.
|
|
57
|
+
A viewport media query cannot fix that: the viewport is wide, the box is not. */
|
|
58
|
+
.attachment__action {
|
|
59
|
+
flex: none;
|
|
60
|
+
font-size: var(--text-sm);
|
|
61
|
+
color: var(--color-muted);
|
|
62
|
+
}
|
|
63
|
+
.attachment:hover .attachment__action { color: var(--color-fg); }
|
|
64
|
+
@media (max-width: 32rem) {
|
|
65
|
+
.attachment__action { display: none; }
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* ---- AI / in-transit: an attachment the AI is still producing wears the dashed terminal edge,
|
|
69
|
+
the same vocabulary card, badge and field use. */
|
|
70
|
+
.attachment[data-commit="pending"],
|
|
71
|
+
[data-grade="grain"] .attachment { border-style: dashed; border-color: var(--ink); }
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Attachment
|
|
2
|
+
|
|
3
|
+
A document hanging off a page: a deck, a paper, a slide set. One quiet horizontal row, near the top,
|
|
4
|
+
saying what is attached and what opening it costs. Composed by hand, so nothing data-binds it.
|
|
5
|
+
|
|
6
|
+
It is deliberately **not** a `media-card`. A poster-sized tile at the top of a note reads as the
|
|
7
|
+
subject of the page; an attachment is the thing the page is *about*, offered on the way in. It
|
|
8
|
+
announces itself in one row and gets out of the way.
|
|
9
|
+
|
|
10
|
+
The whole row is the link. Children are `<span>`s inside an `<a>`, so anything that must sit on its
|
|
11
|
+
own line declares `display` (a `<span>` in an `<a>` does not get one for free). The component owns no
|
|
12
|
+
outer margin: where it sits is the consumer's layout decision.
|
|
13
|
+
|
|
14
|
+
## Attachment
|
|
15
|
+
```html
|
|
16
|
+
<a class="attachment" href="#gallery">
|
|
17
|
+
<span class="attachment__kind">PDF</span>
|
|
18
|
+
<span class="attachment__body">
|
|
19
|
+
<span class="attachment__title">Beyond Limits, the ideation workshop</span>
|
|
20
|
+
<span class="attachment__meta">32 slides · 2.5 MB · opens in a tab here</span>
|
|
21
|
+
</span>
|
|
22
|
+
<span class="attachment__action">Open →</span>
|
|
23
|
+
</a>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## A talk that lives on the site
|
|
27
|
+
```html
|
|
28
|
+
<a class="attachment" href="/notes/ten-times-zero">
|
|
29
|
+
<span class="attachment__kind">Talk</span>
|
|
30
|
+
<span class="attachment__body">
|
|
31
|
+
<span class="attachment__title">Ten times zero</span>
|
|
32
|
+
<span class="attachment__meta">28 slides · runs in the browser</span>
|
|
33
|
+
</span>
|
|
34
|
+
<span class="attachment__action">Open →</span>
|
|
35
|
+
</a>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
**Write the meta line as a cost, not a boast.** Page count, size, and where it opens are the three
|
|
39
|
+
things someone weighs before clicking. `--space` and type come from the tokens; the only per-use knob
|
|
40
|
+
is the kind chip's text.
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* molecules/doc-frame — a document rendered INSIDE the page instead of replacing it. CSS-only
|
|
2
|
+
(CONVENTIONS §4), composed by hand, nothing data-binds it.
|
|
3
|
+
|
|
4
|
+
Why it exists: a link straight to a PDF hands the tab to the browser's viewer and the site is
|
|
5
|
+
gone, chrome and all. Pointed at a route that composes this, the document becomes an ordinary
|
|
6
|
+
page, which means it becomes an ordinary open tab (scripts/tabs.js projects visited paths), which
|
|
7
|
+
means the reader can close it and still be where they were.
|
|
8
|
+
|
|
9
|
+
<object> and not <iframe>: same element, better failure. A browser that cannot render the type
|
|
10
|
+
inline renders the element's CHILDREN instead, so the fallback is markup rather than a script
|
|
11
|
+
sniffing for support. Same origin only — this is for documents the site itself serves, and it is
|
|
12
|
+
emphatically not a hole for third-party embeds.
|
|
13
|
+
|
|
14
|
+
The escape hatch below the frame is NOT redundant with that fallback, and this is the part worth
|
|
15
|
+
remembering: iOS Safari neither renders a multi-page PDF inline nor triggers the fallback. It
|
|
16
|
+
draws page one in a dead box and stops. So the direct link is always visible, for everybody.
|
|
17
|
+
|
|
18
|
+
Height is a knob (--doc-frame-height) because a slide deck and a two-column paper want different
|
|
19
|
+
boxes; the default is most of the viewport, floored so a short window still shows a page. */
|
|
20
|
+
.doc-frame { margin: 0; }
|
|
21
|
+
|
|
22
|
+
.doc-frame__object {
|
|
23
|
+
display: block;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: var(--doc-frame-height, max(28rem, 78vh));
|
|
26
|
+
border: 1px solid var(--color-line);
|
|
27
|
+
border-radius: var(--radius-md);
|
|
28
|
+
background: var(--paper-2);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/* the <object>'s own children: shown only when the browser refuses the document inline */
|
|
32
|
+
.doc-frame__fallback {
|
|
33
|
+
margin: 0;
|
|
34
|
+
padding: var(--space-6);
|
|
35
|
+
color: var(--color-muted);
|
|
36
|
+
font-size: var(--text-sm);
|
|
37
|
+
line-height: var(--leading-relaxed);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* always visible, under the frame: the plain link out, plus whatever the consumer puts beside it */
|
|
41
|
+
.doc-frame__escape {
|
|
42
|
+
display: flex;
|
|
43
|
+
flex-wrap: wrap;
|
|
44
|
+
align-items: baseline;
|
|
45
|
+
gap: var(--space-3);
|
|
46
|
+
margin-top: var(--space-3);
|
|
47
|
+
font-size: var(--text-sm);
|
|
48
|
+
color: var(--color-muted);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.doc-frame[data-commit="pending"] .doc-frame__object,
|
|
52
|
+
[data-grade="grain"] .doc-frame__object { border-style: dashed; border-color: var(--ink); }
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Doc frame
|
|
2
|
+
|
|
3
|
+
A document rendered **inside** the page instead of replacing it. Point a route at one and a PDF
|
|
4
|
+
becomes an ordinary page, which makes it an ordinary open tab (`scripts/tabs.js` projects visited
|
|
5
|
+
paths), which means the reader can close it and still be where they were. A bare link to a `.pdf`
|
|
6
|
+
hands the tab to the browser's viewer and the site is gone, chrome and all.
|
|
7
|
+
|
|
8
|
+
Composed by hand, so nothing data-binds it. **Same-origin documents only.** This is for files the
|
|
9
|
+
site itself serves; it is not a hole for third-party embeds.
|
|
10
|
+
|
|
11
|
+
`<object>` rather than `<iframe>` for one reason: a browser that cannot render the type inline
|
|
12
|
+
renders the element's **children** instead, so the fallback is markup and not a script sniffing for
|
|
13
|
+
support.
|
|
14
|
+
|
|
15
|
+
## Doc frame
|
|
16
|
+
```html
|
|
17
|
+
<figure class="doc-frame">
|
|
18
|
+
<object class="doc-frame__object" data="/assets/doc-sample.pdf" type="application/pdf"
|
|
19
|
+
aria-label="Sample document, rendered in the page">
|
|
20
|
+
<p class="doc-frame__fallback">
|
|
21
|
+
This browser will not display the document inline. Open it directly instead.
|
|
22
|
+
</p>
|
|
23
|
+
</object>
|
|
24
|
+
<figcaption class="doc-frame__escape">
|
|
25
|
+
<a href="/assets/doc-sample.pdf">Open the file directly</a>
|
|
26
|
+
<span>1 page · 753 bytes</span>
|
|
27
|
+
</figcaption>
|
|
28
|
+
</figure>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## The escape hatch is not optional
|
|
32
|
+
|
|
33
|
+
The `<figcaption>` link is **not** redundant with the `<object>` fallback, and this is the part worth
|
|
34
|
+
remembering when a future change makes it look like clutter: **iOS Safari neither renders a
|
|
35
|
+
multi-page PDF inline nor triggers the fallback.** It draws page one in a dead box and stops. Nothing
|
|
36
|
+
in the markup can detect that, so the direct link stays visible for everybody rather than being
|
|
37
|
+
hidden behind a fallback that never fires.
|
|
38
|
+
|
|
39
|
+
## Height
|
|
40
|
+
|
|
41
|
+
`--doc-frame-height` (default `max(28rem, 78vh)`) sets the box, because a slide deck and a
|
|
42
|
+
two-column paper want different ones. Set it on the `.doc-frame`.
|
|
43
|
+
|
|
44
|
+
```html
|
|
45
|
+
<figure class="doc-frame" style="--doc-frame-height: 32rem;">
|
|
46
|
+
<object class="doc-frame__object" data="/assets/doc-sample.pdf" type="application/pdf"
|
|
47
|
+
aria-label="Sample document in a shorter frame">
|
|
48
|
+
<p class="doc-frame__fallback">This browser will not display the document inline.</p>
|
|
49
|
+
</object>
|
|
50
|
+
</figure>
|
|
51
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tjakoen/grain",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.21",
|
|
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",
|
|
@@ -58,6 +58,7 @@ const EXTERNALLY_SET = new Map<string, string>([
|
|
|
58
58
|
["--gallery-min", "instance knob: components/molecules/gallery/gallery.md:8,48"],
|
|
59
59
|
["--gallery-ratio", "instance knob: components/molecules/gallery/gallery.md:8,48"],
|
|
60
60
|
["--media-ratio", "instance knob: components/molecules/media-card/media-card.md:6,76"],
|
|
61
|
+
["--doc-frame-height", "instance knob: components/molecules/doc-frame/doc-frame.md:47"],
|
|
61
62
|
["--rail-icon-col", "instance knob: components/molecules/nav-item/nav-item.md:4"],
|
|
62
63
|
["--draw-len", "instance knob: components/organisms/presentation/presentation.md:82"],
|
|
63
64
|
]);
|