@n1kname/components 0.34.0 → 0.36.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/Highlight.astro +12 -3
- package/src/highlight.css +44 -0
- package/src/icons.ts +3 -0
package/package.json
CHANGED
package/src/Highlight.astro
CHANGED
|
@@ -5,16 +5,25 @@
|
|
|
5
5
|
* the timing live in highlight.css, shared with PageHeader.
|
|
6
6
|
*
|
|
7
7
|
* band the highlighter, a band behind the lower half of the words (default)
|
|
8
|
-
* glow
|
|
8
|
+
* glow a soft blue light behind them that fades in once and holds
|
|
9
|
+
* spotlight a slanted band of blue light that passes through the letters once; the words keep
|
|
10
|
+
* their colour. Each sweep lasts as long as the words have characters, so the light
|
|
11
|
+
* moves at one speed through a short phrase and a long one.
|
|
9
12
|
*/
|
|
10
13
|
import './highlight.css';
|
|
11
14
|
|
|
12
15
|
interface Props {
|
|
13
16
|
/** This mark's place among the marks on the page, from 0. */
|
|
14
17
|
n?: number;
|
|
15
|
-
variant?: 'band' | 'glow';
|
|
18
|
+
variant?: 'band' | 'glow' | 'spotlight';
|
|
16
19
|
}
|
|
17
20
|
const { n = 0, variant = 'band' } = Astro.props;
|
|
21
|
+
const html = Astro.slots.has('default') ? await Astro.slots.render('default') : '';
|
|
22
|
+
// The words as a reader counts them: no tags, an entity as one character.
|
|
23
|
+
const chars = [...html.replace(/<[^>]*>/g, '').replace(/&#?\w+;/g, 'x')].length;
|
|
18
24
|
---
|
|
19
25
|
|
|
20
|
-
<mark
|
|
26
|
+
<mark
|
|
27
|
+
class:list={['highlight', { glow: variant === 'glow', spotlight: variant === 'spotlight' }]}
|
|
28
|
+
style={`--n: ${n}; --chars: ${chars}`}
|
|
29
|
+
><Fragment set:html={html} /></mark>
|
package/src/highlight.css
CHANGED
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
* `mark.highlight.glow` is the quiet look: a soft blue light behind the words that fades in once
|
|
7
7
|
* and then holds still. It reaches past the line, so it never stops in a hard edge.
|
|
8
8
|
*
|
|
9
|
+
* `mark.highlight.spotlight` passes a slanted band of blue light through the letters once, then
|
|
10
|
+
* rests as plain text. It needs `--chars` (Highlight sets it) to keep one speed.
|
|
11
|
+
*
|
|
9
12
|
* Used by Highlight and PageHeader. A page that writes its words once its data arrives can wrap
|
|
10
13
|
* them in <mark class="highlight"> itself, and the sweep plays as they land.
|
|
11
14
|
*
|
|
@@ -83,7 +86,48 @@
|
|
|
83
86
|
}
|
|
84
87
|
}
|
|
85
88
|
|
|
89
|
+
/* The spotlight: the words' fill is a gradient clipped to the glyphs, text colour either side of
|
|
90
|
+
* a soft band of light slanted like the streaks. At rest the visible third is plain text colour.
|
|
91
|
+
* One continuous sweep when the words wrap (slice, not clone), at one speed: 175ms a character. */
|
|
92
|
+
:where(mark.highlight.spotlight) {
|
|
93
|
+
--highlight-shine: color-mix(in oklab, var(--c-chart-2), #fff 25%);
|
|
94
|
+
--highlight-strength: 60%;
|
|
95
|
+
padding-inline: 0;
|
|
96
|
+
margin-inline: 0;
|
|
97
|
+
color: var(--c-text);
|
|
98
|
+
background: linear-gradient(105deg,
|
|
99
|
+
var(--c-text) 36%,
|
|
100
|
+
color-mix(in oklab, var(--highlight-shine) var(--highlight-strength), var(--c-text)) 50%,
|
|
101
|
+
var(--c-text) 64%)
|
|
102
|
+
0 0 / 300% 100% no-repeat;
|
|
103
|
+
-webkit-background-clip: text;
|
|
104
|
+
background-clip: text;
|
|
105
|
+
-webkit-text-fill-color: transparent;
|
|
106
|
+
box-decoration-break: slice;
|
|
107
|
+
-webkit-box-decoration-break: slice;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
111
|
+
:where(mark.highlight.spotlight) {
|
|
112
|
+
animation: highlight-spotlight calc(var(--chars, 10) * 175ms) cubic-bezier(0.45, 0, 0.25, 1)
|
|
113
|
+
calc(var(--highlight-delay, 300ms) + var(--n, 0) * var(--highlight-step, 450ms)) both;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@keyframes highlight-spotlight {
|
|
118
|
+
from {
|
|
119
|
+
background-position: 100% 0;
|
|
120
|
+
}
|
|
121
|
+
to {
|
|
122
|
+
background-position: 0% 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
86
126
|
@media (forced-colors: active) {
|
|
127
|
+
:where(mark.highlight.spotlight) {
|
|
128
|
+
-webkit-text-fill-color: CanvasText;
|
|
129
|
+
}
|
|
130
|
+
|
|
87
131
|
:where(mark.highlight, .page-header .text mark) {
|
|
88
132
|
background: none;
|
|
89
133
|
text-decoration: underline 0.2em;
|
package/src/icons.ts
CHANGED
|
@@ -82,6 +82,9 @@ export const ICONS = {
|
|
|
82
82
|
'<path d="M12 2v20"/><path d="M2 5h20"/><path d="M3 3v2"/><path d="M7 3v2"/><path d="M17 3v2"/><path d="M21 3v2"/><path d="m19 5-7 7-7-7"/>',
|
|
83
83
|
'house-plug':
|
|
84
84
|
'<path d="M10 12V8.964"/><path d="M14 12V8.964"/><path d="M15 12a1 1 0 0 1 1 1v2a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2v-2a1 1 0 0 1 1-1z"/><path d="M8.5 21H5a2 2 0 0 1-2-2v-9a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2h-5a2 2 0 0 1-2-2v-2"/>',
|
|
85
|
+
// A charge point, the hardware: a stop on a journey that was about building chargers.
|
|
86
|
+
'ev-charger':
|
|
87
|
+
'<path d="M14 13h2a2 2 0 0 1 2 2v2a2 2 0 0 0 4 0v-6.998a2 2 0 0 0-.59-1.42L18 5"/><path d="M14 21V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v16"/><path d="M2 21h13"/><path d="M3 7h11"/><path d="m9 11-2 3h3l-2 3"/>',
|
|
85
88
|
'building-2':
|
|
86
89
|
'<path d="M10 12h4"/><path d="M10 8h4"/><path d="M14 21v-3a2 2 0 0 0-4 0v3"/><path d="M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2"/><path d="M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16"/>',
|
|
87
90
|
car: '<path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2"/><circle cx="7" cy="17" r="2"/><path d="M9 17h6"/><circle cx="17" cy="17" r="2"/>',
|