@n1kname/components 0.46.0 → 0.48.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 +9 -7
- package/src/ChartFigure.astro +108 -0
- package/src/ScreenStack.astro +5 -3
- package/src/Screenshot.astro +166 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@n1kname/components",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.48.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
|
@@ -363,9 +363,9 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
363
363
|
0 1px 2px rgb(0 0 0 / 0.2),
|
|
364
364
|
0 30px 60px -16px rgb(0 0 0 / 0.5);
|
|
365
365
|
transition:
|
|
366
|
-
transform
|
|
367
|
-
translate 900ms var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
368
|
-
opacity 700ms ease-out;
|
|
366
|
+
transform var(--motion-grow, 700ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
367
|
+
translate var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
368
|
+
opacity var(--motion-grow, 700ms) var(--ease-out, ease-out);
|
|
369
369
|
}
|
|
370
370
|
|
|
371
371
|
.screen :global(img) {
|
|
@@ -387,9 +387,9 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
387
387
|
--lift: 0px;
|
|
388
388
|
transform: translateY(var(--lift));
|
|
389
389
|
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;
|
|
390
|
+
transform var(--motion-grow, 700ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
391
|
+
translate var(--motion-reveal, 900ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1)),
|
|
392
|
+
opacity var(--motion-grow, 700ms) var(--ease-out, ease-out);
|
|
393
393
|
transition-delay: 0ms, calc(var(--i) * 90ms), calc(var(--i) * 90ms);
|
|
394
394
|
}
|
|
395
395
|
|
|
@@ -496,7 +496,9 @@ const labelledby = [`${uid}-title`, text && `${uid}-text`, overline && `${uid}-o
|
|
|
496
496
|
* and the arrival instead of replacing them. */
|
|
497
497
|
@media (prefers-reduced-motion: no-preference) {
|
|
498
498
|
.layer.float :global(img) {
|
|
499
|
-
|
|
499
|
+
/* Three slow breaths, then still: anything moving on its own for more than five seconds
|
|
500
|
+
* next to other content needs to stop (WCAG 2.2.2). */
|
|
501
|
+
animation: layer-float var(--motion-float, 6s) ease-in-out 3;
|
|
500
502
|
}
|
|
501
503
|
}
|
|
502
504
|
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A chart drawn at build time, two or three times, on a panel that shows whichever drawing fits
|
|
4
|
+
* its width: the narrow one on a phone, the wide one in a column, and an optional full one from
|
|
5
|
+
* 960px. Each is drawn for its width and never scaled up, so the text stays one size and the chart
|
|
6
|
+
* still fills a wide screen. No script draws it; the charts' `enter` plays it in once when it comes
|
|
7
|
+
* into view.
|
|
8
|
+
*
|
|
9
|
+
* Draw the three with `renderPlot` and pass the SVG strings. `alt` speaks for the chart. A
|
|
10
|
+
* `legend` slot sits under it, inside the panel.
|
|
11
|
+
*
|
|
12
|
+
* `as="div"` makes it one panel of a larger figure, such as two charts side by side under one
|
|
13
|
+
* legend and caption: no outer margin and no caption of its own.
|
|
14
|
+
*/
|
|
15
|
+
interface Props {
|
|
16
|
+
/** The drawings, as SVG strings: `narrow` (320), `wide` (about 720) and optionally `full` (960). */
|
|
17
|
+
chart: { narrow: string; wide: string; full?: string };
|
|
18
|
+
alt: string;
|
|
19
|
+
/** A small title at the top of the panel. */
|
|
20
|
+
title?: string;
|
|
21
|
+
caption?: string;
|
|
22
|
+
/** The panel width under which the narrow drawing shows. 560 by default; 420 for a half-width panel. */
|
|
23
|
+
narrowBelow?: 420 | 560;
|
|
24
|
+
as?: 'figure' | 'div';
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { chart, alt, title, caption, narrowBelow = 560, as = 'figure', class: className } = Astro.props;
|
|
29
|
+
const Tag = as;
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
<Tag class:list={['chart-figure', { panel: as === 'div' }, className]}>
|
|
33
|
+
<div class:list={['frame', `nb-${narrowBelow}`, { 'has-full': chart.full }]} data-chart-figure>
|
|
34
|
+
{title && <p class="title">{title}</p>}
|
|
35
|
+
<div role="img" aria-label={alt}>
|
|
36
|
+
<div class="narrow" set:html={chart.narrow} />
|
|
37
|
+
<div class="wide" set:html={chart.wide} />
|
|
38
|
+
{chart.full && <div class="full" set:html={chart.full} />}
|
|
39
|
+
</div>
|
|
40
|
+
<slot name="legend" />
|
|
41
|
+
</div>
|
|
42
|
+
{as === 'figure' && caption && <figcaption>{caption}</figcaption>}
|
|
43
|
+
</Tag>
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
import { enterAll } from '@n1kname/charts/enter';
|
|
47
|
+
enterAll('[data-chart-figure]');
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<style>
|
|
51
|
+
.chart-figure {
|
|
52
|
+
margin-block: var(--sp-6) var(--sp-7);
|
|
53
|
+
}
|
|
54
|
+
.chart-figure.panel {
|
|
55
|
+
margin: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.frame {
|
|
59
|
+
container-type: inline-size;
|
|
60
|
+
height: 100%;
|
|
61
|
+
padding: var(--sp-5);
|
|
62
|
+
background: var(--c-surface);
|
|
63
|
+
border: 1px solid var(--c-border);
|
|
64
|
+
border-radius: var(--radius-lg);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.title {
|
|
68
|
+
margin: 0 0 var(--sp-3);
|
|
69
|
+
font-size: var(--text-body-sm);
|
|
70
|
+
font-weight: 600;
|
|
71
|
+
color: var(--c-text);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.narrow,
|
|
75
|
+
.full {
|
|
76
|
+
display: none;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@container (max-width: 560px) {
|
|
80
|
+
.nb-560 .wide { display: none; }
|
|
81
|
+
.nb-560 .narrow { display: block; }
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@container (max-width: 420px) {
|
|
85
|
+
.nb-420 .wide { display: none; }
|
|
86
|
+
.nb-420 .narrow { display: block; }
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@container (min-width: 960px) {
|
|
90
|
+
.has-full .wide { display: none; }
|
|
91
|
+
.has-full .full { display: block; }
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/* Never scaled up, so the text stays its size; centred when the panel is wider. */
|
|
95
|
+
.frame :global(svg) {
|
|
96
|
+
display: block;
|
|
97
|
+
max-width: 100%;
|
|
98
|
+
height: auto;
|
|
99
|
+
margin-inline: auto;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
figcaption {
|
|
103
|
+
max-width: var(--layout-measure);
|
|
104
|
+
margin-top: var(--sp-4);
|
|
105
|
+
font-size: var(--text-body-sm);
|
|
106
|
+
color: var(--c-text-muted);
|
|
107
|
+
}
|
|
108
|
+
</style>
|
package/src/ScreenStack.astro
CHANGED
|
@@ -253,7 +253,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
253
253
|
position: absolute;
|
|
254
254
|
--lift: 0px;
|
|
255
255
|
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));
|
|
256
|
+
transition: transform var(--motion-grow, 700ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1));
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
.layer :global(img) {
|
|
@@ -296,7 +296,7 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
296
296
|
box-shadow:
|
|
297
297
|
0 1px 2px rgb(0 0 0 / 0.18),
|
|
298
298
|
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));
|
|
299
|
+
transition: transform var(--motion-grow, 700ms) var(--ease-soft, cubic-bezier(0.16, 1, 0.3, 1));
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
.screen :global(img) {
|
|
@@ -429,7 +429,9 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
429
429
|
* and the arrival instead of replacing them. */
|
|
430
430
|
@media (prefers-reduced-motion: no-preference) {
|
|
431
431
|
.layer.float :global(img) {
|
|
432
|
-
|
|
432
|
+
/* Three slow breaths, then still: anything moving on its own for more than five seconds
|
|
433
|
+
* next to other content needs to stop (WCAG 2.2.2). */
|
|
434
|
+
animation: layer-float var(--motion-float, 6s) ease-in-out 3;
|
|
433
435
|
}
|
|
434
436
|
}
|
|
435
437
|
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* A product screenshot on a sunken plate, with a caption. For long reads such as case studies:
|
|
4
|
+
* the plate gives a light-UI capture a frame of its own, so it doesn't float on the page.
|
|
5
|
+
*
|
|
6
|
+
* An imported image goes through astro:assets: it is drawn at most `maxWidth` wide and served at
|
|
7
|
+
* that width and twice it for sharp screens, never upscaled past what the source holds. An SVG or
|
|
8
|
+
* a plain URL is used as it is.
|
|
9
|
+
*
|
|
10
|
+
* Leave `image` off and a labelled placeholder holds the place at the shot's size, so a page can
|
|
11
|
+
* be written and reviewed before the screenshots exist, and a missing picture is visibly missing
|
|
12
|
+
* rather than a broken icon. `alt` still describes the intended shot: it becomes the placeholder's
|
|
13
|
+
* brief, so writing it is never wasted work.
|
|
14
|
+
*
|
|
15
|
+
* `lightPlate` keeps the light plate in dark mode, for transparent artwork with dark labels.
|
|
16
|
+
*/
|
|
17
|
+
import type { ImageMetadata } from 'astro';
|
|
18
|
+
import { Image } from 'astro:assets';
|
|
19
|
+
|
|
20
|
+
interface Props {
|
|
21
|
+
/** The screenshot: an imported image or a URL. Leave off for a placeholder. */
|
|
22
|
+
image?: ImageMetadata | string;
|
|
23
|
+
/** What the shot shows, for a screen reader, and on the placeholder. */
|
|
24
|
+
alt: string;
|
|
25
|
+
caption?: string;
|
|
26
|
+
/** Widest the shot is drawn, in px. Keep it well under the source's width. */
|
|
27
|
+
maxWidth?: number;
|
|
28
|
+
/** The placeholder's size. An image reports its own. */
|
|
29
|
+
width?: number;
|
|
30
|
+
height?: number;
|
|
31
|
+
/** Keep the light plate in dark mode, for transparent artwork with dark labels. */
|
|
32
|
+
lightPlate?: boolean;
|
|
33
|
+
/** The placeholder's label. */
|
|
34
|
+
placeholder?: string;
|
|
35
|
+
class?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const {
|
|
39
|
+
image,
|
|
40
|
+
alt,
|
|
41
|
+
caption,
|
|
42
|
+
maxWidth = 680,
|
|
43
|
+
width = 1600,
|
|
44
|
+
height = 1000,
|
|
45
|
+
lightPlate = false,
|
|
46
|
+
placeholder = 'Screenshot to add',
|
|
47
|
+
class: className,
|
|
48
|
+
} = Astro.props;
|
|
49
|
+
|
|
50
|
+
const asset = image && typeof image !== 'string' && image.format !== 'svg' ? image : undefined;
|
|
51
|
+
const url = typeof image === 'string' ? image : image && !asset ? image.src : undefined;
|
|
52
|
+
|
|
53
|
+
// The cap and its 2x for sharp screens, never past what the source holds.
|
|
54
|
+
const widths = asset ? [...new Set([maxWidth, maxWidth * 2].filter((w) => w <= asset.width))] : [];
|
|
55
|
+
if (asset && widths.length === 0) widths.push(asset.width);
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
<figure class:list={['screenshot', className]}>
|
|
59
|
+
<div class:list={['plate', { 'light-plate': lightPlate }]}>
|
|
60
|
+
{
|
|
61
|
+
asset ? (
|
|
62
|
+
<Image
|
|
63
|
+
src={asset}
|
|
64
|
+
alt={alt}
|
|
65
|
+
widths={widths}
|
|
66
|
+
sizes={`(max-width: ${maxWidth}px) 100vw, ${maxWidth}px`}
|
|
67
|
+
format="webp"
|
|
68
|
+
quality={80}
|
|
69
|
+
loading="lazy"
|
|
70
|
+
style={`max-width: ${maxWidth}px`}
|
|
71
|
+
/>
|
|
72
|
+
) : url ? (
|
|
73
|
+
<img src={url} alt={alt} loading="lazy" style={`max-width: ${maxWidth}px`} />
|
|
74
|
+
) : (
|
|
75
|
+
<div class="placeholder" role="img" aria-label={`Placeholder. ${alt}`} style={`max-width: ${maxWidth}px; aspect-ratio: ${width} / ${height}`}>
|
|
76
|
+
<span class="label">{placeholder}</span>
|
|
77
|
+
<span class="spec">
|
|
78
|
+
{width} × {height}
|
|
79
|
+
</span>
|
|
80
|
+
<span class="brief">{alt}</span>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
</div>
|
|
85
|
+
{caption && <figcaption>{caption}</figcaption>}
|
|
86
|
+
</figure>
|
|
87
|
+
|
|
88
|
+
<style>
|
|
89
|
+
.screenshot {
|
|
90
|
+
margin-block: var(--sp-6) var(--sp-7);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.plate {
|
|
94
|
+
display: flex;
|
|
95
|
+
justify-content: center;
|
|
96
|
+
padding: var(--sp-6);
|
|
97
|
+
background: var(--c-surface-sunken);
|
|
98
|
+
border: 1px solid var(--c-border);
|
|
99
|
+
border-radius: var(--radius-lg);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Screenshots are light-UI captures: kept as they are in dark mode, not inverted or dimmed. */
|
|
103
|
+
img {
|
|
104
|
+
width: 100%;
|
|
105
|
+
height: auto;
|
|
106
|
+
border: 1px solid var(--c-border);
|
|
107
|
+
border-radius: var(--radius-sm);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/* The light theme's --c-surface-sunken and --c-border, fixed, so the plate is the same in both
|
|
111
|
+
* themes. */
|
|
112
|
+
.light-plate {
|
|
113
|
+
background: #fcf1ec;
|
|
114
|
+
}
|
|
115
|
+
.light-plate img {
|
|
116
|
+
border-color: #f1dacf;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.placeholder {
|
|
120
|
+
display: grid;
|
|
121
|
+
place-content: center;
|
|
122
|
+
justify-items: center;
|
|
123
|
+
gap: var(--sp-2);
|
|
124
|
+
width: 100%;
|
|
125
|
+
padding: var(--sp-6);
|
|
126
|
+
text-align: center;
|
|
127
|
+
background: var(--c-surface);
|
|
128
|
+
border: 1px dashed var(--c-border-strong);
|
|
129
|
+
border-radius: var(--radius-sm);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.label {
|
|
133
|
+
font-family: var(--font-body);
|
|
134
|
+
font-size: var(--text-body-sm);
|
|
135
|
+
font-weight: 600;
|
|
136
|
+
color: var(--c-text);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.spec {
|
|
140
|
+
font-family: var(--font-mono);
|
|
141
|
+
font-size: var(--text-caption);
|
|
142
|
+
color: var(--c-text-muted);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/* The brief is the alt text, capped to a readable measure. */
|
|
146
|
+
.brief {
|
|
147
|
+
max-width: 46ch;
|
|
148
|
+
margin-top: var(--sp-2);
|
|
149
|
+
font-size: var(--text-caption);
|
|
150
|
+
line-height: 1.5;
|
|
151
|
+
color: var(--c-text-muted);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
figcaption {
|
|
155
|
+
max-width: var(--layout-measure);
|
|
156
|
+
margin-top: var(--sp-4);
|
|
157
|
+
font-size: var(--text-body-sm);
|
|
158
|
+
color: var(--c-text-muted);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
@media (max-width: 640px) {
|
|
162
|
+
.plate {
|
|
163
|
+
padding: var(--sp-4);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
</style>
|