@n1kname/components 0.49.0 → 0.51.0
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/package.json +1 -1
- package/src/Timeline.astro +63 -81
package/package.json
CHANGED
package/src/Timeline.astro
CHANGED
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
* with a halo); any after it are still to come (hollow markers on a dashed line). By default the
|
|
9
9
|
* last entry is now. `order="newest-first"` turns that round for a history read from today back,
|
|
10
10
|
* such as a career: the first entry is now and the ones below it are done. An entry can carry an
|
|
11
|
-
* icon, shown in a soft
|
|
11
|
+
* icon, shown in a disc: soft for what's done, the accent with a halo for now. With `fill` the discs
|
|
12
|
+
* are the same, in teal for the history behind and the accent for now.
|
|
12
13
|
*
|
|
13
14
|
* Once, as each entry comes into view, its marker settles in, its text rises and its line draws on
|
|
14
15
|
* to the next. Nothing moves under reduced motion, and without script everything is simply there.
|
|
15
16
|
*
|
|
16
|
-
* `fill` is the other motion, for a long history that is read rather than glanced at:
|
|
17
|
-
*
|
|
18
|
-
* step into now and the chart teal for the rest. Each marker it
|
|
17
|
+
* `fill` is the other motion, for a long history that is read rather than glanced at: the same
|
|
18
|
+
* gapped, rounded segments, each filling as the reading line (60% down the window) passes it, in
|
|
19
|
+
* the accent for the step into now and the chart teal for the rest. Each marker it reaches lights
|
|
20
|
+
* up in full teal. The entries
|
|
19
21
|
* don't arrive: the fill is the one moment. Under reduced motion, or without script, the rail is
|
|
20
22
|
* drawn in full.
|
|
21
23
|
*
|
|
@@ -77,7 +79,7 @@ const extras = await Promise.all(
|
|
|
77
79
|
entries.map((e, i) => (
|
|
78
80
|
<li data-state={state(i)} aria-current={state(i) === 'current' ? 'step' : undefined} data-to={i < entries.length - 1 ? (dashed(i) ? 'next' : 'done') : undefined}>
|
|
79
81
|
<span class="marker" aria-hidden="true">
|
|
80
|
-
{e.icon && <Icon name={e.icon} size={
|
|
82
|
+
{e.icon && <Icon name={e.icon} size={16} />}
|
|
81
83
|
</span>
|
|
82
84
|
<div class="content">
|
|
83
85
|
<p class="period">{e.period}</p>
|
|
@@ -119,30 +121,27 @@ const extras = await Promise.all(
|
|
|
119
121
|
list.querySelectorAll('li').forEach((li) => seen.observe(li));
|
|
120
122
|
});
|
|
121
123
|
|
|
122
|
-
// The fill: from
|
|
123
|
-
// the
|
|
124
|
+
// The fill: each segment, from below one marker to above the next, fills as the line being read
|
|
125
|
+
// (60% down the window) passes it, and a marker counts as reached once the line is level with it.
|
|
124
126
|
document.querySelectorAll<HTMLElement>('[data-timeline].filling').forEach((list) => {
|
|
125
127
|
const items = [...list.querySelectorAll<HTMLElement>(':scope > li')];
|
|
126
128
|
if (items.length < 2) return;
|
|
127
|
-
const
|
|
128
|
-
const before = list.dataset.order === 'newest-first' ? now + 1 : now - 1;
|
|
129
|
+
const GAP = 6;
|
|
129
130
|
let queued = false;
|
|
130
131
|
const draw = () => {
|
|
131
132
|
queued = false;
|
|
132
|
-
const
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
list.style.setProperty('--lit-to', `${lit[1] - first}px`);
|
|
145
|
-
items.forEach((li, i) => li.classList.toggle('reached', at[i] <= end + 1));
|
|
133
|
+
const line = innerHeight * 0.6;
|
|
134
|
+
const marks = items.map((li) => li.querySelector('.marker')!.getBoundingClientRect());
|
|
135
|
+
items.forEach((li, i) => {
|
|
136
|
+
const m = marks[i];
|
|
137
|
+
li.classList.toggle('reached', m.top + m.height / 2 <= line + 1);
|
|
138
|
+
const next = marks[i + 1];
|
|
139
|
+
if (!next) return;
|
|
140
|
+
const top = m.bottom + GAP;
|
|
141
|
+
const bottom = next.top - GAP;
|
|
142
|
+
const p = Math.min(1, Math.max(0, (line - top) / Math.max(1, bottom - top)));
|
|
143
|
+
li.style.setProperty('--p', p.toFixed(3));
|
|
144
|
+
});
|
|
146
145
|
};
|
|
147
146
|
const queue = () => {
|
|
148
147
|
if (!queued) {
|
|
@@ -379,9 +378,11 @@ const extras = await Promise.all(
|
|
|
379
378
|
}
|
|
380
379
|
|
|
381
380
|
/* ── Fill ───────────────────────────────────────────────────────────────────
|
|
382
|
-
The
|
|
383
|
-
|
|
384
|
-
|
|
381
|
+
The same line as without the fill: a segment between each pair of markers, a small gap clear
|
|
382
|
+
of each and rounded at both ends. Each segment fills from the top as the reading line passes
|
|
383
|
+
it (--p, from 0 to 1, set by the script), teal for the history and the accent for the step into
|
|
384
|
+
now. A marker turns full teal as the fill reaches it, with a small spring. Without the script
|
|
385
|
+
(or with reduced motion) nothing is held back: every segment and marker is drawn in full. */
|
|
385
386
|
[data-fill] {
|
|
386
387
|
--m: 12px;
|
|
387
388
|
--mt: 6px;
|
|
@@ -389,61 +390,43 @@ const extras = await Promise.all(
|
|
|
389
390
|
--gap: var(--sp-8);
|
|
390
391
|
--rail: var(--c-chart-2);
|
|
391
392
|
--rail-faint: color-mix(in oklab, var(--c-chart-2) 22%, transparent);
|
|
392
|
-
position: relative;
|
|
393
393
|
}
|
|
394
394
|
|
|
395
|
+
/* With icons, the same discs as without the fill. */
|
|
395
396
|
[data-fill][data-icons] {
|
|
396
|
-
--m:
|
|
397
|
-
--mt:
|
|
397
|
+
--m: 32px;
|
|
398
|
+
--mt: 0px;
|
|
399
|
+
--col: 32px;
|
|
398
400
|
}
|
|
399
401
|
|
|
400
402
|
[data-fill] li {
|
|
401
403
|
column-gap: var(--sp-5);
|
|
404
|
+
--seg: var(--rail);
|
|
405
|
+
--seg-faint: var(--rail-faint);
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/* The step into now is the accent, before the fill reaches it as well as after. */
|
|
409
|
+
[data-fill][data-order='newest-first'] li[data-state='current'],
|
|
410
|
+
[data-fill][data-order='oldest-first'] li:has(+ li[data-state='current']) {
|
|
411
|
+
--seg: var(--c-accent);
|
|
412
|
+
--seg-faint: color-mix(in oklab, var(--c-accent) 28%, transparent);
|
|
402
413
|
}
|
|
403
414
|
|
|
404
415
|
[data-fill] li:not(:last-child)::before {
|
|
405
|
-
|
|
406
|
-
bottom: calc(-1 * (var(--mt) + var(--m) / 2));
|
|
407
|
-
background: var(--rail);
|
|
416
|
+
background: var(--seg);
|
|
408
417
|
opacity: 1;
|
|
409
418
|
}
|
|
410
419
|
|
|
411
420
|
[data-fill].filling li:not(:last-child)::before {
|
|
412
|
-
background: var(--rail-faint);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/* The step into now waits in a faint accent rather than faint teal, so it reads orange before
|
|
416
|
-
the fill reaches it as well as after. */
|
|
417
|
-
[data-fill][data-order='newest-first'].filling li[data-state='current']:not(:last-child)::before,
|
|
418
|
-
[data-fill][data-order='oldest-first'].filling li:has(+ li[data-state='current'])::before {
|
|
419
|
-
background: color-mix(in oklab, var(--c-accent) 28%, transparent);
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
/* Drawn in full (no script, reduced motion): the step into now is still the accent. */
|
|
423
|
-
[data-fill][data-order='newest-first']:not(.filling) li[data-state='current']:not(:last-child)::before,
|
|
424
|
-
[data-fill][data-order='oldest-first']:not(.filling) li:has(+ li[data-state='current'])::before {
|
|
425
|
-
background: var(--c-accent);
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
[data-fill].filling::after {
|
|
429
|
-
content: '';
|
|
430
|
-
position: absolute;
|
|
431
|
-
inset-inline-start: calc(var(--col) / 2 - 1px);
|
|
432
|
-
top: var(--fill-top, 0px);
|
|
433
|
-
width: 2px;
|
|
434
|
-
height: var(--fill-h, 0px);
|
|
435
|
-
border-radius: 1px;
|
|
436
421
|
background: linear-gradient(to bottom,
|
|
437
|
-
var(--
|
|
438
|
-
var(--
|
|
439
|
-
var(--rail) var(--lit-to, 0px));
|
|
422
|
+
var(--seg) 0 calc(var(--p, 0) * 100%),
|
|
423
|
+
var(--seg-faint) calc(var(--p, 0) * 100%));
|
|
440
424
|
}
|
|
441
425
|
|
|
442
426
|
[data-fill] .marker {
|
|
443
427
|
z-index: 1;
|
|
444
428
|
background: var(--rail);
|
|
445
|
-
|
|
446
|
-
color: var(--rail);
|
|
429
|
+
color: var(--c-bg);
|
|
447
430
|
transition:
|
|
448
431
|
background-color var(--motion-base) var(--ease-out),
|
|
449
432
|
color var(--motion-base) var(--ease-out);
|
|
@@ -453,40 +436,39 @@ const extras = await Promise.all(
|
|
|
453
436
|
background: color-mix(in oklab, var(--c-chart-2) 40%, var(--c-bg));
|
|
454
437
|
}
|
|
455
438
|
|
|
456
|
-
[data-fill] [data-state='current'] .marker,
|
|
457
|
-
[data-fill] [data-state='next'] .marker {
|
|
458
|
-
box-shadow: 0 0 0 4px var(--c-bg);
|
|
459
|
-
}
|
|
460
|
-
|
|
461
439
|
[data-fill] [data-state='current'] .marker {
|
|
462
440
|
background: var(--c-accent);
|
|
441
|
+
color: var(--c-on-accent);
|
|
463
442
|
}
|
|
464
443
|
|
|
465
|
-
/* With icons: the
|
|
466
|
-
|
|
467
|
-
[data-fill][data-icons] .marker,
|
|
444
|
+
/* With icons: a disc the fill has reached is full teal; one it has yet to reach is a quiet tint;
|
|
445
|
+
now is the accent itself, with its halo. */
|
|
468
446
|
[data-fill][data-icons] [data-state] .marker {
|
|
469
|
-
background: var(--
|
|
470
|
-
|
|
471
|
-
color: var(--rail);
|
|
447
|
+
background: var(--rail);
|
|
448
|
+
color: var(--c-bg);
|
|
472
449
|
}
|
|
473
450
|
|
|
474
451
|
[data-fill][data-icons].filling li:not(.reached) .marker {
|
|
475
|
-
background: var(--c-bg);
|
|
476
|
-
color: color-mix(in oklab, var(--c-chart-2)
|
|
452
|
+
background: color-mix(in oklab, var(--rail) 16%, var(--c-bg));
|
|
453
|
+
color: color-mix(in oklab, var(--c-chart-2) 60%, var(--c-bg));
|
|
477
454
|
}
|
|
478
455
|
|
|
479
456
|
[data-fill][data-icons] [data-state='current'] .marker,
|
|
480
457
|
[data-fill][data-icons].filling [data-state='current']:not(.reached) .marker {
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
458
|
+
background: var(--c-accent);
|
|
459
|
+
color: var(--c-on-accent);
|
|
460
|
+
box-shadow: 0 0 0 4px color-mix(in oklab, var(--c-accent) 28%, var(--c-bg));
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/* Lighting up: the marker swells a little and settles, on the spring. */
|
|
464
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
465
|
+
[data-fill].filling li.reached .marker {
|
|
466
|
+
animation: marker-lit var(--motion-spring, 340ms) var(--ease-spring, ease-out);
|
|
467
|
+
}
|
|
486
468
|
}
|
|
487
469
|
|
|
488
|
-
|
|
489
|
-
|
|
470
|
+
@keyframes marker-lit {
|
|
471
|
+
from { transform: scale(0.82); }
|
|
490
472
|
}
|
|
491
473
|
|
|
492
474
|
@media (max-width: 560px) {
|