@n1kname/components 0.43.0 → 0.44.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 +17 -2
- package/src/ScreenStack.astro +21 -3
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
|
|
|
@@ -151,7 +153,7 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
151
153
|
layers.length > 0 && (
|
|
152
154
|
<div class="stage" style={`aspect-ratio: ${stage}`}>
|
|
153
155
|
{layers.map((l, i) => (
|
|
154
|
-
<div class=
|
|
156
|
+
<div class:list={['layer', { float: l.float }]} style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
155
157
|
{typeof l.image === 'string' ? (
|
|
156
158
|
<img src={l.image} alt={l.alt ?? ''} loading="lazy" />
|
|
157
159
|
) : (
|
|
@@ -457,7 +459,7 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
457
459
|
}
|
|
458
460
|
|
|
459
461
|
@media (prefers-reduced-motion: no-preference) {
|
|
460
|
-
.armed :is(.screen, .layer) {
|
|
462
|
+
.armed:not(.in) :is(.screen, .layer) {
|
|
461
463
|
opacity: 0;
|
|
462
464
|
translate: 0 48px;
|
|
463
465
|
}
|
|
@@ -479,4 +481,17 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
479
481
|
@media (max-width: 640px) {
|
|
480
482
|
.case-tile { border-radius: 18px; }
|
|
481
483
|
}
|
|
484
|
+
|
|
485
|
+
/* A floating layer bobs on its picture, not the layer, so it adds to the pointer, the hover lift
|
|
486
|
+
* and the arrival instead of replacing them. */
|
|
487
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
488
|
+
.layer.float :global(img) {
|
|
489
|
+
animation: layer-float 6s ease-in-out infinite;
|
|
490
|
+
}
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
@keyframes layer-float {
|
|
494
|
+
0%, 100% { translate: 0 0; }
|
|
495
|
+
50% { translate: 0 var(--float-range, 16px); }
|
|
496
|
+
}
|
|
482
497
|
</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
|
|
|
@@ -99,7 +103,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
99
103
|
layers.length > 0 && (
|
|
100
104
|
<div class="stage" style={`aspect-ratio: ${stage}`}>
|
|
101
105
|
{layers.map((l, i) => (
|
|
102
|
-
<div class=
|
|
106
|
+
<div class:list={['layer', { float: l.float }]} style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
103
107
|
{typeof l.image === 'string' ? (
|
|
104
108
|
<img src={l.image} alt={l.alt ?? ''} loading={eager ? 'eager' : 'lazy'} />
|
|
105
109
|
) : (
|
|
@@ -344,9 +348,10 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
344
348
|
.card.phone .s2 { left: 55%; top: 2%; }
|
|
345
349
|
|
|
346
350
|
@media (prefers-reduced-motion: no-preference) {
|
|
351
|
+
/* Layers play in back to front, the way they are stacked, so a floating card lands last. */
|
|
347
352
|
.layer {
|
|
348
353
|
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) *
|
|
354
|
+
animation-delay: calc(var(--i) * 140ms);
|
|
350
355
|
}
|
|
351
356
|
.screen {
|
|
352
357
|
animation: stack-in var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)) both;
|
|
@@ -402,4 +407,17 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
402
407
|
max-width: calc(100% - 2 * var(--sp-3));
|
|
403
408
|
}
|
|
404
409
|
}
|
|
410
|
+
|
|
411
|
+
/* A floating layer bobs on its picture, not the layer, so it adds to the pointer, the hover lift
|
|
412
|
+
* and the arrival instead of replacing them. */
|
|
413
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
414
|
+
.layer.float :global(img) {
|
|
415
|
+
animation: layer-float 6s ease-in-out infinite;
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
@keyframes layer-float {
|
|
420
|
+
0%, 100% { translate: 0 0; }
|
|
421
|
+
50% { translate: 0 var(--float-range, 16px); }
|
|
422
|
+
}
|
|
405
423
|
</style>
|