@n1kname/components 0.42.0 → 0.43.1
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 +23 -5
- package/src/ScreenStack.astro +21 -6
- package/src/patterns.ts +42 -0
package/package.json
CHANGED
package/src/CaseTile.astro
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
import type { ImageMetadata } from 'astro';
|
|
24
24
|
import { Image } from 'astro:assets';
|
|
25
|
+
import { patternStyle, type Pattern } from './patterns';
|
|
25
26
|
|
|
26
27
|
interface Metric {
|
|
27
28
|
value: string;
|
|
@@ -64,6 +65,10 @@ interface Props {
|
|
|
64
65
|
stage?: number;
|
|
65
66
|
/** Dark words for a light tone. */
|
|
66
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;
|
|
67
72
|
device?: 'laptop' | 'phone';
|
|
68
73
|
layout?: 'wide' | 'half';
|
|
69
74
|
/** The tile colour, deep enough for white text. */
|
|
@@ -88,6 +93,8 @@ const {
|
|
|
88
93
|
layers = [],
|
|
89
94
|
stage = 4 / 3,
|
|
90
95
|
ink = 'light',
|
|
96
|
+
pattern = 'dots',
|
|
97
|
+
patternFade = true,
|
|
91
98
|
device = 'laptop',
|
|
92
99
|
layout = 'half',
|
|
93
100
|
tone = 'var(--c-accent)',
|
|
@@ -114,9 +121,9 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
114
121
|
---
|
|
115
122
|
|
|
116
123
|
<a
|
|
117
|
-
class:list={['case-tile', layout, device, `ink-${ink}`, { 'has-image': !shots.length && !layers.length && image, 'has-layers': layers.length }, 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]}
|
|
118
125
|
href={href}
|
|
119
|
-
style={`--tile-tone: ${tone}`}
|
|
126
|
+
style={`--tile-tone: ${tone}; ${patternStyle(pattern, ink)}`}
|
|
120
127
|
data-case-tile
|
|
121
128
|
>
|
|
122
129
|
<div class="frame">
|
|
@@ -220,7 +227,6 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
220
227
|
color: #fff;
|
|
221
228
|
text-decoration: none;
|
|
222
229
|
background:
|
|
223
|
-
radial-gradient(circle at 1px 1px, rgb(255 255 255 / 0.13) 1px, transparent 0) 0 0 / 22px 22px,
|
|
224
230
|
linear-gradient(
|
|
225
231
|
150deg,
|
|
226
232
|
color-mix(in oklab, var(--tile-tone), white 10%),
|
|
@@ -232,6 +238,19 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
232
238
|
box-shadow var(--motion-hover, 160ms) var(--ease-hover, ease-out);
|
|
233
239
|
}
|
|
234
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
|
+
|
|
235
254
|
.case-tile:focus-visible {
|
|
236
255
|
outline: 3px solid var(--c-focus, #fff);
|
|
237
256
|
outline-offset: 3px;
|
|
@@ -372,7 +391,6 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
372
391
|
.ink-dark {
|
|
373
392
|
color: #17181a;
|
|
374
393
|
background:
|
|
375
|
-
radial-gradient(circle at 1px 1px, rgb(0 0 0 / 0.1) 1px, transparent 0) 0 0 / 22px 22px,
|
|
376
394
|
linear-gradient(
|
|
377
395
|
150deg,
|
|
378
396
|
color-mix(in oklab, var(--tile-tone), white 14%),
|
|
@@ -439,7 +457,7 @@ const figures = layout === 'wide' ? metrics.slice(0, 4) : [];
|
|
|
439
457
|
}
|
|
440
458
|
|
|
441
459
|
@media (prefers-reduced-motion: no-preference) {
|
|
442
|
-
.armed :is(.screen, .layer) {
|
|
460
|
+
.armed:not(.in) :is(.screen, .layer) {
|
|
443
461
|
opacity: 0;
|
|
444
462
|
translate: 0 48px;
|
|
445
463
|
}
|
package/src/ScreenStack.astro
CHANGED
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
*/
|
|
27
27
|
import type { ImageMetadata } from 'astro';
|
|
28
28
|
import { Image } from 'astro:assets';
|
|
29
|
+
import { patternStyle, type Pattern } from './patterns';
|
|
29
30
|
|
|
30
31
|
interface Screen {
|
|
31
32
|
image: ImageMetadata | string;
|
|
@@ -52,6 +53,10 @@ interface Props {
|
|
|
52
53
|
stage?: number;
|
|
53
54
|
/** Dark ink on the note, for a light tone. */
|
|
54
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;
|
|
55
60
|
/** The panel colour: a CSS colour, deep enough for white text, such as a client's brand blue. */
|
|
56
61
|
tone?: string;
|
|
57
62
|
note?: string;
|
|
@@ -68,7 +73,7 @@ interface Props {
|
|
|
68
73
|
class?: string;
|
|
69
74
|
}
|
|
70
75
|
|
|
71
|
-
const { screens = [], layers = [], stage = 4 / 3, ink = 'light', 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;
|
|
72
77
|
const shots = screens.slice(0, 3);
|
|
73
78
|
// Back to front, so the first screen paints last and sits on top.
|
|
74
79
|
const order = [...shots.keys()].reverse();
|
|
@@ -85,8 +90,8 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
85
90
|
---
|
|
86
91
|
|
|
87
92
|
<div
|
|
88
|
-
class:list={['screen-stack', size, device, `n${shots.length}`, `ink-${ink}`, { 'has-layers': layers.length }, className]}
|
|
89
|
-
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;` : ''}`}
|
|
90
95
|
data-screen-stack-parallax={parallax ? '' : undefined}
|
|
91
96
|
>
|
|
92
97
|
{note && <p class="note">{note}</p>}
|
|
@@ -174,7 +179,6 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
174
179
|
aspect-ratio: 20 / 9;
|
|
175
180
|
border-radius: var(--radius-lg);
|
|
176
181
|
background:
|
|
177
|
-
radial-gradient(circle at 1px 1px, rgb(255 255 255 / 0.14) 1px, transparent 0) 0 0 / 22px 22px,
|
|
178
182
|
linear-gradient(
|
|
179
183
|
140deg,
|
|
180
184
|
color-mix(in oklab, var(--stack-tone), white 12%),
|
|
@@ -183,10 +187,22 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
183
187
|
);
|
|
184
188
|
}
|
|
185
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
|
+
|
|
186
203
|
.card {
|
|
187
204
|
aspect-ratio: 16 / 9;
|
|
188
205
|
border-radius: var(--radius-sm);
|
|
189
|
-
background-size: 14px 14px, auto;
|
|
190
206
|
}
|
|
191
207
|
|
|
192
208
|
.note {
|
|
@@ -246,7 +262,6 @@ const fit = (img: ImageMetadata) => [...new Set(widths.filter((w) => w <= img.wi
|
|
|
246
262
|
|
|
247
263
|
.ink-dark {
|
|
248
264
|
background:
|
|
249
|
-
radial-gradient(circle at 1px 1px, rgb(0 0 0 / 0.1) 1px, transparent 0) 0 0 / 22px 22px,
|
|
250
265
|
linear-gradient(
|
|
251
266
|
140deg,
|
|
252
267
|
color-mix(in oklab, var(--stack-tone), white 14%),
|
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
|
+
};
|