@n1kname/components 0.41.0 → 0.42.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 +2 -2
- package/src/CaseTile.astro +94 -4
- package/src/ScreenStack.astro +104 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1kname/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.42.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"./cardlist.js": "./src/cardlist.js"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@n1kname/charts": "0.
|
|
36
|
+
"@n1kname/charts": "0.15.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
39
|
"@n1kname/tokens": "^0.7.0",
|
package/src/CaseTile.astro
CHANGED
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
* narrower than 760px, and the figures drop out there.
|
|
11
11
|
*
|
|
12
12
|
* Screens are laptop (wide) or phone (tall) screenshots, or one picture (`image`), such as a photo,
|
|
13
|
-
* for a case without screens. The first screen sits in front.
|
|
13
|
+
* for a case without screens. The first screen sits in front. Or `layers`: separate pictures, such
|
|
14
|
+
* as an isometric page and a card cut out of it, placed on a stage by percentage, each with a
|
|
15
|
+
* `depth`. On hover a deeper layer floats up further, so a card lifts off the page it came from.
|
|
16
|
+
*
|
|
17
|
+
* `ink="dark"` sets the words in dark ink, for a light tone such as a yellow.
|
|
14
18
|
*
|
|
15
19
|
* Motion, all of it off under reduced motion: the screens rise in once as the tile scrolls into view,
|
|
16
20
|
* front first. Under a real pointer the tile lifts and the screens fan out a little; focus does the
|
|
@@ -30,6 +34,17 @@ interface Screen {
|
|
|
30
34
|
alt?: string;
|
|
31
35
|
}
|
|
32
36
|
|
|
37
|
+
interface Layer {
|
|
38
|
+
image: ImageMetadata | string;
|
|
39
|
+
/** Position and width on the stage, in percent of its width (x, width) and height (y). */
|
|
40
|
+
x: number;
|
|
41
|
+
y: number;
|
|
42
|
+
width: number;
|
|
43
|
+
/** How far it floats on hover: 0 stays put, 1 lifts the most. */
|
|
44
|
+
depth?: number;
|
|
45
|
+
alt?: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
interface Props {
|
|
34
49
|
href: string;
|
|
35
50
|
/** The project's name, set large. */
|
|
@@ -43,6 +58,12 @@ interface Props {
|
|
|
43
58
|
screens?: Screen[];
|
|
44
59
|
/** One picture instead of screens, such as a photo. */
|
|
45
60
|
image?: ImageMetadata | string;
|
|
61
|
+
/** Separate pictures on a stage, in place of screens. */
|
|
62
|
+
layers?: Layer[];
|
|
63
|
+
/** The stage's width over its height. */
|
|
64
|
+
stage?: number;
|
|
65
|
+
/** Dark words for a light tone. */
|
|
66
|
+
ink?: 'light' | 'dark';
|
|
46
67
|
device?: 'laptop' | 'phone';
|
|
47
68
|
layout?: 'wide' | 'half';
|
|
48
69
|
/** The tile colour, deep enough for white text. */
|
|
@@ -64,6 +85,9 @@ const {
|
|
|
64
85
|
metrics = [],
|
|
65
86
|
screens = [],
|
|
66
87
|
image,
|
|
88
|
+
layers = [],
|
|
89
|
+
stage = 4 / 3,
|
|
90
|
+
ink = 'light',
|
|
67
91
|
device = 'laptop',
|
|
68
92
|
layout = 'half',
|
|
69
93
|
tone = 'var(--c-accent)',
|
|
@@ -82,11 +106,15 @@ const fit = (img: ImageMetadata) => {
|
|
|
82
106
|
const w = widths.filter((x) => x <= img.width);
|
|
83
107
|
return w.length ? w : [img.width];
|
|
84
108
|
};
|
|
109
|
+
const layerWidths = (img: ImageMetadata) => {
|
|
110
|
+
const w = [800, 1600].filter((x) => x <= img.width);
|
|
111
|
+
return w.length ? w : [img.width];
|
|
112
|
+
};
|
|
85
113
|
const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
86
114
|
---
|
|
87
115
|
|
|
88
116
|
<a
|
|
89
|
-
class:list={['case-tile', layout, device, { 'has-image': !shots.length && image }, className]}
|
|
117
|
+
class:list={['case-tile', layout, device, `ink-${ink}`, { 'has-image': !shots.length && !layers.length && image, 'has-layers': layers.length }, className]}
|
|
90
118
|
href={href}
|
|
91
119
|
style={`--tile-tone: ${tone}`}
|
|
92
120
|
data-case-tile
|
|
@@ -113,7 +141,24 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
113
141
|
|
|
114
142
|
<div class="art" style={transition ? `view-transition-name: ${transition}; view-transition-class: media` : undefined}>
|
|
115
143
|
{
|
|
116
|
-
|
|
144
|
+
layers.length > 0 && (
|
|
145
|
+
<div class="stage" style={`aspect-ratio: ${stage}`}>
|
|
146
|
+
{layers.map((l, i) => (
|
|
147
|
+
<div class="layer" style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
148
|
+
{typeof l.image === 'string' ? (
|
|
149
|
+
<img src={l.image} alt={l.alt ?? ''} loading="lazy" />
|
|
150
|
+
) : (
|
|
151
|
+
<Image src={l.image} alt={l.alt ?? ''} widths={layerWidths(l.image)} sizes="(max-width: 760px) 90vw, 700px" format="webp" quality={80} loading="lazy" />
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
))}
|
|
155
|
+
</div>
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
{
|
|
159
|
+
layers.length > 0
|
|
160
|
+
? null
|
|
161
|
+
: shots.length > 0
|
|
117
162
|
? order.map((i) => {
|
|
118
163
|
const s = shots[i];
|
|
119
164
|
return (
|
|
@@ -298,6 +343,50 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
298
343
|
height: auto;
|
|
299
344
|
}
|
|
300
345
|
|
|
346
|
+
/* Layers: pictures that carry their own shadows, on a stage the size of the picture area's width. */
|
|
347
|
+
.stage {
|
|
348
|
+
position: absolute;
|
|
349
|
+
left: 0;
|
|
350
|
+
top: 0;
|
|
351
|
+
width: 100%;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
.layer {
|
|
355
|
+
position: absolute;
|
|
356
|
+
--lift: 0px;
|
|
357
|
+
transform: translateY(var(--lift));
|
|
358
|
+
transition:
|
|
359
|
+
transform 700ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
360
|
+
translate 900ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
361
|
+
opacity 700ms ease-out;
|
|
362
|
+
transition-delay: 0ms, calc(var(--i) * 90ms), calc(var(--i) * 90ms);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
.layer :global(img) {
|
|
366
|
+
display: block;
|
|
367
|
+
width: 100%;
|
|
368
|
+
height: auto;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/* Dark ink, for a light tone. */
|
|
372
|
+
.ink-dark {
|
|
373
|
+
color: #17181a;
|
|
374
|
+
background:
|
|
375
|
+
radial-gradient(circle at 1px 1px, rgb(0 0 0 / 0.1) 1px, transparent 0) 0 0 / 22px 22px,
|
|
376
|
+
linear-gradient(
|
|
377
|
+
150deg,
|
|
378
|
+
color-mix(in oklab, var(--tile-tone), white 14%),
|
|
379
|
+
var(--tile-tone) 50%,
|
|
380
|
+
color-mix(in oklab, var(--tile-tone), black 10%)
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
.ink-dark .title { color: #17181a; }
|
|
384
|
+
.ink-dark .overline { color: rgb(0 0 0 / 0.66); }
|
|
385
|
+
.ink-dark .text { color: rgb(0 0 0 / 0.8); }
|
|
386
|
+
.ink-dark .note { background: rgb(0 0 0 / 0.1); color: #17181a; }
|
|
387
|
+
.ink-dark .metrics { border-top-color: rgb(0 0 0 / 0.2); }
|
|
388
|
+
.ink-dark .metrics dd { color: rgb(0 0 0 / 0.7); }
|
|
389
|
+
|
|
301
390
|
.s0 { z-index: 3; }
|
|
302
391
|
.s1 { z-index: 2; transition-delay: 0ms, 90ms, 90ms; }
|
|
303
392
|
.s2 { z-index: 1; transition-delay: 0ms, 180ms, 180ms; }
|
|
@@ -350,10 +439,11 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
350
439
|
}
|
|
351
440
|
|
|
352
441
|
@media (prefers-reduced-motion: no-preference) {
|
|
353
|
-
.armed .screen {
|
|
442
|
+
.armed :is(.screen, .layer) {
|
|
354
443
|
opacity: 0;
|
|
355
444
|
translate: 0 48px;
|
|
356
445
|
}
|
|
446
|
+
.case-tile:is(:hover, :focus-visible) .layer { --lift: calc(var(--depth) * -20px); }
|
|
357
447
|
|
|
358
448
|
@media (hover: hover) {
|
|
359
449
|
.case-tile:hover {
|
package/src/ScreenStack.astro
CHANGED
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
* `device="phone"` lays tall phone screens side by side instead, stepping up and right, each in a
|
|
17
17
|
* thin dark bezel with rounded corners. Give it the screen alone, without a device frame.
|
|
18
18
|
*
|
|
19
|
+
* `layers` places separate pictures on a stage instead, such as an isometric page and a card cut
|
|
20
|
+
* out of it, each with a `depth`: deeper layers follow the pointer further and lift on hover, so the
|
|
21
|
+
* card floats off its page. `ink="dark"` darkens the note for a light tone.
|
|
22
|
+
*
|
|
19
23
|
* A picture is an imported image (it goes through astro:assets, sized and converted to webp) or a
|
|
20
24
|
* plain URL. `note` labels the panel, such as "Concepts, made-up data", for screens that are not
|
|
21
25
|
* shipped work: keep it short on a card.
|
|
@@ -28,9 +32,26 @@ interface Screen {
|
|
|
28
32
|
alt: string;
|
|
29
33
|
}
|
|
30
34
|
|
|
35
|
+
interface Layer {
|
|
36
|
+
image: ImageMetadata | string;
|
|
37
|
+
/** Position and width on the stage, in percent of its width (x, width) and height (y). */
|
|
38
|
+
x: number;
|
|
39
|
+
y: number;
|
|
40
|
+
width: number;
|
|
41
|
+
/** 0 stays put; 1 follows the pointer and lifts the most. */
|
|
42
|
+
depth?: number;
|
|
43
|
+
alt?: string;
|
|
44
|
+
}
|
|
45
|
+
|
|
31
46
|
interface Props {
|
|
32
47
|
/** Two or three; any more are left out. The first sits in front. */
|
|
33
|
-
screens
|
|
48
|
+
screens?: Screen[];
|
|
49
|
+
/** Separate pictures on a stage, in place of screens. */
|
|
50
|
+
layers?: Layer[];
|
|
51
|
+
/** The stage's width over its height. */
|
|
52
|
+
stage?: number;
|
|
53
|
+
/** Dark ink on the note, for a light tone. */
|
|
54
|
+
ink?: 'light' | 'dark';
|
|
34
55
|
/** The panel colour: a CSS colour, deep enough for white text, such as a client's brand blue. */
|
|
35
56
|
tone?: string;
|
|
36
57
|
note?: string;
|
|
@@ -47,7 +68,7 @@ interface Props {
|
|
|
47
68
|
class?: string;
|
|
48
69
|
}
|
|
49
70
|
|
|
50
|
-
const { screens, tone = 'var(--c-accent)', note, size = 'cover', device = 'laptop', transition, eager = size === 'cover', parallax = size === 'cover', class: className } = Astro.props;
|
|
71
|
+
const { screens = [], layers = [], stage = 4 / 3, ink = 'light', tone = 'var(--c-accent)', note, size = 'cover', device = 'laptop', transition, eager = size === 'cover', parallax = size === 'cover', class: className } = Astro.props;
|
|
51
72
|
const shots = screens.slice(0, 3);
|
|
52
73
|
// Back to front, so the first screen paints last and sits on top.
|
|
53
74
|
const order = [...shots.keys()].reverse();
|
|
@@ -56,17 +77,44 @@ const widths = phone ? (size === 'cover' ? [240, 480, 720] : [160, 320]) : size
|
|
|
56
77
|
const sizes = phone
|
|
57
78
|
? size === 'cover' ? '(max-width: 640px) 30vw, 230px' : '(max-width: 640px) 22vw, 70px'
|
|
58
79
|
: size === 'cover' ? '(max-width: 900px) 80vw, 760px' : '(max-width: 640px) 70vw, 220px';
|
|
80
|
+
const layerWidths = (img: ImageMetadata) => {
|
|
81
|
+
const w = [800, 1600, 2400].filter((x) => x <= img.width);
|
|
82
|
+
return w.length ? w : [img.width];
|
|
83
|
+
};
|
|
59
84
|
const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.width))];
|
|
60
85
|
---
|
|
61
86
|
|
|
62
87
|
<div
|
|
63
|
-
class:list={['screen-stack', size, device, `n${shots.length}`, className]}
|
|
88
|
+
class:list={['screen-stack', size, device, `n${shots.length}`, `ink-${ink}`, { 'has-layers': layers.length }, className]}
|
|
64
89
|
style={`--stack-tone: ${tone};${transition ? ` view-transition-name: ${transition}; view-transition-class: media;` : ''}`}
|
|
65
90
|
data-screen-stack-parallax={parallax ? '' : undefined}
|
|
66
91
|
>
|
|
67
92
|
{note && <p class="note">{note}</p>}
|
|
68
93
|
{
|
|
69
|
-
|
|
94
|
+
layers.length > 0 && (
|
|
95
|
+
<div class="stage" style={`aspect-ratio: ${stage}`}>
|
|
96
|
+
{layers.map((l, i) => (
|
|
97
|
+
<div class="layer" style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
98
|
+
{typeof l.image === 'string' ? (
|
|
99
|
+
<img src={l.image} alt={l.alt ?? ''} loading={eager ? 'eager' : 'lazy'} />
|
|
100
|
+
) : (
|
|
101
|
+
<Image
|
|
102
|
+
src={l.image}
|
|
103
|
+
alt={l.alt ?? ''}
|
|
104
|
+
widths={layerWidths(l.image)}
|
|
105
|
+
sizes="(max-width: 900px) 90vw, 1000px"
|
|
106
|
+
format="webp"
|
|
107
|
+
quality={80}
|
|
108
|
+
loading={eager ? 'eager' : 'lazy'}
|
|
109
|
+
/>
|
|
110
|
+
)}
|
|
111
|
+
</div>
|
|
112
|
+
))}
|
|
113
|
+
</div>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
116
|
+
{
|
|
117
|
+
layers.length > 0 ? null : order.map((i) => {
|
|
70
118
|
const s = shots[i];
|
|
71
119
|
const first = i === 0;
|
|
72
120
|
return (
|
|
@@ -163,6 +211,54 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
163
211
|
font-size: 11px;
|
|
164
212
|
}
|
|
165
213
|
|
|
214
|
+
/* Layers on a stage over the right of the panel; they carry their own shadows. */
|
|
215
|
+
.stage {
|
|
216
|
+
position: absolute;
|
|
217
|
+
right: 4%;
|
|
218
|
+
top: 6%;
|
|
219
|
+
width: 56%;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.layer {
|
|
223
|
+
position: absolute;
|
|
224
|
+
--lift: 0px;
|
|
225
|
+
transform: translate(calc(var(--px) * var(--depth) * 16px), calc(var(--py) * var(--depth) * 12px + var(--lift)));
|
|
226
|
+
transition: transform 700ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.layer :global(img) {
|
|
230
|
+
display: block;
|
|
231
|
+
width: 100%;
|
|
232
|
+
height: auto;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
|
|
236
|
+
.screen-stack:hover .layer {
|
|
237
|
+
--lift: calc(var(--depth) * -14px);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.card .stage {
|
|
242
|
+
right: -10%;
|
|
243
|
+
top: -8%;
|
|
244
|
+
width: 100%;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.ink-dark {
|
|
248
|
+
background:
|
|
249
|
+
radial-gradient(circle at 1px 1px, rgb(0 0 0 / 0.1) 1px, transparent 0) 0 0 / 22px 22px,
|
|
250
|
+
linear-gradient(
|
|
251
|
+
140deg,
|
|
252
|
+
color-mix(in oklab, var(--stack-tone), white 14%),
|
|
253
|
+
var(--stack-tone) 55%,
|
|
254
|
+
color-mix(in oklab, var(--stack-tone), black 10%)
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
.ink-dark .note {
|
|
258
|
+
background: rgb(0 0 0 / 0.1);
|
|
259
|
+
color: #17181a;
|
|
260
|
+
}
|
|
261
|
+
|
|
166
262
|
.screen {
|
|
167
263
|
position: absolute;
|
|
168
264
|
width: 58%;
|
|
@@ -233,6 +329,10 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
233
329
|
.card.phone .s2 { left: 55%; top: 2%; }
|
|
234
330
|
|
|
235
331
|
@media (prefers-reduced-motion: no-preference) {
|
|
332
|
+
.layer {
|
|
333
|
+
animation: stack-in var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)) both;
|
|
334
|
+
animation-delay: calc(var(--i) * 90ms);
|
|
335
|
+
}
|
|
236
336
|
.screen {
|
|
237
337
|
animation: stack-in var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)) both;
|
|
238
338
|
}
|