@n1kname/components 0.40.1 → 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 +464 -0
- 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",
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A case on an index as a tile in the client's colour: the project's name large, one line on what
|
|
4
|
+
* it achieved, a few figures, and two or three screens that run off the tile's edge. The whole tile
|
|
5
|
+
* is one link.
|
|
6
|
+
*
|
|
7
|
+
* `layout="wide"` puts the words on the left and the screens on the right, with the figures under
|
|
8
|
+
* the words; it spans the full row, for the case that leads. `layout="half"` puts the words on top
|
|
9
|
+
* and the screens underneath, two tiles to a row. Either becomes the half layout once the tile is
|
|
10
|
+
* narrower than 760px, and the figures drop out there.
|
|
11
|
+
*
|
|
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. 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.
|
|
18
|
+
*
|
|
19
|
+
* Motion, all of it off under reduced motion: the screens rise in once as the tile scrolls into view,
|
|
20
|
+
* front first. Under a real pointer the tile lifts and the screens fan out a little; focus does the
|
|
21
|
+
* same.
|
|
22
|
+
*/
|
|
23
|
+
import type { ImageMetadata } from 'astro';
|
|
24
|
+
import { Image } from 'astro:assets';
|
|
25
|
+
|
|
26
|
+
interface Metric {
|
|
27
|
+
value: string;
|
|
28
|
+
label: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface Screen {
|
|
32
|
+
image: ImageMetadata | string;
|
|
33
|
+
/** Empty by default: the tile is one link, named by its words. */
|
|
34
|
+
alt?: string;
|
|
35
|
+
}
|
|
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
|
+
|
|
48
|
+
interface Props {
|
|
49
|
+
href: string;
|
|
50
|
+
/** The project's name, set large. */
|
|
51
|
+
title: string;
|
|
52
|
+
/** One line on what it achieved. */
|
|
53
|
+
text?: string;
|
|
54
|
+
/** Above the title: organisation, years, state. */
|
|
55
|
+
overline?: string;
|
|
56
|
+
/** Shown on a wide tile only; up to four. */
|
|
57
|
+
metrics?: Metric[];
|
|
58
|
+
screens?: Screen[];
|
|
59
|
+
/** One picture instead of screens, such as a photo. */
|
|
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';
|
|
67
|
+
device?: 'laptop' | 'phone';
|
|
68
|
+
layout?: 'wide' | 'half';
|
|
69
|
+
/** The tile colour, deep enough for white text. */
|
|
70
|
+
tone?: string;
|
|
71
|
+
/** A label on the picture, such as "Concepts". */
|
|
72
|
+
note?: string;
|
|
73
|
+
/** A view-transition-name for the screens, shared with the cover on the page it opens. */
|
|
74
|
+
transition?: string;
|
|
75
|
+
/** The title's heading level. */
|
|
76
|
+
as?: 'h2' | 'h3';
|
|
77
|
+
class?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const {
|
|
81
|
+
href,
|
|
82
|
+
title,
|
|
83
|
+
text,
|
|
84
|
+
overline,
|
|
85
|
+
metrics = [],
|
|
86
|
+
screens = [],
|
|
87
|
+
image,
|
|
88
|
+
layers = [],
|
|
89
|
+
stage = 4 / 3,
|
|
90
|
+
ink = 'light',
|
|
91
|
+
device = 'laptop',
|
|
92
|
+
layout = 'half',
|
|
93
|
+
tone = 'var(--c-accent)',
|
|
94
|
+
note,
|
|
95
|
+
transition,
|
|
96
|
+
as: Heading = 'h2',
|
|
97
|
+
class: className,
|
|
98
|
+
} = Astro.props;
|
|
99
|
+
|
|
100
|
+
const shots = screens.slice(0, 3);
|
|
101
|
+
const order = [...shots.keys()].reverse();
|
|
102
|
+
const phone = device === 'phone';
|
|
103
|
+
const widths = phone ? [240, 480] : [600, 1200];
|
|
104
|
+
const sizes = phone ? '(max-width: 760px) 30vw, 200px' : '(max-width: 760px) 80vw, 600px';
|
|
105
|
+
const fit = (img: ImageMetadata) => {
|
|
106
|
+
const w = widths.filter((x) => x <= img.width);
|
|
107
|
+
return w.length ? w : [img.width];
|
|
108
|
+
};
|
|
109
|
+
const layerWidths = (img: ImageMetadata) => {
|
|
110
|
+
const w = [800, 1600].filter((x) => x <= img.width);
|
|
111
|
+
return w.length ? w : [img.width];
|
|
112
|
+
};
|
|
113
|
+
const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
<a
|
|
117
|
+
class:list={['case-tile', layout, device, `ink-${ink}`, { 'has-image': !shots.length && !layers.length && image, 'has-layers': layers.length }, className]}
|
|
118
|
+
href={href}
|
|
119
|
+
style={`--tile-tone: ${tone}`}
|
|
120
|
+
data-case-tile
|
|
121
|
+
>
|
|
122
|
+
<div class="frame">
|
|
123
|
+
<div class="copy">
|
|
124
|
+
{overline && <p class="overline">{overline}</p>}
|
|
125
|
+
<Heading class="title">{title}</Heading>
|
|
126
|
+
{text && <p class="text">{text}</p>}
|
|
127
|
+
{note && <p class="note">{note}</p>}
|
|
128
|
+
{
|
|
129
|
+
figures.length > 0 && (
|
|
130
|
+
<dl class="metrics">
|
|
131
|
+
{figures.map((m) => (
|
|
132
|
+
<div>
|
|
133
|
+
<dt>{m.value}</dt>
|
|
134
|
+
<dd>{m.label}</dd>
|
|
135
|
+
</div>
|
|
136
|
+
))}
|
|
137
|
+
</dl>
|
|
138
|
+
)
|
|
139
|
+
}
|
|
140
|
+
</div>
|
|
141
|
+
|
|
142
|
+
<div class="art" style={transition ? `view-transition-name: ${transition}; view-transition-class: media` : undefined}>
|
|
143
|
+
{
|
|
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
|
|
162
|
+
? order.map((i) => {
|
|
163
|
+
const s = shots[i];
|
|
164
|
+
return (
|
|
165
|
+
<div class={`screen s${i}`}>
|
|
166
|
+
{typeof s.image === 'string' ? (
|
|
167
|
+
<img src={s.image} alt={s.alt ?? ''} loading="lazy" />
|
|
168
|
+
) : (
|
|
169
|
+
<Image src={s.image} alt={s.alt ?? ''} widths={fit(s.image)} sizes={sizes} format="webp" quality={80} loading="lazy" />
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
})
|
|
174
|
+
: image && (
|
|
175
|
+
<div class="screen picture s0">
|
|
176
|
+
{typeof image === 'string' ? (
|
|
177
|
+
<img src={image} alt="" loading="lazy" />
|
|
178
|
+
) : (
|
|
179
|
+
<Image src={image} alt="" widths={fit(image)} sizes="(max-width: 760px) 90vw, 700px" format="webp" quality={78} loading="lazy" />
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
</a>
|
|
187
|
+
|
|
188
|
+
<script>
|
|
189
|
+
// Arm the entrance only with script and motion welcome, so without either the screens are simply
|
|
190
|
+
// there. Each tile plays once, when it first comes into view.
|
|
191
|
+
const tiles = document.querySelectorAll<HTMLElement>('[data-case-tile]');
|
|
192
|
+
if (tiles.length && matchMedia('(prefers-reduced-motion: no-preference)').matches && 'IntersectionObserver' in window) {
|
|
193
|
+
const io = new IntersectionObserver(
|
|
194
|
+
(entries) => {
|
|
195
|
+
for (const e of entries) {
|
|
196
|
+
if (!e.isIntersecting) continue;
|
|
197
|
+
e.target.classList.add('in');
|
|
198
|
+
io.unobserve(e.target);
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{ threshold: 0.25 },
|
|
202
|
+
);
|
|
203
|
+
for (const t of tiles) {
|
|
204
|
+
if (t.getBoundingClientRect().top < innerHeight * 0.9) continue;
|
|
205
|
+
t.classList.add('armed');
|
|
206
|
+
io.observe(t);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
<style>
|
|
212
|
+
.case-tile {
|
|
213
|
+
container-type: inline-size;
|
|
214
|
+
position: relative;
|
|
215
|
+
display: block;
|
|
216
|
+
height: 100%;
|
|
217
|
+
overflow: hidden;
|
|
218
|
+
isolation: isolate;
|
|
219
|
+
border-radius: 24px;
|
|
220
|
+
color: #fff;
|
|
221
|
+
text-decoration: none;
|
|
222
|
+
background:
|
|
223
|
+
radial-gradient(circle at 1px 1px, rgb(255 255 255 / 0.13) 1px, transparent 0) 0 0 / 22px 22px,
|
|
224
|
+
linear-gradient(
|
|
225
|
+
150deg,
|
|
226
|
+
color-mix(in oklab, var(--tile-tone), white 10%),
|
|
227
|
+
var(--tile-tone) 50%,
|
|
228
|
+
color-mix(in oklab, var(--tile-tone), black 32%)
|
|
229
|
+
);
|
|
230
|
+
transition:
|
|
231
|
+
translate var(--motion-spring, 500ms) var(--ease-spring, ease-out),
|
|
232
|
+
box-shadow var(--motion-hover, 160ms) var(--ease-hover, ease-out);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.case-tile:focus-visible {
|
|
236
|
+
outline: 3px solid var(--c-focus, #fff);
|
|
237
|
+
outline-offset: 3px;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/* The tile is the container, and a container can't restyle itself, so the layout lives on this
|
|
241
|
+
* frame inside it. */
|
|
242
|
+
.frame {
|
|
243
|
+
display: flex;
|
|
244
|
+
flex-direction: column;
|
|
245
|
+
height: 100%;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* Words first; the pictures take the rest, so they never run under the text. */
|
|
249
|
+
.copy {
|
|
250
|
+
position: relative;
|
|
251
|
+
z-index: 2;
|
|
252
|
+
padding: clamp(24px, 7cqw, 48px);
|
|
253
|
+
padding-bottom: 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.overline {
|
|
257
|
+
margin: 0 0 var(--sp-3);
|
|
258
|
+
font-size: var(--text-caption);
|
|
259
|
+
letter-spacing: 0.02em;
|
|
260
|
+
color: rgb(255 255 255 / 0.74);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.title {
|
|
264
|
+
margin: 0;
|
|
265
|
+
font-family: var(--font-display);
|
|
266
|
+
font-weight: 600;
|
|
267
|
+
font-size: clamp(1.75rem, 7.5cqw, 3.25rem);
|
|
268
|
+
line-height: 1.05;
|
|
269
|
+
letter-spacing: -0.01em;
|
|
270
|
+
color: #fff;
|
|
271
|
+
text-wrap: balance;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.text {
|
|
275
|
+
margin: var(--sp-3) 0 0;
|
|
276
|
+
max-width: 36ch;
|
|
277
|
+
font-size: clamp(1rem, 2.6cqw, 1.2rem);
|
|
278
|
+
line-height: 1.45;
|
|
279
|
+
color: rgb(255 255 255 / 0.88);
|
|
280
|
+
text-wrap: pretty;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
.note {
|
|
284
|
+
display: inline-block;
|
|
285
|
+
margin: var(--sp-4) 0 0;
|
|
286
|
+
padding: 2px var(--sp-3);
|
|
287
|
+
border-radius: var(--radius-full);
|
|
288
|
+
background: rgb(255 255 255 / 0.16);
|
|
289
|
+
font-size: var(--text-caption);
|
|
290
|
+
color: #fff;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/* Figures only when the tile is wide enough to give them room. */
|
|
294
|
+
.metrics {
|
|
295
|
+
display: none;
|
|
296
|
+
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
297
|
+
gap: var(--sp-5) var(--sp-6);
|
|
298
|
+
margin: var(--sp-6) 0 0;
|
|
299
|
+
padding-top: var(--sp-5);
|
|
300
|
+
border-top: 1px solid rgb(255 255 255 / 0.24);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.metrics dt {
|
|
304
|
+
font-family: var(--font-display);
|
|
305
|
+
font-weight: 600;
|
|
306
|
+
font-size: clamp(1.5rem, 2.6cqw, 2.5rem);
|
|
307
|
+
line-height: 1.1;
|
|
308
|
+
font-variant-numeric: tabular-nums;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.metrics dd {
|
|
312
|
+
margin: var(--sp-1) 0 0;
|
|
313
|
+
font-size: var(--text-body-sm);
|
|
314
|
+
color: rgb(255 255 255 / 0.8);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/* Pictures, running off the bottom and right edge. Their height follows the tile's width. */
|
|
318
|
+
.art {
|
|
319
|
+
position: relative;
|
|
320
|
+
z-index: 1;
|
|
321
|
+
flex: 1 0 auto;
|
|
322
|
+
min-height: 56cqw;
|
|
323
|
+
margin-top: var(--sp-6);
|
|
324
|
+
pointer-events: none;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.screen {
|
|
328
|
+
position: absolute;
|
|
329
|
+
overflow: hidden;
|
|
330
|
+
border-radius: 10px;
|
|
331
|
+
box-shadow:
|
|
332
|
+
0 1px 2px rgb(0 0 0 / 0.2),
|
|
333
|
+
0 30px 60px -16px rgb(0 0 0 / 0.5);
|
|
334
|
+
transition:
|
|
335
|
+
transform 600ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
336
|
+
translate 900ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
337
|
+
opacity 700ms ease-out;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.screen :global(img) {
|
|
341
|
+
display: block;
|
|
342
|
+
width: 100%;
|
|
343
|
+
height: auto;
|
|
344
|
+
}
|
|
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
|
+
|
|
390
|
+
.s0 { z-index: 3; }
|
|
391
|
+
.s1 { z-index: 2; transition-delay: 0ms, 90ms, 90ms; }
|
|
392
|
+
.s2 { z-index: 1; transition-delay: 0ms, 180ms, 180ms; }
|
|
393
|
+
|
|
394
|
+
.phone .screen {
|
|
395
|
+
border-radius: 11% / 5%;
|
|
396
|
+
box-shadow:
|
|
397
|
+
0 0 0 3px rgb(18 18 20),
|
|
398
|
+
0 30px 50px -14px rgb(0 0 0 / 0.55);
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/* Half, and any tile under 760px. */
|
|
402
|
+
.laptop .screen { width: 84%; }
|
|
403
|
+
.laptop .s0 { left: 6%; top: 22%; }
|
|
404
|
+
.laptop .s1 { left: 13%; top: 11%; }
|
|
405
|
+
.laptop .s2 { left: 20%; top: 0; }
|
|
406
|
+
.phone .screen { width: 28%; }
|
|
407
|
+
.phone .s0 { left: 12%; top: 18%; }
|
|
408
|
+
.phone .s1 { left: 36%; top: 10%; }
|
|
409
|
+
.phone .s2 { left: 60%; top: 2%; }
|
|
410
|
+
.has-image .picture { left: 7%; top: 0; width: 100%; border-radius: 10px 0 0 0; }
|
|
411
|
+
|
|
412
|
+
/* Wide, from 760px of tile: words and figures left, pictures right. */
|
|
413
|
+
@container (min-width: 760px) {
|
|
414
|
+
.wide .frame {
|
|
415
|
+
flex-direction: row;
|
|
416
|
+
}
|
|
417
|
+
.wide .copy {
|
|
418
|
+
flex: 0 0 46%;
|
|
419
|
+
padding: clamp(32px, 4.5cqw, 56px);
|
|
420
|
+
padding-right: 0;
|
|
421
|
+
}
|
|
422
|
+
.wide .metrics { display: grid; }
|
|
423
|
+
.wide .title { font-size: clamp(2.25rem, 4.6cqw, 3.75rem); }
|
|
424
|
+
.wide .text { font-size: clamp(1rem, 1.5cqw, 1.25rem); }
|
|
425
|
+
.wide .art {
|
|
426
|
+
flex: 1 1 auto;
|
|
427
|
+
min-height: 38cqw;
|
|
428
|
+
margin-top: 0;
|
|
429
|
+
}
|
|
430
|
+
.wide.laptop .screen { width: 88%; }
|
|
431
|
+
.wide.laptop .s0 { left: 6%; top: 30%; }
|
|
432
|
+
.wide.laptop .s1 { left: 14%; top: 17%; }
|
|
433
|
+
.wide.laptop .s2 { left: 22%; top: 4%; }
|
|
434
|
+
.wide.phone .screen { width: 28%; }
|
|
435
|
+
.wide.phone .s0 { left: 10%; top: 16%; }
|
|
436
|
+
.wide.phone .s1 { left: 35%; top: 9%; }
|
|
437
|
+
.wide.phone .s2 { left: 60%; top: 2%; }
|
|
438
|
+
.wide.has-image .picture { left: 8%; top: 10%; }
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
442
|
+
.armed :is(.screen, .layer) {
|
|
443
|
+
opacity: 0;
|
|
444
|
+
translate: 0 48px;
|
|
445
|
+
}
|
|
446
|
+
.case-tile:is(:hover, :focus-visible) .layer { --lift: calc(var(--depth) * -20px); }
|
|
447
|
+
|
|
448
|
+
@media (hover: hover) {
|
|
449
|
+
.case-tile:hover {
|
|
450
|
+
translate: 0 -3px;
|
|
451
|
+
box-shadow: 0 24px 48px -24px rgb(0 0 0 / 0.6);
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
.case-tile:is(:hover, :focus-visible) .s0 { transform: translate(-1.5%, -2%); }
|
|
455
|
+
.case-tile:is(:hover, :focus-visible) .s1 { transform: translate(1%, -4%); }
|
|
456
|
+
.case-tile:is(:hover, :focus-visible) .s2 { transform: translate(3.5%, -6%); }
|
|
457
|
+
.case-tile.phone:is(:hover, :focus-visible) .s0 { transform: translate(-6%, -2%) rotate(-2deg); }
|
|
458
|
+
.case-tile.phone:is(:hover, :focus-visible) .s2 { transform: translate(6%, -5%) rotate(2deg); }
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
@media (max-width: 640px) {
|
|
462
|
+
.case-tile { border-radius: 18px; }
|
|
463
|
+
}
|
|
464
|
+
</style>
|
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
|
}
|