@n1kname/components 0.44.0 → 0.45.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 +16 -6
- package/src/ScreenStack.astro +26 -9
package/package.json
CHANGED
package/src/CaseTile.astro
CHANGED
|
@@ -116,10 +116,19 @@ const fit = (img: ImageMetadata) => {
|
|
|
116
116
|
return w.length ? w : [img.width];
|
|
117
117
|
};
|
|
118
118
|
const layerWidths = (img: ImageMetadata) => {
|
|
119
|
-
const w = [800, 1600].filter((x) => x <= img.width);
|
|
119
|
+
const w = [400, 800, 1200, 1600].filter((x) => x <= img.width);
|
|
120
120
|
return w.length ? w : [img.width];
|
|
121
121
|
};
|
|
122
|
+
// A layer is shown at its share of the stage, and the stage is the picture area: about the tile's
|
|
123
|
+
// width on a phone, and at most some 600px (half) or 700px (wide) beside it. Saying so lets a small
|
|
124
|
+
// card cut out of a page load a small file.
|
|
125
|
+
const layerSizes = (width: number) =>
|
|
126
|
+
`(max-width: 760px) ${Math.round(width * 0.85)}vw, ${Math.round(width * (layout === 'wide' ? 7 : 6))}px`;
|
|
122
127
|
const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
128
|
+
// The link is named title first, then the line, the overline and the note, so a screen reader
|
|
129
|
+
// hears the case before its dates. Ids from the href, so the build stays the same each run.
|
|
130
|
+
const uid = `case-tile-${href.replace(/[^a-z0-9]+/gi, '-').replace(/^-|-$/g, '') || 'home'}`;
|
|
131
|
+
const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-over`, note && `${uid}-note`].filter(Boolean).join(' ');
|
|
123
132
|
---
|
|
124
133
|
|
|
125
134
|
<a
|
|
@@ -127,13 +136,14 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
127
136
|
href={href}
|
|
128
137
|
style={`--tile-tone: ${tone}; ${patternStyle(pattern, ink)}`}
|
|
129
138
|
data-case-tile
|
|
139
|
+
aria-labelledby={labelledby}
|
|
130
140
|
>
|
|
131
141
|
<div class="frame">
|
|
132
142
|
<div class="copy">
|
|
133
|
-
{overline && <p class="overline">{overline}</p>}
|
|
134
|
-
<Heading class="title">{title}</Heading>
|
|
135
|
-
{text && <p class="text">{text}</p>}
|
|
136
|
-
{note && <p class="note">{note}</p>}
|
|
143
|
+
{overline && <p class="overline" id={`${uid}-over`}>{overline}</p>}
|
|
144
|
+
<Heading class="title" id={`${uid}-title`}>{title}</Heading>
|
|
145
|
+
{text && <p class="text" id={`${uid}-text`}>{text}</p>}
|
|
146
|
+
{note && <p class="note" id={`${uid}-note`}>{note}</p>}
|
|
137
147
|
{
|
|
138
148
|
figures.length > 0 && (
|
|
139
149
|
<dl class="metrics">
|
|
@@ -157,7 +167,7 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
157
167
|
{typeof l.image === 'string' ? (
|
|
158
168
|
<img src={l.image} alt={l.alt ?? ''} loading="lazy" />
|
|
159
169
|
) : (
|
|
160
|
-
<Image src={l.image} alt={l.alt ?? ''} widths={layerWidths(l.image)} sizes=
|
|
170
|
+
<Image src={l.image} alt={l.alt ?? ''} widths={layerWidths(l.image)} sizes={layerSizes(l.width)} format="webp" quality={80} loading="lazy" />
|
|
161
171
|
)}
|
|
162
172
|
</div>
|
|
163
173
|
))}
|
package/src/ScreenStack.astro
CHANGED
|
@@ -87,9 +87,15 @@ const sizes = phone
|
|
|
87
87
|
? size === 'cover' ? '(max-width: 640px) 30vw, 230px' : '(max-width: 640px) 22vw, 70px'
|
|
88
88
|
: size === 'cover' ? '(max-width: 900px) 80vw, 760px' : '(max-width: 640px) 70vw, 220px';
|
|
89
89
|
const layerWidths = (img: ImageMetadata) => {
|
|
90
|
-
const w = [800, 1600, 2400].filter((x) => x <= img.width);
|
|
90
|
+
const w = [400, 800, 1200, 1600, 2400].filter((x) => x <= img.width);
|
|
91
91
|
return w.length ? w : [img.width];
|
|
92
92
|
};
|
|
93
|
+
// A layer is shown at its share of the stage: on a cover about 56% of a panel up to some 1240px wide
|
|
94
|
+
// (76% on a phone), on a card about the card's width. Saying so lets a small card load a small file.
|
|
95
|
+
const layerSizes = (width: number) =>
|
|
96
|
+
size === 'cover'
|
|
97
|
+
? `(max-width: 640px) ${Math.round(width * 0.7)}vw, ${Math.round(width * 7)}px`
|
|
98
|
+
: `(max-width: 640px) ${Math.round(width * 0.9)}vw, ${Math.round(width * 3.6)}px`;
|
|
93
99
|
const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.width))];
|
|
94
100
|
---
|
|
95
101
|
|
|
@@ -111,7 +117,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
111
117
|
src={l.image}
|
|
112
118
|
alt={l.alt ?? ''}
|
|
113
119
|
widths={layerWidths(l.image)}
|
|
114
|
-
sizes=
|
|
120
|
+
sizes={layerSizes(l.width)}
|
|
115
121
|
format="webp"
|
|
116
122
|
quality={80}
|
|
117
123
|
loading={eager ? 'eager' : 'lazy'}
|
|
@@ -217,7 +223,11 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
217
223
|
margin: 0;
|
|
218
224
|
padding: 4px var(--sp-3);
|
|
219
225
|
border-radius: var(--radius-full);
|
|
220
|
-
|
|
226
|
+
/* Tinted from the panel and blurred, so it reads even where a picture runs under it. */
|
|
227
|
+
background: color-mix(in oklab, var(--stack-tone), black 30%);
|
|
228
|
+
background: color-mix(in oklab, color-mix(in oklab, var(--stack-tone), black 35%) 72%, transparent);
|
|
229
|
+
backdrop-filter: blur(10px);
|
|
230
|
+
-webkit-backdrop-filter: blur(10px);
|
|
221
231
|
color: #fff;
|
|
222
232
|
font-size: var(--text-caption);
|
|
223
233
|
line-height: 1.4;
|
|
@@ -274,7 +284,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
274
284
|
);
|
|
275
285
|
}
|
|
276
286
|
.ink-dark .note {
|
|
277
|
-
background:
|
|
287
|
+
background: color-mix(in oklab, color-mix(in oklab, var(--stack-tone), white 45%) 78%, transparent);
|
|
278
288
|
color: #17181a;
|
|
279
289
|
}
|
|
280
290
|
|
|
@@ -392,17 +402,24 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
392
402
|
.cover.laptop .screen {
|
|
393
403
|
width: 78%;
|
|
394
404
|
}
|
|
395
|
-
|
|
396
|
-
.cover.laptop .
|
|
405
|
+
/* On a phone the note takes the top, so the pictures start under it rather than behind it. */
|
|
406
|
+
.cover.laptop .s0 { left: 6%; top: 44%; }
|
|
407
|
+
.cover.laptop .s1 { left: 16%; top: 30%; }
|
|
397
408
|
.cover.laptop .s2 { display: none; }
|
|
398
409
|
|
|
399
410
|
/* Phones keep all three, larger, overlapping more. */
|
|
400
411
|
.cover.phone .screen {
|
|
401
412
|
width: 30%;
|
|
402
413
|
}
|
|
403
|
-
.cover.phone .s0 { left: 12%; top:
|
|
404
|
-
.cover.phone .s1 { left: 35%; top:
|
|
405
|
-
.cover.phone .s2 { left: 58%; top:
|
|
414
|
+
.cover.phone .s0 { left: 12%; top: 36%; }
|
|
415
|
+
.cover.phone .s1 { left: 35%; top: 31%; }
|
|
416
|
+
.cover.phone .s2 { left: 58%; top: 26%; }
|
|
417
|
+
|
|
418
|
+
.cover .stage {
|
|
419
|
+
right: -4%;
|
|
420
|
+
top: 28%;
|
|
421
|
+
width: 76%;
|
|
422
|
+
}
|
|
406
423
|
.cover.phone .note {
|
|
407
424
|
max-width: calc(100% - 2 * var(--sp-3));
|
|
408
425
|
}
|