@tjakoen/grain 0.1.30 → 0.1.32
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.
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/* organisms/date-rail: dates for a note that tells a dated story.
|
|
2
|
+
Two states, both CSS only, with no scroll JS and no animation (so nothing for
|
|
3
|
+
prefers-reduced-motion to switch off). Tokens only, no shadows.
|
|
4
|
+
|
|
5
|
+
Folded (the default): each date is a small label above its heading with a hairline under it.
|
|
6
|
+
It is sticky at the top of the column inside its own section, so it stays on screen while the
|
|
7
|
+
section does and the next section's label pushes it off.
|
|
8
|
+
|
|
9
|
+
In the margin: when the page's main column is wide enough, each date hangs in the left margin
|
|
10
|
+
beside its section, sticky, with a hairline between the dates and the prose. The note keeps its
|
|
11
|
+
normal reading measure, because the rail borrows the margin instead of a column.
|
|
12
|
+
|
|
13
|
+
Which state applies is decided by the width of the page's main column, not the viewport: a note
|
|
14
|
+
in a narrow pane on a wide screen has no margin to spare. A page opts in by naming that column
|
|
15
|
+
as a size container called "page". Without one the rail stays folded, which always fits. */
|
|
16
|
+
.date-rail {
|
|
17
|
+
--date-rail-width: 5rem;
|
|
18
|
+
--date-rail-gap: var(--space-5);
|
|
19
|
+
--date-rail-top: var(--space-6);
|
|
20
|
+
}
|
|
21
|
+
.date-rail__section { position: relative; }
|
|
22
|
+
.date-rail__date {
|
|
23
|
+
position: sticky;
|
|
24
|
+
top: 0;
|
|
25
|
+
z-index: 1;
|
|
26
|
+
margin: 0 0 var(--space-2);
|
|
27
|
+
padding-block: var(--space-2);
|
|
28
|
+
border-bottom: 1px solid var(--color-line);
|
|
29
|
+
font-size: var(--text-xs);
|
|
30
|
+
font-weight: var(--font-weight-semibold);
|
|
31
|
+
font-variant-numeric: tabular-nums;
|
|
32
|
+
text-transform: uppercase;
|
|
33
|
+
letter-spacing: 0.08em;
|
|
34
|
+
color: var(--color-muted);
|
|
35
|
+
background: var(--color-bg);
|
|
36
|
+
}
|
|
37
|
+
.date-rail__date:empty { display: none; }
|
|
38
|
+
.date-rail__body { min-width: 0; }
|
|
39
|
+
.date-rail__body > h2:first-child { margin-top: var(--space-1); }
|
|
40
|
+
.date-rail__body > p, .date-rail__body > ul, .date-rail__body > ol, .date-rail__body > blockquote {
|
|
41
|
+
line-height: var(--leading-relaxed);
|
|
42
|
+
}
|
|
43
|
+
.date-rail__section + .date-rail__section { padding-top: var(--space-4); }
|
|
44
|
+
|
|
45
|
+
@container page (min-width: 54rem) {
|
|
46
|
+
/* The hairline sits halfway between the dates and the prose. */
|
|
47
|
+
.date-rail__section::before {
|
|
48
|
+
content: "";
|
|
49
|
+
position: absolute;
|
|
50
|
+
inset-block: 0;
|
|
51
|
+
inset-inline-start: calc(-0.5 * var(--date-rail-gap));
|
|
52
|
+
border-inline-start: 1px solid var(--color-line);
|
|
53
|
+
}
|
|
54
|
+
/* A zero-height float, pulled out into the margin, still sticks within its section. */
|
|
55
|
+
.date-rail__date,
|
|
56
|
+
.date-rail__date:empty {
|
|
57
|
+
display: block;
|
|
58
|
+
position: sticky;
|
|
59
|
+
top: var(--date-rail-top);
|
|
60
|
+
float: inline-start;
|
|
61
|
+
width: var(--date-rail-width);
|
|
62
|
+
height: 0;
|
|
63
|
+
margin: 0;
|
|
64
|
+
margin-inline-start: calc(-1 * (var(--date-rail-width) + var(--date-rail-gap)));
|
|
65
|
+
padding: 0;
|
|
66
|
+
overflow: visible;
|
|
67
|
+
border-bottom: 0;
|
|
68
|
+
background: none;
|
|
69
|
+
text-align: end;
|
|
70
|
+
text-transform: none;
|
|
71
|
+
letter-spacing: 0;
|
|
72
|
+
line-height: 1.3;
|
|
73
|
+
color: var(--color-fg);
|
|
74
|
+
}
|
|
75
|
+
.date-rail__date time { display: block; padding-top: var(--space-3); }
|
|
76
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Date rail
|
|
2
|
+
|
|
3
|
+
Dates for a note that tells a dated story. When the page has room, each section's date hangs in the left margin beside it, with a hairline between the dates and the prose, and the date of the section you are reading stays pinned near the top while you scroll through it. The note keeps its normal reading measure: the rail borrows the margin, never a column of the text.
|
|
4
|
+
|
|
5
|
+
Without room in the margin, on a phone or in a narrow pane, each date folds into a small uppercase label above its heading with a hairline under it. The label is sticky at the top of the column while its section is on screen, and the next section's label pushes it off. An empty label is hidden.
|
|
6
|
+
|
|
7
|
+
Both states are plain CSS. Each date is `position: sticky` inside its own section, so the section's end is what releases it. There is no scroll listener and no animation, which is also why there is nothing to switch off under reduced motion. It reads only palette tokens and draws no shadow, so it follows light and dark with the theme.
|
|
8
|
+
|
|
9
|
+
**Parent context:** the margin state is decided by the width of the page's main column, not the viewport, so a page opts in by naming that column as a size container called `page`, for example `.app-shell__main { container: page / inline-size; }`. The dates hang in the margin once that column is at least 54rem wide. A page with no `page` container always gets the folded labels, which fit anywhere. Sticky also needs a scrolling ancestor with no `overflow: hidden` between it and the rail. Tune the rail with `--date-rail-width` (5rem), `--date-rail-gap` (`--space-5`) and `--date-rail-top` on `.date-rail`. CSS-only (no `.html`).
|
|
10
|
+
|
|
11
|
+
## Authoring it from MILL
|
|
12
|
+
|
|
13
|
+
Opt a note in with `layout: timeline` in its frontmatter, then open each H2 with its date and a spaced middle dot, as in `## Aug 18 · Then it had to keep score`. The marker is plain Markdown, so the file still reads sensibly anywhere else, where the date simply shows as part of the heading.
|
|
14
|
+
|
|
15
|
+
```html flat
|
|
16
|
+
---
|
|
17
|
+
title: The reviewer that learned to be wrong
|
|
18
|
+
layout: timeline
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
An opening paragraph stays above the rail.
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
MILL's default layout then wraps every H2 and the prose under it in a rail section, adds `data-layout="timeline"` to the note, and slugs each heading from its text without the date, so an anchor does not move when a date is corrected. An H2 without a marker still gets a section, with an empty rail slot. A consumer with its own layout can call `dateRailBody(body)` from `@tjakoen/mill` to get the same markup.
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
The box below names itself the page container, so it shows the margin state when the catalog is wide and folds when it is not.
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<div style="container:page / inline-size;height:22rem;overflow:auto;border:1px solid var(--color-line);padding:var(--space-4) var(--space-4) var(--space-4) 7rem">
|
|
32
|
+
<article class="note" data-layout="timeline">
|
|
33
|
+
<p>An opening paragraph stays above the rail and reads at full width.</p>
|
|
34
|
+
<div class="date-rail">
|
|
35
|
+
<section class="date-rail__section">
|
|
36
|
+
<p class="date-rail__date"><time>Aug 18</time></p>
|
|
37
|
+
<div class="date-rail__body">
|
|
38
|
+
<h2 id="then-it-had-to-keep-score">Then it had to keep score</h2>
|
|
39
|
+
<p>The first version only commented. It had no way to know whether a comment had landed, so it could not tell a good finding from noise.</p>
|
|
40
|
+
<p>Keeping score meant writing down every finding and what the author did with it.</p>
|
|
41
|
+
<p>Scroll on and the date beside this section stays pinned until the section ends.</p>
|
|
42
|
+
</div>
|
|
43
|
+
</section>
|
|
44
|
+
<section class="date-rail__section">
|
|
45
|
+
<p class="date-rail__date"><time>Sep 17</time></p>
|
|
46
|
+
<div class="date-rail__body">
|
|
47
|
+
<h2 id="the-talk-was-the-old-version">The talk was the old version</h2>
|
|
48
|
+
<p>By the time it was presented, the thing on the slides had already been replaced.</p>
|
|
49
|
+
<p>The next date takes over as this section reaches the top.</p>
|
|
50
|
+
</div>
|
|
51
|
+
</section>
|
|
52
|
+
<section class="date-rail__section">
|
|
53
|
+
<p class="date-rail__date"><time>Nov 2</time></p>
|
|
54
|
+
<div class="date-rail__body">
|
|
55
|
+
<h2 id="where-it-stands">Where it stands</h2>
|
|
56
|
+
<p>A short closing section, so the last handover is visible too.</p>
|
|
57
|
+
</div>
|
|
58
|
+
</section>
|
|
59
|
+
</div>
|
|
60
|
+
</article>
|
|
61
|
+
</div>
|
|
62
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tjakoen/grain",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
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",
|