@n1kname/components 0.43.1 → 0.45.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/CaseTile.astro +32 -7
- package/src/ScreenStack.astro +47 -12
package/package.json
CHANGED
package/src/CaseTile.astro
CHANGED
|
@@ -43,6 +43,8 @@ interface Layer {
|
|
|
43
43
|
width: number;
|
|
44
44
|
/** How far it floats on hover: 0 stays put, 1 lifts the most. */
|
|
45
45
|
depth?: number;
|
|
46
|
+
/** Bobs slowly on its own, down and back, so a card cut out of a page floats above it. */
|
|
47
|
+
float?: boolean;
|
|
46
48
|
alt?: string;
|
|
47
49
|
}
|
|
48
50
|
|
|
@@ -114,10 +116,19 @@ const fit = (img: ImageMetadata) => {
|
|
|
114
116
|
return w.length ? w : [img.width];
|
|
115
117
|
};
|
|
116
118
|
const layerWidths = (img: ImageMetadata) => {
|
|
117
|
-
const w = [800, 1600].filter((x) => x <= img.width);
|
|
119
|
+
const w = [400, 800, 1200, 1600].filter((x) => x <= img.width);
|
|
118
120
|
return w.length ? w : [img.width];
|
|
119
121
|
};
|
|
122
|
+
// A layer is shown at its share of the stage, and the stage is the picture area: about the tile's
|
|
123
|
+
// width on a phone, and at most some 600px (half) or 700px (wide) beside it. Saying so lets a small
|
|
124
|
+
// card cut out of a page load a small file.
|
|
125
|
+
const layerSizes = (width: number) =>
|
|
126
|
+
`(max-width: 760px) ${Math.round(width * 0.85)}vw, ${Math.round(width * (layout === 'wide' ? 7 : 6))}px`;
|
|
120
127
|
const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
128
|
+
// The link is named title first, then the line, the overline and the note, so a screen reader
|
|
129
|
+
// hears the case before its dates. Ids from the href, so the build stays the same each run.
|
|
130
|
+
const uid = `case-tile-${href.replace(/[^a-z0-9]+/gi, '-').replace(/^-|-$/g, '') || 'home'}`;
|
|
131
|
+
const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-over`, note && `${uid}-note`].filter(Boolean).join(' ');
|
|
121
132
|
---
|
|
122
133
|
|
|
123
134
|
<a
|
|
@@ -125,13 +136,14 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
125
136
|
href={href}
|
|
126
137
|
style={`--tile-tone: ${tone}; ${patternStyle(pattern, ink)}`}
|
|
127
138
|
data-case-tile
|
|
139
|
+
aria-labelledby={labelledby}
|
|
128
140
|
>
|
|
129
141
|
<div class="frame">
|
|
130
142
|
<div class="copy">
|
|
131
|
-
{overline && <p class="overline">{overline}</p>}
|
|
132
|
-
<Heading class="title">{title}</Heading>
|
|
133
|
-
{text && <p class="text">{text}</p>}
|
|
134
|
-
{note && <p class="note">{note}</p>}
|
|
143
|
+
{overline && <p class="overline" id={`${uid}-over`}>{overline}</p>}
|
|
144
|
+
<Heading class="title" id={`${uid}-title`}>{title}</Heading>
|
|
145
|
+
{text && <p class="text" id={`${uid}-text`}>{text}</p>}
|
|
146
|
+
{note && <p class="note" id={`${uid}-note`}>{note}</p>}
|
|
135
147
|
{
|
|
136
148
|
figures.length > 0 && (
|
|
137
149
|
<dl class="metrics">
|
|
@@ -151,11 +163,11 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
151
163
|
layers.length > 0 && (
|
|
152
164
|
<div class="stage" style={`aspect-ratio: ${stage}`}>
|
|
153
165
|
{layers.map((l, i) => (
|
|
154
|
-
<div class=
|
|
166
|
+
<div class:list={['layer', { float: l.float }]} style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
155
167
|
{typeof l.image === 'string' ? (
|
|
156
168
|
<img src={l.image} alt={l.alt ?? ''} loading="lazy" />
|
|
157
169
|
) : (
|
|
158
|
-
<Image src={l.image} alt={l.alt ?? ''} widths={layerWidths(l.image)} sizes=
|
|
170
|
+
<Image src={l.image} alt={l.alt ?? ''} widths={layerWidths(l.image)} sizes={layerSizes(l.width)} format="webp" quality={80} loading="lazy" />
|
|
159
171
|
)}
|
|
160
172
|
</div>
|
|
161
173
|
))}
|
|
@@ -479,4 +491,17 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
479
491
|
@media (max-width: 640px) {
|
|
480
492
|
.case-tile { border-radius: 18px; }
|
|
481
493
|
}
|
|
494
|
+
|
|
495
|
+
/* A floating layer bobs on its picture, not the layer, so it adds to the pointer, the hover lift
|
|
496
|
+
* and the arrival instead of replacing them. */
|
|
497
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
498
|
+
.layer.float :global(img) {
|
|
499
|
+
animation: layer-float 6s ease-in-out infinite;
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
@keyframes layer-float {
|
|
504
|
+
0%, 100% { translate: 0 0; }
|
|
505
|
+
50% { translate: 0 var(--float-range, 16px); }
|
|
506
|
+
}
|
|
482
507
|
</style>
|
package/src/ScreenStack.astro
CHANGED
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
* The first screen sits in front, low and left; the others step up and right behind it.
|
|
8
8
|
*
|
|
9
9
|
* Motion, all of it off under reduced motion:
|
|
10
|
-
* - The screens play in once, front first, rising a little as they fade in
|
|
10
|
+
* - The screens play in once, front first, rising a little as they fade in; layers play in back
|
|
11
|
+
* to front. This is the page's entrance: no picture morphs in from the page before.
|
|
12
|
+
* - A layer with `float` bobs slowly on its own, down and back, whatever the others do.
|
|
11
13
|
* - `size="cover"`: under a real pointer, the screens follow it a few pixels, the front one most,
|
|
12
14
|
* so the stack reads as layers. Leaves no listener behind when there is no fine pointer.
|
|
13
15
|
* - `size="card"`: when the link around it is hovered or focused (a LinkCard), the screens fan
|
|
@@ -41,6 +43,8 @@ interface Layer {
|
|
|
41
43
|
width: number;
|
|
42
44
|
/** 0 stays put; 1 follows the pointer and lifts the most. */
|
|
43
45
|
depth?: number;
|
|
46
|
+
/** Bobs slowly on its own, down and back, so a card cut out of a page floats above it. */
|
|
47
|
+
float?: boolean;
|
|
44
48
|
alt?: string;
|
|
45
49
|
}
|
|
46
50
|
|
|
@@ -83,9 +87,15 @@ const sizes = phone
|
|
|
83
87
|
? size === 'cover' ? '(max-width: 640px) 30vw, 230px' : '(max-width: 640px) 22vw, 70px'
|
|
84
88
|
: size === 'cover' ? '(max-width: 900px) 80vw, 760px' : '(max-width: 640px) 70vw, 220px';
|
|
85
89
|
const layerWidths = (img: ImageMetadata) => {
|
|
86
|
-
const w = [800, 1600, 2400].filter((x) => x <= img.width);
|
|
90
|
+
const w = [400, 800, 1200, 1600, 2400].filter((x) => x <= img.width);
|
|
87
91
|
return w.length ? w : [img.width];
|
|
88
92
|
};
|
|
93
|
+
// A layer is shown at its share of the stage: on a cover about 56% of a panel up to some 1240px wide
|
|
94
|
+
// (76% on a phone), on a card about the card's width. Saying so lets a small card load a small file.
|
|
95
|
+
const layerSizes = (width: number) =>
|
|
96
|
+
size === 'cover'
|
|
97
|
+
? `(max-width: 640px) ${Math.round(width * 0.7)}vw, ${Math.round(width * 7)}px`
|
|
98
|
+
: `(max-width: 640px) ${Math.round(width * 0.9)}vw, ${Math.round(width * 3.6)}px`;
|
|
89
99
|
const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.width))];
|
|
90
100
|
---
|
|
91
101
|
|
|
@@ -99,7 +109,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
99
109
|
layers.length > 0 && (
|
|
100
110
|
<div class="stage" style={`aspect-ratio: ${stage}`}>
|
|
101
111
|
{layers.map((l, i) => (
|
|
102
|
-
<div class=
|
|
112
|
+
<div class:list={['layer', { float: l.float }]} style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
103
113
|
{typeof l.image === 'string' ? (
|
|
104
114
|
<img src={l.image} alt={l.alt ?? ''} loading={eager ? 'eager' : 'lazy'} />
|
|
105
115
|
) : (
|
|
@@ -107,7 +117,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
107
117
|
src={l.image}
|
|
108
118
|
alt={l.alt ?? ''}
|
|
109
119
|
widths={layerWidths(l.image)}
|
|
110
|
-
sizes=
|
|
120
|
+
sizes={layerSizes(l.width)}
|
|
111
121
|
format="webp"
|
|
112
122
|
quality={80}
|
|
113
123
|
loading={eager ? 'eager' : 'lazy'}
|
|
@@ -213,7 +223,11 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
213
223
|
margin: 0;
|
|
214
224
|
padding: 4px var(--sp-3);
|
|
215
225
|
border-radius: var(--radius-full);
|
|
216
|
-
|
|
226
|
+
/* Tinted from the panel and blurred, so it reads even where a picture runs under it. */
|
|
227
|
+
background: color-mix(in oklab, var(--stack-tone), black 30%);
|
|
228
|
+
background: color-mix(in oklab, color-mix(in oklab, var(--stack-tone), black 35%) 72%, transparent);
|
|
229
|
+
backdrop-filter: blur(10px);
|
|
230
|
+
-webkit-backdrop-filter: blur(10px);
|
|
217
231
|
color: #fff;
|
|
218
232
|
font-size: var(--text-caption);
|
|
219
233
|
line-height: 1.4;
|
|
@@ -270,7 +284,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
270
284
|
);
|
|
271
285
|
}
|
|
272
286
|
.ink-dark .note {
|
|
273
|
-
background:
|
|
287
|
+
background: color-mix(in oklab, color-mix(in oklab, var(--stack-tone), white 45%) 78%, transparent);
|
|
274
288
|
color: #17181a;
|
|
275
289
|
}
|
|
276
290
|
|
|
@@ -344,9 +358,10 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
344
358
|
.card.phone .s2 { left: 55%; top: 2%; }
|
|
345
359
|
|
|
346
360
|
@media (prefers-reduced-motion: no-preference) {
|
|
361
|
+
/* Layers play in back to front, the way they are stacked, so a floating card lands last. */
|
|
347
362
|
.layer {
|
|
348
363
|
animation: stack-in var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)) both;
|
|
349
|
-
animation-delay: calc(var(--i) *
|
|
364
|
+
animation-delay: calc(var(--i) * 140ms);
|
|
350
365
|
}
|
|
351
366
|
.screen {
|
|
352
367
|
animation: stack-in var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)) both;
|
|
@@ -387,19 +402,39 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
387
402
|
.cover.laptop .screen {
|
|
388
403
|
width: 78%;
|
|
389
404
|
}
|
|
390
|
-
|
|
391
|
-
.cover.laptop .
|
|
405
|
+
/* On a phone the note takes the top, so the pictures start under it rather than behind it. */
|
|
406
|
+
.cover.laptop .s0 { left: 6%; top: 44%; }
|
|
407
|
+
.cover.laptop .s1 { left: 16%; top: 30%; }
|
|
392
408
|
.cover.laptop .s2 { display: none; }
|
|
393
409
|
|
|
394
410
|
/* Phones keep all three, larger, overlapping more. */
|
|
395
411
|
.cover.phone .screen {
|
|
396
412
|
width: 30%;
|
|
397
413
|
}
|
|
398
|
-
.cover.phone .s0 { left: 12%; top:
|
|
399
|
-
.cover.phone .s1 { left: 35%; top:
|
|
400
|
-
.cover.phone .s2 { left: 58%; top:
|
|
414
|
+
.cover.phone .s0 { left: 12%; top: 36%; }
|
|
415
|
+
.cover.phone .s1 { left: 35%; top: 31%; }
|
|
416
|
+
.cover.phone .s2 { left: 58%; top: 26%; }
|
|
417
|
+
|
|
418
|
+
.cover .stage {
|
|
419
|
+
right: -4%;
|
|
420
|
+
top: 28%;
|
|
421
|
+
width: 76%;
|
|
422
|
+
}
|
|
401
423
|
.cover.phone .note {
|
|
402
424
|
max-width: calc(100% - 2 * var(--sp-3));
|
|
403
425
|
}
|
|
404
426
|
}
|
|
427
|
+
|
|
428
|
+
/* A floating layer bobs on its picture, not the layer, so it adds to the pointer, the hover lift
|
|
429
|
+
* and the arrival instead of replacing them. */
|
|
430
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
431
|
+
.layer.float :global(img) {
|
|
432
|
+
animation: layer-float 6s ease-in-out infinite;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
@keyframes layer-float {
|
|
437
|
+
0%, 100% { translate: 0 0; }
|
|
438
|
+
50% { translate: 0 var(--float-range, 16px); }
|
|
439
|
+
}
|
|
405
440
|
</style>
|