@n1kname/components 0.48.0 → 0.50.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n1kname/components",
3
- "version": "0.48.0",
3
+ "version": "0.50.0",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {
@@ -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
  )}
@@ -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}
@@ -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. An image reports its own. */
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 = 1600,
44
- height = 1000,
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>
@@ -8,7 +8,8 @@
8
8
  * with a halo); any after it are still to come (hollow markers on a dashed line). By default the
9
9
  * last entry is now. `order="newest-first"` turns that round for a history read from today back,
10
10
  * such as a career: the first entry is now and the ones below it are done. An entry can carry an
11
- * icon, shown in a soft disc of the accent.
11
+ * icon, shown in a disc: soft for what's done, the accent with a halo for now. With `fill` the discs
12
+ * are the same, in teal for the history behind and the accent for now.
12
13
  *
13
14
  * Once, as each entry comes into view, its marker settles in, its text rises and its line draws on
14
15
  * to the next. Nothing moves under reduced motion, and without script everything is simply there.
@@ -77,7 +78,7 @@ const extras = await Promise.all(
77
78
  entries.map((e, i) => (
78
79
  <li data-state={state(i)} aria-current={state(i) === 'current' ? 'step' : undefined} data-to={i < entries.length - 1 ? (dashed(i) ? 'next' : 'done') : undefined}>
79
80
  <span class="marker" aria-hidden="true">
80
- {e.icon && <Icon name={e.icon} size={fill ? 18 : 16} stroke={fill ? 1.75 : undefined} />}
81
+ {e.icon && <Icon name={e.icon} size={16} />}
81
82
  </span>
82
83
  <div class="content">
83
84
  <p class="period">{e.period}</p>
@@ -392,9 +393,11 @@ const extras = await Promise.all(
392
393
  position: relative;
393
394
  }
394
395
 
396
+ /* With icons, the same discs as without the fill. */
395
397
  [data-fill][data-icons] {
396
- --m: 26px;
397
- --mt: -2px;
398
+ --m: 32px;
399
+ --mt: 0px;
400
+ --col: 32px;
398
401
  }
399
402
 
400
403
  [data-fill] li {
@@ -462,31 +465,26 @@ const extras = await Promise.all(
462
465
  background: var(--c-accent);
463
466
  }
464
467
 
465
- /* With icons: the icon itself on the rail, in a gap of the page colour. Now is larger, in a soft
466
- disc of the accent. */
468
+ /* With icons: each icon in a disc, as on a timeline without the fill. The discs are opaque, so
469
+ the rail seems to pass behind them. A disc the fill has passed is a soft teal; one it has yet
470
+ to reach is fainter; now is the accent itself, with its halo. */
467
471
  [data-fill][data-icons] .marker,
468
472
  [data-fill][data-icons] [data-state] .marker {
469
- background: var(--c-bg);
473
+ background: color-mix(in oklab, var(--rail) 26%, var(--c-bg));
470
474
  box-shadow: none;
471
475
  color: var(--rail);
472
476
  }
473
477
 
474
478
  [data-fill][data-icons].filling li:not(.reached) .marker {
475
- background: var(--c-bg);
476
- color: color-mix(in oklab, var(--c-chart-2) 50%, var(--c-bg));
479
+ background: color-mix(in oklab, var(--rail) 14%, var(--c-bg));
480
+ color: color-mix(in oklab, var(--c-chart-2) 55%, var(--c-bg));
477
481
  }
478
482
 
479
483
  [data-fill][data-icons] [data-state='current'] .marker,
480
484
  [data-fill][data-icons].filling [data-state='current']:not(.reached) .marker {
481
- width: calc(var(--m) + 6px);
482
- height: calc(var(--m) + 6px);
483
- margin-top: calc(var(--mt) - 3px);
484
- background: var(--c-surface-tint);
485
- color: var(--c-text-accent);
486
- }
487
-
488
- [data-fill][data-icons] .content {
489
- padding-top: 0;
485
+ background: var(--c-accent);
486
+ color: var(--c-on-accent);
487
+ box-shadow: 0 0 0 4px color-mix(in oklab, var(--c-accent) 28%, var(--c-bg));
490
488
  }
491
489
 
492
490
  @media (max-width: 560px) {