@n1kname/components 0.41.0 → 0.43.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 +114 -6
- package/src/ScreenStack.astro +122 -7
- package/src/patterns.ts +42 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1kname/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.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
|
|
@@ -18,6 +22,7 @@
|
|
|
18
22
|
*/
|
|
19
23
|
import type { ImageMetadata } from 'astro';
|
|
20
24
|
import { Image } from 'astro:assets';
|
|
25
|
+
import { patternStyle, type Pattern } from './patterns';
|
|
21
26
|
|
|
22
27
|
interface Metric {
|
|
23
28
|
value: string;
|
|
@@ -30,6 +35,17 @@ interface Screen {
|
|
|
30
35
|
alt?: string;
|
|
31
36
|
}
|
|
32
37
|
|
|
38
|
+
interface Layer {
|
|
39
|
+
image: ImageMetadata | string;
|
|
40
|
+
/** Position and width on the stage, in percent of its width (x, width) and height (y). */
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
width: number;
|
|
44
|
+
/** How far it floats on hover: 0 stays put, 1 lifts the most. */
|
|
45
|
+
depth?: number;
|
|
46
|
+
alt?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
33
49
|
interface Props {
|
|
34
50
|
href: string;
|
|
35
51
|
/** The project's name, set large. */
|
|
@@ -43,6 +59,16 @@ interface Props {
|
|
|
43
59
|
screens?: Screen[];
|
|
44
60
|
/** One picture instead of screens, such as a photo. */
|
|
45
61
|
image?: ImageMetadata | string;
|
|
62
|
+
/** Separate pictures on a stage, in place of screens. */
|
|
63
|
+
layers?: Layer[];
|
|
64
|
+
/** The stage's width over its height. */
|
|
65
|
+
stage?: number;
|
|
66
|
+
/** Dark words for a light tone. */
|
|
67
|
+
ink?: 'light' | 'dark';
|
|
68
|
+
/** The panel's texture: dots (default), grid, lines, plus, waves or none. */
|
|
69
|
+
pattern?: Pattern;
|
|
70
|
+
/** Fade the pattern out toward the bottom left, so it reads as texture. On by default. */
|
|
71
|
+
patternFade?: boolean;
|
|
46
72
|
device?: 'laptop' | 'phone';
|
|
47
73
|
layout?: 'wide' | 'half';
|
|
48
74
|
/** The tile colour, deep enough for white text. */
|
|
@@ -64,6 +90,11 @@ const {
|
|
|
64
90
|
metrics = [],
|
|
65
91
|
screens = [],
|
|
66
92
|
image,
|
|
93
|
+
layers = [],
|
|
94
|
+
stage = 4 / 3,
|
|
95
|
+
ink = 'light',
|
|
96
|
+
pattern = 'dots',
|
|
97
|
+
patternFade = true,
|
|
67
98
|
device = 'laptop',
|
|
68
99
|
layout = 'half',
|
|
69
100
|
tone = 'var(--c-accent)',
|
|
@@ -82,13 +113,17 @@ const fit = (img: ImageMetadata) => {
|
|
|
82
113
|
const w = widths.filter((x) => x <= img.width);
|
|
83
114
|
return w.length ? w : [img.width];
|
|
84
115
|
};
|
|
116
|
+
const layerWidths = (img: ImageMetadata) => {
|
|
117
|
+
const w = [800, 1600].filter((x) => x <= img.width);
|
|
118
|
+
return w.length ? w : [img.width];
|
|
119
|
+
};
|
|
85
120
|
const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
86
121
|
---
|
|
87
122
|
|
|
88
123
|
<a
|
|
89
|
-
class:list={['case-tile', layout, device, { 'has-image': !shots.length && image }, className]}
|
|
124
|
+
class:list={['case-tile', layout, device, `ink-${ink}`, { 'pattern-fade': patternFade, 'has-image': !shots.length && !layers.length && image, 'has-layers': layers.length }, className]}
|
|
90
125
|
href={href}
|
|
91
|
-
style={`--tile-tone: ${tone}`}
|
|
126
|
+
style={`--tile-tone: ${tone}; ${patternStyle(pattern, ink)}`}
|
|
92
127
|
data-case-tile
|
|
93
128
|
>
|
|
94
129
|
<div class="frame">
|
|
@@ -113,7 +148,24 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
113
148
|
|
|
114
149
|
<div class="art" style={transition ? `view-transition-name: ${transition}; view-transition-class: media` : undefined}>
|
|
115
150
|
{
|
|
116
|
-
|
|
151
|
+
layers.length > 0 && (
|
|
152
|
+
<div class="stage" style={`aspect-ratio: ${stage}`}>
|
|
153
|
+
{layers.map((l, i) => (
|
|
154
|
+
<div class="layer" style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
155
|
+
{typeof l.image === 'string' ? (
|
|
156
|
+
<img src={l.image} alt={l.alt ?? ''} loading="lazy" />
|
|
157
|
+
) : (
|
|
158
|
+
<Image src={l.image} alt={l.alt ?? ''} widths={layerWidths(l.image)} sizes="(max-width: 760px) 90vw, 700px" format="webp" quality={80} loading="lazy" />
|
|
159
|
+
)}
|
|
160
|
+
</div>
|
|
161
|
+
))}
|
|
162
|
+
</div>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
{
|
|
166
|
+
layers.length > 0
|
|
167
|
+
? null
|
|
168
|
+
: shots.length > 0
|
|
117
169
|
? order.map((i) => {
|
|
118
170
|
const s = shots[i];
|
|
119
171
|
return (
|
|
@@ -175,7 +227,6 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
175
227
|
color: #fff;
|
|
176
228
|
text-decoration: none;
|
|
177
229
|
background:
|
|
178
|
-
radial-gradient(circle at 1px 1px, rgb(255 255 255 / 0.13) 1px, transparent 0) 0 0 / 22px 22px,
|
|
179
230
|
linear-gradient(
|
|
180
231
|
150deg,
|
|
181
232
|
color-mix(in oklab, var(--tile-tone), white 10%),
|
|
@@ -187,6 +238,19 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
187
238
|
box-shadow var(--motion-hover, 160ms) var(--ease-hover, ease-out);
|
|
188
239
|
}
|
|
189
240
|
|
|
241
|
+
/* The pattern, on a layer of its own so it can fade out toward the bottom left. */
|
|
242
|
+
.case-tile::before {
|
|
243
|
+
content: '';
|
|
244
|
+
position: absolute;
|
|
245
|
+
inset: 0;
|
|
246
|
+
z-index: 0;
|
|
247
|
+
pointer-events: none;
|
|
248
|
+
background: var(--pattern-image) 0 0 / var(--pattern-size);
|
|
249
|
+
}
|
|
250
|
+
.pattern-fade::before {
|
|
251
|
+
mask-image: radial-gradient(130% 110% at 100% 0%, #000 25%, transparent 80%);
|
|
252
|
+
}
|
|
253
|
+
|
|
190
254
|
.case-tile:focus-visible {
|
|
191
255
|
outline: 3px solid var(--c-focus, #fff);
|
|
192
256
|
outline-offset: 3px;
|
|
@@ -298,6 +362,49 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
298
362
|
height: auto;
|
|
299
363
|
}
|
|
300
364
|
|
|
365
|
+
/* Layers: pictures that carry their own shadows, on a stage the size of the picture area's width. */
|
|
366
|
+
.stage {
|
|
367
|
+
position: absolute;
|
|
368
|
+
left: 0;
|
|
369
|
+
top: 0;
|
|
370
|
+
width: 100%;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.layer {
|
|
374
|
+
position: absolute;
|
|
375
|
+
--lift: 0px;
|
|
376
|
+
transform: translateY(var(--lift));
|
|
377
|
+
transition:
|
|
378
|
+
transform 700ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
379
|
+
translate 900ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
380
|
+
opacity 700ms ease-out;
|
|
381
|
+
transition-delay: 0ms, calc(var(--i) * 90ms), calc(var(--i) * 90ms);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.layer :global(img) {
|
|
385
|
+
display: block;
|
|
386
|
+
width: 100%;
|
|
387
|
+
height: auto;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/* Dark ink, for a light tone. */
|
|
391
|
+
.ink-dark {
|
|
392
|
+
color: #17181a;
|
|
393
|
+
background:
|
|
394
|
+
linear-gradient(
|
|
395
|
+
150deg,
|
|
396
|
+
color-mix(in oklab, var(--tile-tone), white 14%),
|
|
397
|
+
var(--tile-tone) 50%,
|
|
398
|
+
color-mix(in oklab, var(--tile-tone), black 10%)
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
.ink-dark .title { color: #17181a; }
|
|
402
|
+
.ink-dark .overline { color: rgb(0 0 0 / 0.66); }
|
|
403
|
+
.ink-dark .text { color: rgb(0 0 0 / 0.8); }
|
|
404
|
+
.ink-dark .note { background: rgb(0 0 0 / 0.1); color: #17181a; }
|
|
405
|
+
.ink-dark .metrics { border-top-color: rgb(0 0 0 / 0.2); }
|
|
406
|
+
.ink-dark .metrics dd { color: rgb(0 0 0 / 0.7); }
|
|
407
|
+
|
|
301
408
|
.s0 { z-index: 3; }
|
|
302
409
|
.s1 { z-index: 2; transition-delay: 0ms, 90ms, 90ms; }
|
|
303
410
|
.s2 { z-index: 1; transition-delay: 0ms, 180ms, 180ms; }
|
|
@@ -350,10 +457,11 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
350
457
|
}
|
|
351
458
|
|
|
352
459
|
@media (prefers-reduced-motion: no-preference) {
|
|
353
|
-
.armed .screen {
|
|
460
|
+
.armed :is(.screen, .layer) {
|
|
354
461
|
opacity: 0;
|
|
355
462
|
translate: 0 48px;
|
|
356
463
|
}
|
|
464
|
+
.case-tile:is(:hover, :focus-visible) .layer { --lift: calc(var(--depth) * -20px); }
|
|
357
465
|
|
|
358
466
|
@media (hover: hover) {
|
|
359
467
|
.case-tile:hover {
|
package/src/ScreenStack.astro
CHANGED
|
@@ -16,21 +16,47 @@
|
|
|
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.
|
|
22
26
|
*/
|
|
23
27
|
import type { ImageMetadata } from 'astro';
|
|
24
28
|
import { Image } from 'astro:assets';
|
|
29
|
+
import { patternStyle, type Pattern } from './patterns';
|
|
25
30
|
|
|
26
31
|
interface Screen {
|
|
27
32
|
image: ImageMetadata | string;
|
|
28
33
|
alt: string;
|
|
29
34
|
}
|
|
30
35
|
|
|
36
|
+
interface Layer {
|
|
37
|
+
image: ImageMetadata | string;
|
|
38
|
+
/** Position and width on the stage, in percent of its width (x, width) and height (y). */
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
width: number;
|
|
42
|
+
/** 0 stays put; 1 follows the pointer and lifts the most. */
|
|
43
|
+
depth?: number;
|
|
44
|
+
alt?: string;
|
|
45
|
+
}
|
|
46
|
+
|
|
31
47
|
interface Props {
|
|
32
48
|
/** Two or three; any more are left out. The first sits in front. */
|
|
33
|
-
screens
|
|
49
|
+
screens?: Screen[];
|
|
50
|
+
/** Separate pictures on a stage, in place of screens. */
|
|
51
|
+
layers?: Layer[];
|
|
52
|
+
/** The stage's width over its height. */
|
|
53
|
+
stage?: number;
|
|
54
|
+
/** Dark ink on the note, for a light tone. */
|
|
55
|
+
ink?: 'light' | 'dark';
|
|
56
|
+
/** The panel's texture: dots (default), grid, lines, plus, waves or none. */
|
|
57
|
+
pattern?: Pattern;
|
|
58
|
+
/** Fade the pattern out toward the bottom left, so it reads as texture. On by default. */
|
|
59
|
+
patternFade?: boolean;
|
|
34
60
|
/** The panel colour: a CSS colour, deep enough for white text, such as a client's brand blue. */
|
|
35
61
|
tone?: string;
|
|
36
62
|
note?: string;
|
|
@@ -47,7 +73,7 @@ interface Props {
|
|
|
47
73
|
class?: string;
|
|
48
74
|
}
|
|
49
75
|
|
|
50
|
-
const { screens, tone = 'var(--c-accent)', note, size = 'cover', device = 'laptop', transition, eager = size === 'cover', parallax = size === 'cover', class: className } = Astro.props;
|
|
76
|
+
const { screens = [], layers = [], stage = 4 / 3, ink = 'light', pattern = 'dots', patternFade = true, tone = 'var(--c-accent)', note, size = 'cover', device = 'laptop', transition, eager = size === 'cover', parallax = size === 'cover', class: className } = Astro.props;
|
|
51
77
|
const shots = screens.slice(0, 3);
|
|
52
78
|
// Back to front, so the first screen paints last and sits on top.
|
|
53
79
|
const order = [...shots.keys()].reverse();
|
|
@@ -56,17 +82,44 @@ const widths = phone ? (size === 'cover' ? [240, 480, 720] : [160, 320]) : size
|
|
|
56
82
|
const sizes = phone
|
|
57
83
|
? size === 'cover' ? '(max-width: 640px) 30vw, 230px' : '(max-width: 640px) 22vw, 70px'
|
|
58
84
|
: size === 'cover' ? '(max-width: 900px) 80vw, 760px' : '(max-width: 640px) 70vw, 220px';
|
|
85
|
+
const layerWidths = (img: ImageMetadata) => {
|
|
86
|
+
const w = [800, 1600, 2400].filter((x) => x <= img.width);
|
|
87
|
+
return w.length ? w : [img.width];
|
|
88
|
+
};
|
|
59
89
|
const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.width))];
|
|
60
90
|
---
|
|
61
91
|
|
|
62
92
|
<div
|
|
63
|
-
class:list={['screen-stack', size, device, `n${shots.length}`, className]}
|
|
64
|
-
style={`--stack-tone: ${tone}
|
|
93
|
+
class:list={['screen-stack', size, device, `n${shots.length}`, `ink-${ink}`, { 'has-layers': layers.length, 'pattern-fade': patternFade }, className]}
|
|
94
|
+
style={`--stack-tone: ${tone}; ${patternStyle(pattern, ink)}${transition ? ` view-transition-name: ${transition}; view-transition-class: media;` : ''}`}
|
|
65
95
|
data-screen-stack-parallax={parallax ? '' : undefined}
|
|
66
96
|
>
|
|
67
97
|
{note && <p class="note">{note}</p>}
|
|
68
98
|
{
|
|
69
|
-
|
|
99
|
+
layers.length > 0 && (
|
|
100
|
+
<div class="stage" style={`aspect-ratio: ${stage}`}>
|
|
101
|
+
{layers.map((l, i) => (
|
|
102
|
+
<div class="layer" style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
103
|
+
{typeof l.image === 'string' ? (
|
|
104
|
+
<img src={l.image} alt={l.alt ?? ''} loading={eager ? 'eager' : 'lazy'} />
|
|
105
|
+
) : (
|
|
106
|
+
<Image
|
|
107
|
+
src={l.image}
|
|
108
|
+
alt={l.alt ?? ''}
|
|
109
|
+
widths={layerWidths(l.image)}
|
|
110
|
+
sizes="(max-width: 900px) 90vw, 1000px"
|
|
111
|
+
format="webp"
|
|
112
|
+
quality={80}
|
|
113
|
+
loading={eager ? 'eager' : 'lazy'}
|
|
114
|
+
/>
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
))}
|
|
118
|
+
</div>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
{
|
|
122
|
+
layers.length > 0 ? null : order.map((i) => {
|
|
70
123
|
const s = shots[i];
|
|
71
124
|
const first = i === 0;
|
|
72
125
|
return (
|
|
@@ -126,7 +179,6 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
126
179
|
aspect-ratio: 20 / 9;
|
|
127
180
|
border-radius: var(--radius-lg);
|
|
128
181
|
background:
|
|
129
|
-
radial-gradient(circle at 1px 1px, rgb(255 255 255 / 0.14) 1px, transparent 0) 0 0 / 22px 22px,
|
|
130
182
|
linear-gradient(
|
|
131
183
|
140deg,
|
|
132
184
|
color-mix(in oklab, var(--stack-tone), white 12%),
|
|
@@ -135,10 +187,22 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
135
187
|
);
|
|
136
188
|
}
|
|
137
189
|
|
|
190
|
+
/* The pattern, on a layer of its own so it can fade out toward the bottom left. */
|
|
191
|
+
.screen-stack::before {
|
|
192
|
+
content: '';
|
|
193
|
+
position: absolute;
|
|
194
|
+
inset: 0;
|
|
195
|
+
z-index: 0;
|
|
196
|
+
pointer-events: none;
|
|
197
|
+
background: var(--pattern-image) 0 0 / var(--pattern-size);
|
|
198
|
+
}
|
|
199
|
+
.pattern-fade::before {
|
|
200
|
+
mask-image: radial-gradient(130% 110% at 100% 0%, #000 25%, transparent 80%);
|
|
201
|
+
}
|
|
202
|
+
|
|
138
203
|
.card {
|
|
139
204
|
aspect-ratio: 16 / 9;
|
|
140
205
|
border-radius: var(--radius-sm);
|
|
141
|
-
background-size: 14px 14px, auto;
|
|
142
206
|
}
|
|
143
207
|
|
|
144
208
|
.note {
|
|
@@ -163,6 +227,53 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
163
227
|
font-size: 11px;
|
|
164
228
|
}
|
|
165
229
|
|
|
230
|
+
/* Layers on a stage over the right of the panel; they carry their own shadows. */
|
|
231
|
+
.stage {
|
|
232
|
+
position: absolute;
|
|
233
|
+
right: 4%;
|
|
234
|
+
top: 6%;
|
|
235
|
+
width: 56%;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
.layer {
|
|
239
|
+
position: absolute;
|
|
240
|
+
--lift: 0px;
|
|
241
|
+
transform: translate(calc(var(--px) * var(--depth) * 16px), calc(var(--py) * var(--depth) * 12px + var(--lift)));
|
|
242
|
+
transition: transform 700ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1));
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.layer :global(img) {
|
|
246
|
+
display: block;
|
|
247
|
+
width: 100%;
|
|
248
|
+
height: auto;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
@media (prefers-reduced-motion: no-preference) and (hover: hover) {
|
|
252
|
+
.screen-stack:hover .layer {
|
|
253
|
+
--lift: calc(var(--depth) * -14px);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.card .stage {
|
|
258
|
+
right: -10%;
|
|
259
|
+
top: -8%;
|
|
260
|
+
width: 100%;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.ink-dark {
|
|
264
|
+
background:
|
|
265
|
+
linear-gradient(
|
|
266
|
+
140deg,
|
|
267
|
+
color-mix(in oklab, var(--stack-tone), white 14%),
|
|
268
|
+
var(--stack-tone) 55%,
|
|
269
|
+
color-mix(in oklab, var(--stack-tone), black 10%)
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
.ink-dark .note {
|
|
273
|
+
background: rgb(0 0 0 / 0.1);
|
|
274
|
+
color: #17181a;
|
|
275
|
+
}
|
|
276
|
+
|
|
166
277
|
.screen {
|
|
167
278
|
position: absolute;
|
|
168
279
|
width: 58%;
|
|
@@ -233,6 +344,10 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
233
344
|
.card.phone .s2 { left: 55%; top: 2%; }
|
|
234
345
|
|
|
235
346
|
@media (prefers-reduced-motion: no-preference) {
|
|
347
|
+
.layer {
|
|
348
|
+
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) * 90ms);
|
|
350
|
+
}
|
|
236
351
|
.screen {
|
|
237
352
|
animation: stack-in var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)) both;
|
|
238
353
|
}
|
package/src/patterns.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Background patterns for coloured panels (CaseTile, ScreenStack): a small SVG tile, drawn in white
|
|
3
|
+
* for a deep tone or black for a light one, at low opacity. Each is a single image, so a component
|
|
4
|
+
* can put it on its own layer and fade it with a mask.
|
|
5
|
+
*
|
|
6
|
+
* dots a dot every 22px, the default
|
|
7
|
+
* grid a hairline grid at 32px
|
|
8
|
+
* lines diagonal hairlines, 12px apart
|
|
9
|
+
* plus small plus marks at 28px, like registration marks
|
|
10
|
+
* waves soft horizontal waves
|
|
11
|
+
* none no pattern, the gradient alone
|
|
12
|
+
*/
|
|
13
|
+
export const PATTERNS = ['dots', 'grid', 'lines', 'plus', 'waves', 'none'] as const;
|
|
14
|
+
export type Pattern = (typeof PATTERNS)[number];
|
|
15
|
+
|
|
16
|
+
const svg = (w: number, h: number, body: string) =>
|
|
17
|
+
`url("data:image/svg+xml,${encodeURIComponent(`<svg xmlns='http://www.w3.org/2000/svg' width='${w}' height='${h}'>${body}</svg>`)}")`;
|
|
18
|
+
|
|
19
|
+
export const pattern = (name: Pattern = 'dots', ink: 'light' | 'dark' = 'light') => {
|
|
20
|
+
const c = ink === 'dark' ? '#000' : '#fff';
|
|
21
|
+
const o = (light: number, dark: number) => (ink === 'dark' ? dark : light);
|
|
22
|
+
switch (name) {
|
|
23
|
+
case 'grid':
|
|
24
|
+
return { image: svg(32, 32, `<path d='M32 .5H.5V32' fill='none' stroke='${c}' stroke-opacity='${o(0.11, 0.08)}'/>`), size: '32px 32px' };
|
|
25
|
+
case 'lines':
|
|
26
|
+
return { image: svg(12, 12, `<path d='M-3 3 3-3M0 12 12 0M9 15l6-6' stroke='${c}' stroke-opacity='${o(0.1, 0.07)}'/>`), size: '12px 12px' };
|
|
27
|
+
case 'plus':
|
|
28
|
+
return { image: svg(28, 28, `<path d='M14 10.5v7M10.5 14h7' stroke='${c}' stroke-opacity='${o(0.22, 0.14)}' stroke-linecap='round'/>`), size: '28px 28px' };
|
|
29
|
+
case 'waves':
|
|
30
|
+
return { image: svg(96, 20, `<path d='M0 10c16-8 32-8 48 0s32 8 48 0' fill='none' stroke='${c}' stroke-opacity='${o(0.12, 0.08)}'/>`), size: '96px 20px' };
|
|
31
|
+
case 'none':
|
|
32
|
+
return { image: 'none', size: 'auto' };
|
|
33
|
+
default:
|
|
34
|
+
return { image: svg(22, 22, `<circle cx='1' cy='1' r='1' fill='${c}' fill-opacity='${o(0.16, 0.11)}'/>`), size: '22px 22px' };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/** The inline custom properties a component sets on its root for its pattern layer. */
|
|
39
|
+
export const patternStyle = (name?: Pattern, ink?: 'light' | 'dark') => {
|
|
40
|
+
const p = pattern(name, ink);
|
|
41
|
+
return `--pattern-image: ${p.image}; --pattern-size: ${p.size};`;
|
|
42
|
+
};
|