@tjakoen/grain 0.1.31 → 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.
@@ -1,67 +1,76 @@
1
- /* organisms/date-rail: a left-hand rail of dates for a note that tells a dated story.
2
- Each .date-rail__section pairs a date with a stretch of prose. The date is position: sticky
3
- inside its own section, so it holds at the top while the reader is in that section and is
4
- carried off by the section's end, which is exactly when the next date arrives. No scroll JS:
5
- the handover is the browser's containing-block rule, nothing more.
6
- No transitions or animation, so there is nothing for prefers-reduced-motion to switch off.
7
- Tokens only, no shadows: the rail is one hairline in --color-line. */
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. */
8
16
  .date-rail {
9
- --date-rail-width: 7.5rem;
17
+ --date-rail-width: 5rem;
18
+ --date-rail-gap: var(--space-5);
10
19
  --date-rail-top: var(--space-6);
11
- position: relative;
12
- }
13
- /* The hairline runs the full height of the rail, behind every section, so the bar reads as one
14
- continuous line rather than a stack of segments. */
15
- .date-rail::before {
16
- content: "";
17
- position: absolute;
18
- inset-block: 0;
19
- inset-inline-start: calc(var(--date-rail-width) - 1px);
20
- border-inline-start: 1px solid var(--color-line);
21
- }
22
- .date-rail__section {
23
- display: grid;
24
- grid-template-columns: var(--date-rail-width) minmax(0, 1fr);
25
- column-gap: var(--space-6);
26
20
  }
21
+ .date-rail__section { position: relative; }
27
22
  .date-rail__date {
28
23
  position: sticky;
29
- top: var(--date-rail-top);
30
- align-self: start;
31
- margin: 0;
24
+ top: 0;
25
+ z-index: 1;
26
+ margin: 0 0 var(--space-2);
32
27
  padding-block: var(--space-2);
33
- padding-inline-end: var(--space-4);
34
- text-align: end;
35
- font-size: var(--text-sm);
28
+ border-bottom: 1px solid var(--color-line);
29
+ font-size: var(--text-xs);
36
30
  font-weight: var(--font-weight-semibold);
37
- color: var(--color-fg);
38
31
  font-variant-numeric: tabular-nums;
32
+ text-transform: uppercase;
33
+ letter-spacing: 0.08em;
34
+ color: var(--color-muted);
39
35
  background: var(--color-bg);
40
36
  }
37
+ .date-rail__date:empty { display: none; }
41
38
  .date-rail__body { min-width: 0; }
42
- .date-rail__body > h2:first-child { margin-top: var(--space-2); }
39
+ .date-rail__body > h2:first-child { margin-top: var(--space-1); }
43
40
  .date-rail__body > p, .date-rail__body > ul, .date-rail__body > ol, .date-rail__body > blockquote {
44
41
  line-height: var(--leading-relaxed);
45
42
  }
46
- .date-rail__section + .date-rail__section { padding-top: var(--space-6); }
47
- /* A note on the rail needs the rail's width on top of its reading measure. */
48
- .note[data-layout="timeline"] { max-width: calc(72ch + var(--date-rail-width, 7.5rem)); }
43
+ .date-rail__section + .date-rail__section { padding-top: var(--space-4); }
49
44
 
50
- /* Phone width: the rail folds away and each date becomes a small label above its heading. */
51
- @media (max-width: 768px) {
52
- .date-rail::before { content: none; }
53
- .date-rail__section { display: block; }
54
- .date-rail__date {
55
- position: static;
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)));
56
65
  padding: 0;
57
- text-align: start;
58
- font-size: var(--text-xs);
59
- text-transform: uppercase;
60
- letter-spacing: 0.08em;
61
- color: var(--color-muted);
66
+ overflow: visible;
67
+ border-bottom: 0;
62
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);
63
74
  }
64
- .date-rail__date:empty { display: none; }
65
- .date-rail__body > h2:first-child { margin-top: var(--space-1); }
66
- .note[data-layout="timeline"] { max-width: 72ch; }
75
+ .date-rail__date time { display: block; padding-top: var(--space-3); }
67
76
  }
@@ -1,10 +1,12 @@
1
1
  # Date rail
2
2
 
3
- A left-hand rail of dates for a note that tells a dated story. On desktop a hairline runs down the left of the article and each section's date sits beside it. The date of the section you are reading stays pinned near the top of the screen while you scroll through that section, then the section's end carries it away and the next date takes its place. On phone width (768px and under) the rail folds away and each date becomes a small label above its heading, with no horizontal scroll.
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
4
 
5
- The handover is plain CSS. Each date is `position: sticky` inside its own section, so the section's bottom edge 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.
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
6
 
7
- **Parent context:** sticky needs a scrolling ancestor with no `overflow: hidden` between it and the rail. A normal page scroll is that ancestor. Inside a bounded box (like the demo below) the box itself must scroll. Tune where the date pins with `--date-rail-top` and the rail's width with `--date-rail-width` on `.date-rail`. CSS-only (no `.html`).
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`).
8
10
 
9
11
  ## Authoring it from MILL
10
12
 
@@ -23,8 +25,10 @@ MILL's default layout then wraps every H2 and the prose under it in a rail secti
23
25
 
24
26
  ## Example
25
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
+
26
30
  ```html
27
- <div style="height:22rem;overflow:auto;border:1px solid var(--color-line);padding:var(--space-4)">
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">
28
32
  <article class="note" data-layout="timeline">
29
33
  <p>An opening paragraph stays above the rail and reads at full width.</p>
30
34
  <div class="date-rail">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tjakoen/grain",
3
- "version": "0.1.31",
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",