@n1kname/components 0.47.0 → 0.49.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 +19 -10
- package/src/ScreenStack.astro +11 -5
- package/src/Screenshot.astro +11 -6
- package/src/Steps.astro +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1kname/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@n1kname/charts": "0.15.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@n1kname/tokens": "^0.
|
|
39
|
+
"@n1kname/tokens": "^0.9.0",
|
|
40
40
|
"astro": "^7.4.4"
|
|
41
41
|
},
|
|
42
42
|
"publishConfig": {
|
package/src/CaseTile.astro
CHANGED
|
@@ -33,6 +33,8 @@ interface Screen {
|
|
|
33
33
|
image: ImageMetadata | string;
|
|
34
34
|
/** Empty by default: the tile is one link, named by its words. */
|
|
35
35
|
alt?: string;
|
|
36
|
+
/** A plain URL's own size in px, so the space is kept while it loads. An import knows its own. */
|
|
37
|
+
size?: { width: number; height: number };
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
interface Layer {
|
|
@@ -46,6 +48,8 @@ interface Layer {
|
|
|
46
48
|
/** Bobs slowly on its own, down and back, so a card cut out of a page floats above it. */
|
|
47
49
|
float?: boolean;
|
|
48
50
|
alt?: string;
|
|
51
|
+
/** A plain URL's own size in px, so the space is kept while it loads. An import knows its own. */
|
|
52
|
+
size?: { width: number; height: number };
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
interface Props {
|
|
@@ -61,6 +65,8 @@ interface Props {
|
|
|
61
65
|
screens?: Screen[];
|
|
62
66
|
/** One picture instead of screens, such as a photo. */
|
|
63
67
|
image?: ImageMetadata | string;
|
|
68
|
+
/** A plain-URL `image`'s own size in px, so the space is kept while it loads. */
|
|
69
|
+
imageSize?: { width: number; height: number };
|
|
64
70
|
/** Separate pictures on a stage, in place of screens. */
|
|
65
71
|
layers?: Layer[];
|
|
66
72
|
/** The stage's width over its height. */
|
|
@@ -92,6 +98,7 @@ const {
|
|
|
92
98
|
metrics = [],
|
|
93
99
|
screens = [],
|
|
94
100
|
image,
|
|
101
|
+
imageSize,
|
|
95
102
|
layers = [],
|
|
96
103
|
stage = 4 / 3,
|
|
97
104
|
ink = 'light',
|
|
@@ -165,7 +172,7 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
165
172
|
{layers.map((l, i) => (
|
|
166
173
|
<div class:list={['layer', { float: l.float }]} style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
167
174
|
{typeof l.image === 'string' ? (
|
|
168
|
-
<img src={l.image} alt={l.alt ?? ''} loading="lazy" />
|
|
175
|
+
<img src={l.image} alt={l.alt ?? ''} width={l.size?.width} height={l.size?.height} loading="lazy" />
|
|
169
176
|
) : (
|
|
170
177
|
<Image src={l.image} alt={l.alt ?? ''} widths={layerWidths(l.image)} sizes={layerSizes(l.width)} format="webp" quality={80} loading="lazy" />
|
|
171
178
|
)}
|
|
@@ -183,7 +190,7 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
183
190
|
return (
|
|
184
191
|
<div class={`screen s${i}`}>
|
|
185
192
|
{typeof s.image === 'string' ? (
|
|
186
|
-
<img src={s.image} alt={s.alt ?? ''} loading="lazy" />
|
|
193
|
+
<img src={s.image} alt={s.alt ?? ''} width={s.size?.width} height={s.size?.height} loading="lazy" />
|
|
187
194
|
) : (
|
|
188
195
|
<Image src={s.image} alt={s.alt ?? ''} widths={fit(s.image)} sizes={sizes} format="webp" quality={80} loading="lazy" />
|
|
189
196
|
)}
|
|
@@ -193,7 +200,7 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
193
200
|
: image && (
|
|
194
201
|
<div class="screen picture s0">
|
|
195
202
|
{typeof image === 'string' ? (
|
|
196
|
-
<img src={image} alt="" loading="lazy" />
|
|
203
|
+
<img src={image} alt="" width={imageSize?.width} height={imageSize?.height} loading="lazy" />
|
|
197
204
|
) : (
|
|
198
205
|
<Image src={image} alt="" widths={fit(image)} sizes="(max-width: 760px) 90vw, 700px" format="webp" quality={78} loading="lazy" />
|
|
199
206
|
)}
|
|
@@ -363,9 +370,9 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
363
370
|
0 1px 2px rgb(0 0 0 / 0.2),
|
|
364
371
|
0 30px 60px -16px rgb(0 0 0 / 0.5);
|
|
365
372
|
transition:
|
|
366
|
-
transform
|
|
367
|
-
translate 900ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
368
|
-
opacity 700ms ease-out;
|
|
373
|
+
transform var(--motion-grow, 700ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
374
|
+
translate var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
375
|
+
opacity var(--motion-grow, 700ms) var(--ease-out, ease-out);
|
|
369
376
|
}
|
|
370
377
|
|
|
371
378
|
.screen :global(img) {
|
|
@@ -387,9 +394,9 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
387
394
|
--lift: 0px;
|
|
388
395
|
transform: translateY(var(--lift));
|
|
389
396
|
transition:
|
|
390
|
-
transform 700ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
391
|
-
translate 900ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
392
|
-
opacity 700ms ease-out;
|
|
397
|
+
transform var(--motion-grow, 700ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
398
|
+
translate var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
399
|
+
opacity var(--motion-grow, 700ms) var(--ease-out, ease-out);
|
|
393
400
|
transition-delay: 0ms, calc(var(--i) * 90ms), calc(var(--i) * 90ms);
|
|
394
401
|
}
|
|
395
402
|
|
|
@@ -496,7 +503,9 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
496
503
|
* and the arrival instead of replacing them. */
|
|
497
504
|
@media (prefers-reduced-motion: no-preference) {
|
|
498
505
|
.layer.float :global(img) {
|
|
499
|
-
|
|
506
|
+
/* Three slow breaths, then still: anything moving on its own for more than five seconds
|
|
507
|
+
* next to other content needs to stop (WCAG 2.2.2). */
|
|
508
|
+
animation: layer-float var(--motion-float, 6s) ease-in-out 3;
|
|
500
509
|
}
|
|
501
510
|
}
|
|
502
511
|
|
package/src/ScreenStack.astro
CHANGED
|
@@ -33,6 +33,8 @@ import { patternStyle, type Pattern } from './patterns';
|
|
|
33
33
|
interface Screen {
|
|
34
34
|
image: ImageMetadata | string;
|
|
35
35
|
alt: string;
|
|
36
|
+
/** A plain URL's own size in px, so the space is kept while it loads. An import knows its own. */
|
|
37
|
+
size?: { width: number; height: number };
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
interface Layer {
|
|
@@ -46,6 +48,8 @@ interface Layer {
|
|
|
46
48
|
/** Bobs slowly on its own, down and back, so a card cut out of a page floats above it. */
|
|
47
49
|
float?: boolean;
|
|
48
50
|
alt?: string;
|
|
51
|
+
/** A plain URL's own size in px, so the space is kept while it loads. An import knows its own. */
|
|
52
|
+
size?: { width: number; height: number };
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
interface Props {
|
|
@@ -111,7 +115,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
111
115
|
{layers.map((l, i) => (
|
|
112
116
|
<div class:list={['layer', { float: l.float }]} style={`left: ${l.x}%; top: ${l.y}%; width: ${l.width}%; --depth: ${l.depth ?? 0}; --i: ${i}`}>
|
|
113
117
|
{typeof l.image === 'string' ? (
|
|
114
|
-
<img src={l.image} alt={l.alt ?? ''} loading={eager ? 'eager' : 'lazy'} />
|
|
118
|
+
<img src={l.image} alt={l.alt ?? ''} width={l.size?.width} height={l.size?.height} loading={eager ? 'eager' : 'lazy'} />
|
|
115
119
|
) : (
|
|
116
120
|
<Image
|
|
117
121
|
src={l.image}
|
|
@@ -135,7 +139,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
135
139
|
return (
|
|
136
140
|
<div class={`screen s${i}`}>
|
|
137
141
|
{typeof s.image === 'string' ? (
|
|
138
|
-
<img src={s.image} alt={s.alt} loading={eager && first ? 'eager' : 'lazy'} />
|
|
142
|
+
<img src={s.image} alt={s.alt} width={s.size?.width} height={s.size?.height} loading={eager && first ? 'eager' : 'lazy'} />
|
|
139
143
|
) : (
|
|
140
144
|
<Image
|
|
141
145
|
src={s.image}
|
|
@@ -253,7 +257,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
253
257
|
position: absolute;
|
|
254
258
|
--lift: 0px;
|
|
255
259
|
transform: translate(calc(var(--px) * var(--depth) * 16px), calc(var(--py) * var(--depth) * 12px + var(--lift)));
|
|
256
|
-
transition: transform 700ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1));
|
|
260
|
+
transition: transform var(--motion-grow, 700ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1));
|
|
257
261
|
}
|
|
258
262
|
|
|
259
263
|
.layer :global(img) {
|
|
@@ -296,7 +300,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
296
300
|
box-shadow:
|
|
297
301
|
0 1px 2px rgb(0 0 0 / 0.18),
|
|
298
302
|
0 24px 60px -12px rgb(0 0 0 / 0.45);
|
|
299
|
-
transition: transform 700ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1));
|
|
303
|
+
transition: transform var(--motion-grow, 700ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1));
|
|
300
304
|
}
|
|
301
305
|
|
|
302
306
|
.screen :global(img) {
|
|
@@ -429,7 +433,9 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
429
433
|
* and the arrival instead of replacing them. */
|
|
430
434
|
@media (prefers-reduced-motion: no-preference) {
|
|
431
435
|
.layer.float :global(img) {
|
|
432
|
-
|
|
436
|
+
/* Three slow breaths, then still: anything moving on its own for more than five seconds
|
|
437
|
+
* next to other content needs to stop (WCAG 2.2.2). */
|
|
438
|
+
animation: layer-float var(--motion-float, 6s) ease-in-out 3;
|
|
433
439
|
}
|
|
434
440
|
}
|
|
435
441
|
|
package/src/Screenshot.astro
CHANGED
|
@@ -25,7 +25,8 @@ interface Props {
|
|
|
25
25
|
caption?: string;
|
|
26
26
|
/** Widest the shot is drawn, in px. Keep it well under the source's width. */
|
|
27
27
|
maxWidth?: number;
|
|
28
|
-
/** The placeholder's size
|
|
28
|
+
/** The shot's size in px: the placeholder's size, and a plain URL's, so the space is kept while it
|
|
29
|
+
* loads. An import reports its own. */
|
|
29
30
|
width?: number;
|
|
30
31
|
height?: number;
|
|
31
32
|
/** Keep the light plate in dark mode, for transparent artwork with dark labels. */
|
|
@@ -40,8 +41,8 @@ const {
|
|
|
40
41
|
alt,
|
|
41
42
|
caption,
|
|
42
43
|
maxWidth = 680,
|
|
43
|
-
width
|
|
44
|
-
height
|
|
44
|
+
width,
|
|
45
|
+
height,
|
|
45
46
|
lightPlate = false,
|
|
46
47
|
placeholder = 'Screenshot to add',
|
|
47
48
|
class: className,
|
|
@@ -49,6 +50,10 @@ const {
|
|
|
49
50
|
|
|
50
51
|
const asset = image && typeof image !== 'string' && image.format !== 'svg' ? image : undefined;
|
|
51
52
|
const url = typeof image === 'string' ? image : image && !asset ? image.src : undefined;
|
|
53
|
+
// A plain URL's size comes from the props; an imported SVG knows its own.
|
|
54
|
+
const urlSize = typeof image === 'string' ? { width, height } : image && !asset ? { width: image.width, height: image.height } : { width: undefined, height: undefined };
|
|
55
|
+
// The placeholder needs a shape even when none is given.
|
|
56
|
+
const box = { width: width ?? 1600, height: height ?? 1000 };
|
|
52
57
|
|
|
53
58
|
// The cap and its 2x for sharp screens, never past what the source holds.
|
|
54
59
|
const widths = asset ? [...new Set([maxWidth, maxWidth * 2].filter((w) => w <= asset.width))] : [];
|
|
@@ -70,12 +75,12 @@ if (asset && widths.length === 0) widths.push(asset.width);
|
|
|
70
75
|
style={`max-width: ${maxWidth}px`}
|
|
71
76
|
/>
|
|
72
77
|
) : url ? (
|
|
73
|
-
<img src={url} alt={alt} loading="lazy" style={`max-width: ${maxWidth}px`} />
|
|
78
|
+
<img src={url} alt={alt} width={urlSize.width} height={urlSize.height} loading="lazy" style={`max-width: ${maxWidth}px`} />
|
|
74
79
|
) : (
|
|
75
|
-
<div class="placeholder" role="img" aria-label={`Placeholder. ${alt}`} style={`max-width: ${maxWidth}px; aspect-ratio: ${width} / ${height}`}>
|
|
80
|
+
<div class="placeholder" role="img" aria-label={`Placeholder. ${alt}`} style={`max-width: ${maxWidth}px; aspect-ratio: ${box.width} / ${box.height}`}>
|
|
76
81
|
<span class="label">{placeholder}</span>
|
|
77
82
|
<span class="spec">
|
|
78
|
-
{width} × {height}
|
|
83
|
+
{box.width} × {box.height}
|
|
79
84
|
</span>
|
|
80
85
|
<span class="brief">{alt}</span>
|
|
81
86
|
</div>
|
package/src/Steps.astro
CHANGED
|
@@ -20,6 +20,8 @@ interface Step {
|
|
|
20
20
|
image?: ImageMetadata | string;
|
|
21
21
|
/** What the picture shows. */
|
|
22
22
|
alt?: string;
|
|
23
|
+
/** A plain URL's own size in px, so the space is kept while it loads. An import knows its own. */
|
|
24
|
+
size?: { width: number; height: number };
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
interface Props {
|
|
@@ -54,7 +56,7 @@ const { steps, caption, phone = false, class: className } = Astro.props;
|
|
|
54
56
|
loading="lazy"
|
|
55
57
|
/>
|
|
56
58
|
) : s.image ? (
|
|
57
|
-
<img src={s.image} alt={s.alt ?? ''} loading="lazy" />
|
|
59
|
+
<img src={s.image} alt={s.alt ?? ''} width={s.size?.width} height={s.size?.height} loading="lazy" />
|
|
58
60
|
) : (
|
|
59
61
|
<div class="placeholder" role="img" aria-label={`Placeholder. ${s.alt ?? s.label}`}>
|
|
60
62
|
<span>{s.label}</span>
|