@arraypress/effects-astro 0.8.0 → 0.9.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/AGENTS.md +1 -1
- package/COMPONENTS.md +10 -1
- package/package.json +1 -1
- package/src/components/BorderSweep.astro +43 -4
- package/src/components/GlitchText.astro +17 -8
- package/src/components/Marquee.astro +34 -10
- package/src/components/text.js +29 -0
- package/src/styles/border-sweep.css +35 -6
- package/src/styles/glitch-text.css +155 -2
package/AGENTS.md
CHANGED
|
@@ -38,7 +38,7 @@ Pick by what is asked for:
|
|
|
38
38
|
| Sections that arrive on scroll, site-wide | `<ScrollReveal />` once in the layout, then reveal.css classes (`fade-in-up`…) on elements |
|
|
39
39
|
| A type foundry or bold brand headline: big variable-font letters that swell under the pointer | `<VariableType as="h1" fit>` set in a variable font (`axes` for which axes swell) |
|
|
40
40
|
| Text that arrives or moves | `<Reveal>`, `<ScrambleText>`, `<Typewriter>`, `<HighlightSweep>`, `<Marquee>` |
|
|
41
|
-
| A headline that glitches now and then (a label, a studio, a "make it yours" card) | `<GlitchText as="h2">` (CSS only; `blend="screen"` on a dark ground, `every`, `colors`) |
|
|
41
|
+
| A headline that glitches now and then (a label, a studio, a "make it yours" card) | `<GlitchText as="h2">` (CSS only; `blend="screen"` on a dark ground, `every`, `colors`; `variant="skew"` shakes the whole word; `copies="pseudo"` for one element of plain text) |
|
|
42
42
|
| A small logo mark, a loading or "live" sign | `<PulseMark>`, `.fx-live` from `motion.css` |
|
|
43
43
|
| A hero photo that reacts like water: ripples, a pond, "touch the photo" | `<ImageRipple src="…" alt="…">` (`strength`, `size`, `viscosity`, `fringe`, `fit="contain"`) |
|
|
44
44
|
| A digital-goods or shop hero showing the products: their covers as the centrepiece, copy beside them | `<ProductStack items={[{ src, href, alt }, …]}>` (`layout="fan"`, `"stack"` or `"arc"`), or the covers as `<a><img></a>` children |
|
package/COMPONENTS.md
CHANGED
|
@@ -60,6 +60,10 @@ BorderSweep: a light travelling round an element's outline, on hover and focus o
|
|
|
60
60
|
| `always` | `boolean` | Run all the time, not only on hover. Default false. |
|
|
61
61
|
| `lights` | `1 \| 2` | How many lights go round, 1–2: two chase each other half a lap apart. Default 1. |
|
|
62
62
|
| `inset` | `boolean` | Draw the ring inside the edge and over the content, for elements that clip (`overflow: hidden`) and fill themselves with a picture or a canvas. Default false. |
|
|
63
|
+
| `long` | `boolean` | A longer light: a faint lead-in over the quarter lap before it, then the light and its tail. Default false. |
|
|
64
|
+
| `outset` | `number` | How far the ring sits out past the edge, px: 1 lays it over a 1px border. Default 0. |
|
|
65
|
+
| `focus` | `'within' \| 'visible' \| 'none'` | Which focus lights it: `within` when it or anything in it has the focus, `visible` only its own keyboard focus, `none` never (hover only). Default `within`. |
|
|
66
|
+
| `still` | `'ring' \| 'none'` | What reduced motion shows: `ring` a still lit edge where the light would run, `none` nothing. Default `ring`. |
|
|
63
67
|
| `class` | `string` | Classes for the element. |
|
|
64
68
|
|
|
65
69
|
## `<Caustics>`
|
|
@@ -327,6 +331,8 @@ GlitchText: a headline that glitches now and then. Every few seconds two coloure
|
|
|
327
331
|
| `colors` | `string[]` | The two copies' colours. Default `['#ff3ea5', '#2e4bff']` (pink and blue). |
|
|
328
332
|
| `palette` | `PaletteName \| (string & {})` | A shared palette by name (`PALETTES`, any case), its first two colours, when there are no `colors`. |
|
|
329
333
|
| `blend` | `'multiply' \| 'screen' \| 'normal' \| 'difference' \| 'plus-lighter'` | How the copies blend with the text and what is behind: `multiply` on a light ground, `screen` on a dark one. Default `multiply`. |
|
|
334
|
+
| `copies` | `'spans' \| 'pseudo'` | How the copies are drawn: `spans`, the slot laid twice more (inline formatting kept), or `pseudo`, the element's `::before` and `::after` from a `data-text` of the slot's words (one element; plain text only). Default `spans`. |
|
|
335
|
+
| `variant` | `'slice' \| 'skew'` | The glitch: `slice`, the copies sliced into four bands and shifted a few pixels while the text nudges; `skew`, the whole word shaking and skewing while the copies tear through three bands, shifted by a share of the type size. Default `slice`. |
|
|
330
336
|
| `class` | `string` | Classes for the element. |
|
|
331
337
|
|
|
332
338
|
## `<GlowField>`
|
|
@@ -632,7 +638,10 @@ Marquee: an endless strip that scrolls sideways, for "as featured in" logos, art
|
|
|
632
638
|
| `gap` | `string` | Space between items, CSS length. Default `2.5rem`. |
|
|
633
639
|
| `pauseOnHover` | `boolean` | Pause while the pointer is over it. Default true. |
|
|
634
640
|
| `pauseButton` | `boolean` | Show a pause button. Default true. |
|
|
635
|
-
| `fade` | `number` | How wide the faded edges are, % of the strip. Default 8. |
|
|
641
|
+
| `fade` | `number` | How wide the faded edges are, % of the strip; 0 cuts them. Default 8. |
|
|
642
|
+
| `copies` | `2 \| 3 \| 4` | How many times the content is laid, 2–4; the strip moves by one of them a loop. Two is enough when one set is always wider than the strip. Default 4. |
|
|
643
|
+
| `role` | `'region' \| 'marquee' \| 'note'` | What it is to assistive technology: `region` a landmark, `marquee` a ticker, `note` an aside. Default `region`. |
|
|
644
|
+
| `still` | `'scroll' \| 'hold'` | With reduced motion: `scroll`, one set as a still row to scroll by hand; `hold`, the strip held where it starts, every set laid. Default `scroll`. |
|
|
636
645
|
| `labels` | `{ pause: string; resume: string }` | The pause button's labels, for other languages. Default English. |
|
|
637
646
|
| `label` | `string` | What the strip is, for screen readers. Default the items joined. |
|
|
638
647
|
| `class` | `string` | Classes for the element. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arraypress/effects-astro",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "GPU effects for Astro sites, as components: liquid light with a real fluid under it, ink in water, and outline text a spotlight fills. Plain WebGL, no third-party dependencies, with the fallbacks a theme needs (reduced motion, no WebGL, touch screens, off-screen pausing).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
* Suits outlined things: cards, ghost buttons, a featured pricing tier. A
|
|
9
9
|
* filled button has no outline for the light to travel. `lights={2}` sends
|
|
10
10
|
* two round, chasing each other; `inset` keeps the ring over the content of
|
|
11
|
-
* a card that clips and fills itself.
|
|
11
|
+
* a card that clips and fills itself. `long` draws a longer light with a
|
|
12
|
+
* faint lead-in, `outset` lays the ring over a border, `focus` picks which
|
|
13
|
+
* focus lights it, and `still` what reduced motion shows.
|
|
12
14
|
*
|
|
13
15
|
* @example
|
|
14
16
|
* <BorderSweep as="a" href="/pricing" class="card" color="#a5b4fc" always>…</BorderSweep>
|
|
@@ -32,14 +34,51 @@ interface Props {
|
|
|
32
34
|
lights?: 1 | 2;
|
|
33
35
|
/** Draw the ring inside the edge and over the content, for elements that clip (`overflow: hidden`) and fill themselves with a picture or a canvas. Default false. */
|
|
34
36
|
inset?: boolean;
|
|
37
|
+
/** A longer light: a faint lead-in over the quarter lap before it, then the light and its tail. Default false. */
|
|
38
|
+
long?: boolean;
|
|
39
|
+
/** How far the ring sits out past the edge, px: 1 lays it over a 1px border. Default 0. */
|
|
40
|
+
outset?: number;
|
|
41
|
+
/** Which focus lights it: `within` when it or anything in it has the focus, `visible` only its own keyboard focus, `none` never (hover only). Default `within`. */
|
|
42
|
+
focus?: 'within' | 'visible' | 'none';
|
|
43
|
+
/** What reduced motion shows: `ring` a still lit edge where the light would run, `none` nothing. Default `ring`. */
|
|
44
|
+
still?: 'ring' | 'none';
|
|
35
45
|
class?: string;
|
|
36
46
|
[attribute: string]: unknown;
|
|
37
47
|
}
|
|
38
48
|
|
|
39
|
-
const {
|
|
40
|
-
|
|
49
|
+
const {
|
|
50
|
+
as: Tag = 'div',
|
|
51
|
+
color,
|
|
52
|
+
speed,
|
|
53
|
+
width,
|
|
54
|
+
always = false,
|
|
55
|
+
lights = 1,
|
|
56
|
+
inset = false,
|
|
57
|
+
long = false,
|
|
58
|
+
outset,
|
|
59
|
+
focus = 'within',
|
|
60
|
+
still = 'ring',
|
|
61
|
+
class: className,
|
|
62
|
+
style: given,
|
|
63
|
+
...attributes
|
|
64
|
+
} = Astro.props;
|
|
65
|
+
const style = [
|
|
66
|
+
color && `--sweep-color: ${color}`,
|
|
67
|
+
speed !== undefined && `--sweep-speed: ${speed}s`,
|
|
68
|
+
width !== undefined && `--sweep-width: ${width}px`,
|
|
69
|
+
outset !== undefined && `--sweep-outset: ${outset}px`,
|
|
70
|
+
]
|
|
41
71
|
.filter(Boolean)
|
|
42
72
|
.join('; ');
|
|
43
73
|
---
|
|
44
74
|
|
|
45
|
-
<Tag
|
|
75
|
+
<Tag
|
|
76
|
+
class:list={['sweep-ring',
|
|
77
|
+
{ 'sweep-ring--always': always, 'sweep-ring--two': lights === 2, 'sweep-ring--inset': inset, 'sweep-ring--long': long },
|
|
78
|
+
focus !== 'within' && `sweep-ring--focus-${focus}`,
|
|
79
|
+
still !== 'ring' && `sweep-ring--still-${still}`,
|
|
80
|
+
className,
|
|
81
|
+
]}
|
|
82
|
+
style={withStyle(style, given)}
|
|
83
|
+
{...attributes}><slot /></Tag
|
|
84
|
+
>
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The slot is rendered three times: once as the real text, twice as the
|
|
13
13
|
* copies (hidden from assistive technology and from focus), so keep it to
|
|
14
|
-
* text and inline formatting.
|
|
14
|
+
* text and inline formatting. `copies="pseudo"` draws the copies as the
|
|
15
|
+
* element's `::before` and `::after` from a `data-text` instead: one
|
|
16
|
+
* element, for plain text. `variant="skew"` is another glitch, the whole
|
|
17
|
+
* word shaking and skewing. For elements you render yourself, import
|
|
15
18
|
* `@arraypress/effects-astro/glitch-text.css` and follow its markup.
|
|
16
19
|
*
|
|
17
20
|
* @example
|
|
@@ -22,6 +25,7 @@ import type { PaletteName } from '../runtime/palettes.js';
|
|
|
22
25
|
import { pickColors } from '../runtime/palettes.js';
|
|
23
26
|
import '../styles/glitch-text.css';
|
|
24
27
|
import { withStyle } from './style.js';
|
|
28
|
+
import { plainText } from './text.js';
|
|
25
29
|
|
|
26
30
|
interface Props {
|
|
27
31
|
/** The element to render. Default `span`. */
|
|
@@ -38,11 +42,15 @@ interface Props {
|
|
|
38
42
|
palette?: PaletteName | (string & {});
|
|
39
43
|
/** How the copies blend with the text and what is behind: `multiply` on a light ground, `screen` on a dark one. Default `multiply`. */
|
|
40
44
|
blend?: 'multiply' | 'screen' | 'normal' | 'difference' | 'plus-lighter';
|
|
45
|
+
/** How the copies are drawn: `spans`, the slot laid twice more (inline formatting kept), or `pseudo`, the element's `::before` and `::after` from a `data-text` of the slot's words (one element; plain text only). Default `spans`. */
|
|
46
|
+
copies?: 'spans' | 'pseudo';
|
|
47
|
+
/** The glitch: `slice`, the copies sliced into four bands and shifted a few pixels while the text nudges; `skew`, the whole word shaking and skewing while the copies tear through three bands, shifted by a share of the type size. Default `slice`. */
|
|
48
|
+
variant?: 'slice' | 'skew';
|
|
41
49
|
class?: string;
|
|
42
50
|
[attribute: string]: unknown;
|
|
43
51
|
}
|
|
44
52
|
|
|
45
|
-
const { as: Tag = 'span', every, hoverEvery, delay, colors, palette, blend, class: className, style: given, ...attributes } = Astro.props;
|
|
53
|
+
const { as: Tag = 'span', every, hoverEvery, delay, colors, palette, blend, copies = 'spans', variant = 'slice', class: className, style: given, ...attributes } = Astro.props;
|
|
46
54
|
const [a, b] = colors?.length || palette ? pickColors({ colors, palette }, ['#ff3ea5', '#2e4bff'], (p) => [p.colors[0], p.colors[1]]) : [];
|
|
47
55
|
const cycle = every ?? 5;
|
|
48
56
|
// Rendered once, at build time: each instance gets its own beat in the static page.
|
|
@@ -58,12 +66,13 @@ const style = [
|
|
|
58
66
|
.filter(Boolean)
|
|
59
67
|
.join('; ');
|
|
60
68
|
const html = await Astro.slots.render('default');
|
|
69
|
+
const pseudo = copies === 'pseudo';
|
|
61
70
|
---
|
|
62
71
|
|
|
63
|
-
<Tag
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
></Tag
|
|
72
|
+
<Tag
|
|
73
|
+
class:list={['glitch-text', pseudo && 'glitch-text--pseudo', variant !== 'slice' && `glitch-text--${variant}`, className]}
|
|
74
|
+
data-text={pseudo ? plainText(html) : undefined}
|
|
75
|
+
style={withStyle(style, given)}
|
|
76
|
+
{...attributes}
|
|
77
|
+
>{pseudo ? <Fragment set:html={html} /> : <Fragment><span><Fragment set:html={html} /></span><span class="glitch-text-a" aria-hidden="true" inert><Fragment set:html={html} /></span><span class="glitch-text-b" aria-hidden="true" inert><Fragment set:html={html} /></span></Fragment>}</Tag
|
|
69
78
|
>
|
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* anything as the slot (logos, images, cards).
|
|
6
6
|
*
|
|
7
7
|
* The content is laid four times and the strip moves by one set, so the
|
|
8
|
-
* loop is seamless even when a set is narrower than the screen
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* loop is seamless even when a set is narrower than the screen (`copies`
|
|
9
|
+
* lays it fewer times, for a set that is always wider). The edges fade
|
|
10
|
+
* out rather than cutting (`fade={0}` cuts them), it can pause under the
|
|
11
|
+
* pointer, and a small pause button stops it for good (moving content
|
|
12
|
+
* needs one, WCAG 2.2.2). With reduced motion it is a still row,
|
|
13
|
+
* scrollable by hand, or (`still="hold"`) the strip held where it starts.
|
|
12
14
|
* Screen readers get the content once.
|
|
13
15
|
*
|
|
14
16
|
* Merges the marquees of the WaveGrid, SellGrid, LinkGrid and LaunchGrid
|
|
@@ -34,8 +36,14 @@ interface Props {
|
|
|
34
36
|
pauseOnHover?: boolean;
|
|
35
37
|
/** Show a pause button. Default true. */
|
|
36
38
|
pauseButton?: boolean;
|
|
37
|
-
/** How wide the faded edges are, % of the strip. Default 8. */
|
|
39
|
+
/** How wide the faded edges are, % of the strip; 0 cuts them. Default 8. */
|
|
38
40
|
fade?: number;
|
|
41
|
+
/** How many times the content is laid, 2–4; the strip moves by one of them a loop. Two is enough when one set is always wider than the strip. Default 4. */
|
|
42
|
+
copies?: 2 | 3 | 4;
|
|
43
|
+
/** What it is to assistive technology: `region` a landmark, `marquee` a ticker, `note` an aside. Default `region`. */
|
|
44
|
+
role?: 'region' | 'marquee' | 'note';
|
|
45
|
+
/** With reduced motion: `scroll`, one set as a still row to scroll by hand; `hold`, the strip held where it starts, every set laid. Default `scroll`. */
|
|
46
|
+
still?: 'scroll' | 'hold';
|
|
39
47
|
/** The pause button's labels, for other languages. Default English. */
|
|
40
48
|
labels?: { pause: string; resume: string };
|
|
41
49
|
/** What the strip is, for screen readers. Default the items joined. */
|
|
@@ -52,6 +60,9 @@ const {
|
|
|
52
60
|
pauseOnHover = true,
|
|
53
61
|
pauseButton = true,
|
|
54
62
|
fade = 8,
|
|
63
|
+
copies = 4,
|
|
64
|
+
role = 'region',
|
|
65
|
+
still = 'scroll',
|
|
55
66
|
labels = { pause: 'Pause scrolling', resume: 'Resume scrolling' },
|
|
56
67
|
label,
|
|
57
68
|
class: className,
|
|
@@ -59,13 +70,14 @@ const {
|
|
|
59
70
|
|
|
60
71
|
// Slot content is rendered once and laid again for the copies.
|
|
61
72
|
const slotted = items ? '' : await Astro.slots.render('default');
|
|
62
|
-
const sets =
|
|
73
|
+
const sets = Array.from({ length: copies }, (_, set) => set);
|
|
74
|
+
const shift = copies === 4 ? '' : `; --marquee-shift: ${-100 / copies}%`;
|
|
63
75
|
---
|
|
64
76
|
|
|
65
77
|
<div
|
|
66
|
-
class:list={['effect-marquee', `is-${direction}`, { 'pause-on-hover': pauseOnHover }, className]}
|
|
67
|
-
style={`--marquee-speed: ${speed}s; --marquee-gap: ${gap}; --marquee-fade: ${fade}
|
|
68
|
-
role=
|
|
78
|
+
class:list={['effect-marquee', `is-${direction}`, { 'pause-on-hover': pauseOnHover, 'no-fade': fade === 0, 'still-hold': still === 'hold' }, className]}
|
|
79
|
+
style={`--marquee-speed: ${speed}s; --marquee-gap: ${gap}; --marquee-fade: ${fade}%${shift}`}
|
|
80
|
+
role={role}
|
|
69
81
|
aria-label={label ?? items?.join(', ')}
|
|
70
82
|
data-effect-marquee
|
|
71
83
|
>
|
|
@@ -159,9 +171,14 @@ const sets = [0, 1, 2, 3];
|
|
|
159
171
|
.effect-marquee:global(.is-paused) .track {
|
|
160
172
|
animation-play-state: paused;
|
|
161
173
|
}
|
|
174
|
+
.no-fade .viewport {
|
|
175
|
+
-webkit-mask-image: none;
|
|
176
|
+
mask-image: none;
|
|
177
|
+
}
|
|
178
|
+
/* One set a loop: a quarter of the four, or --marquee-shift for fewer. */
|
|
162
179
|
@keyframes effect-marquee {
|
|
163
180
|
to {
|
|
164
|
-
transform: translateX(-25%);
|
|
181
|
+
transform: translateX(var(--marquee-shift, -25%));
|
|
165
182
|
}
|
|
166
183
|
}
|
|
167
184
|
|
|
@@ -212,5 +229,12 @@ const sets = [0, 1, 2, 3];
|
|
|
212
229
|
.toggle {
|
|
213
230
|
display: none;
|
|
214
231
|
}
|
|
232
|
+
/* Held: every set laid, still, as it starts. */
|
|
233
|
+
.still-hold .viewport {
|
|
234
|
+
overflow-x: hidden;
|
|
235
|
+
}
|
|
236
|
+
.still-hold .set[aria-hidden='true'] {
|
|
237
|
+
display: flex;
|
|
238
|
+
}
|
|
215
239
|
}
|
|
216
240
|
</style>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @arraypress/effects-astro/components/text
|
|
3
|
+
*
|
|
4
|
+
* The words of a rendered slot, for an attribute that repeats them
|
|
5
|
+
* (`<GlitchText copies="pseudo">`'s `data-text`): its tags dropped and its
|
|
6
|
+
* character references read back into characters, so Astro escapes them
|
|
7
|
+
* once, as the attribute's own.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** The named references Astro's escaping writes, and the no-break space. */
|
|
11
|
+
const NAMED = { amp: '&', lt: '<', gt: '>', quot: '"', apos: "'", nbsp: ' ' };
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A slot's HTML as plain text.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} html The rendered slot.
|
|
17
|
+
* @returns {string} Its text: no tags, each run of white space one space, trimmed, references decoded.
|
|
18
|
+
*/
|
|
19
|
+
export function plainText(html) {
|
|
20
|
+
return html
|
|
21
|
+
.replace(/<[^>]*>/g, '')
|
|
22
|
+
.replace(/[ \t\n\r\f]+/g, ' ')
|
|
23
|
+
.trim()
|
|
24
|
+
.replace(/&(#x[\da-f]+|#\d+|[a-z]+);/gi, (whole, ref) => {
|
|
25
|
+
if (ref[0] !== '#') return NAMED[/** @type {keyof typeof NAMED} */ (ref.toLowerCase())] ?? whole;
|
|
26
|
+
const code = /^#x/i.test(ref) ? parseInt(ref.slice(2), 16) : parseInt(ref.slice(1), 10);
|
|
27
|
+
return code <= 0x10ffff ? String.fromCodePoint(code) : whole;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -21,7 +21,16 @@
|
|
|
21
21
|
* contents (`overflow: hidden`) and fill themselves with a picture or a
|
|
22
22
|
* canvas that would otherwise cover it.
|
|
23
23
|
*
|
|
24
|
-
*
|
|
24
|
+
* `sweep-ring--long` is a longer light: a faint lead-in over the quarter
|
|
25
|
+
* lap before it, then the light and its tail. `--sweep-outset` moves the
|
|
26
|
+
* ring out past the edge (`1px` lays it over a 1px border). Focus lights
|
|
27
|
+
* it when the element or anything in it has the focus; `--focus-visible`
|
|
28
|
+
* only on the element's own keyboard focus, `--focus-none` never (hover
|
|
29
|
+
* only). `sweep-ring--still-none` shows no ring at all with reduced
|
|
30
|
+
* motion, where the default keeps a still lit edge.
|
|
31
|
+
*
|
|
32
|
+
* From the ArrayPress theme; the two lights, the long light, the outset,
|
|
33
|
+
* the focus and the still options from the Logomarks site.
|
|
25
34
|
* ───────────────────────────────────────────────────────────────────── */
|
|
26
35
|
|
|
27
36
|
@property --sweep-angle {
|
|
@@ -37,7 +46,7 @@
|
|
|
37
46
|
.sweep-ring::after {
|
|
38
47
|
content: '';
|
|
39
48
|
position: absolute;
|
|
40
|
-
inset:
|
|
49
|
+
inset: calc(var(--sweep-outset, 0px) * -1);
|
|
41
50
|
border-radius: inherit;
|
|
42
51
|
padding: var(--sweep-width, 1px);
|
|
43
52
|
background: conic-gradient(
|
|
@@ -57,9 +66,10 @@
|
|
|
57
66
|
pointer-events: none;
|
|
58
67
|
}
|
|
59
68
|
|
|
69
|
+
/* Focus lights it unless told otherwise; `:where` keeps the selectors' weight as it was. */
|
|
60
70
|
.sweep-ring:hover::after,
|
|
61
|
-
.sweep-ring:focus-visible::after,
|
|
62
|
-
.sweep-ring:focus-within::after,
|
|
71
|
+
.sweep-ring:where(:not(.sweep-ring--focus-none)):focus-visible::after,
|
|
72
|
+
.sweep-ring:where(:not(.sweep-ring--focus-visible, .sweep-ring--focus-none)):focus-within::after,
|
|
63
73
|
.sweep-ring--always::after {
|
|
64
74
|
opacity: 1;
|
|
65
75
|
animation: effect-border-sweep var(--sweep-speed, 2.6s) linear infinite;
|
|
@@ -69,6 +79,19 @@
|
|
|
69
79
|
--sweep-speed: 1.8s;
|
|
70
80
|
}
|
|
71
81
|
|
|
82
|
+
/* A longer light: a faint lead-in over the quarter lap before it, then the light and its tail. */
|
|
83
|
+
.sweep-ring--long::after {
|
|
84
|
+
background: conic-gradient(
|
|
85
|
+
from var(--sweep-angle),
|
|
86
|
+
transparent 0%,
|
|
87
|
+
transparent 50%,
|
|
88
|
+
color-mix(in srgb, var(--sweep-color, currentColor) 30%, transparent) 64%,
|
|
89
|
+
var(--sweep-color, currentColor) 78%,
|
|
90
|
+
color-mix(in srgb, var(--sweep-color, currentColor) 35%, transparent) 88%,
|
|
91
|
+
transparent 96%
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
72
95
|
/* Two lights, half a lap apart, each with a faint lead-in. */
|
|
73
96
|
.sweep-ring--two::after {
|
|
74
97
|
background: conic-gradient(
|
|
@@ -98,12 +121,18 @@
|
|
|
98
121
|
|
|
99
122
|
@media (prefers-reduced-motion: reduce) {
|
|
100
123
|
.sweep-ring:hover::after,
|
|
101
|
-
.sweep-ring:focus-visible::after,
|
|
102
|
-
.sweep-ring:focus-within::after,
|
|
124
|
+
.sweep-ring:where(:not(.sweep-ring--focus-none)):focus-visible::after,
|
|
125
|
+
.sweep-ring:where(:not(.sweep-ring--focus-visible, .sweep-ring--focus-none)):focus-within::after,
|
|
103
126
|
.sweep-ring--always::after {
|
|
104
127
|
animation: none;
|
|
105
128
|
/* Keep the lit edge, drop the travel. */
|
|
106
129
|
background: none;
|
|
107
130
|
box-shadow: inset 0 0 0 1px var(--sweep-color, currentColor);
|
|
108
131
|
}
|
|
132
|
+
|
|
133
|
+
/* Or no ring at all: still and see-through, outweighing the lit states. */
|
|
134
|
+
.sweep-ring.sweep-ring--still-none::after {
|
|
135
|
+
animation: none;
|
|
136
|
+
opacity: 0;
|
|
137
|
+
}
|
|
109
138
|
}
|
|
@@ -23,7 +23,18 @@
|
|
|
23
23
|
* `--glitch-blend` (how they blend: multiply on a light ground, screen on
|
|
24
24
|
* a dark one). With reduced motion it is the plain text, still.
|
|
25
25
|
*
|
|
26
|
-
*
|
|
26
|
+
* `glitch-text--pseudo` draws the copies as the element's own `::before`
|
|
27
|
+
* and `::after` from its `data-text` instead, for one element of plain
|
|
28
|
+
* text:
|
|
29
|
+
*
|
|
30
|
+
* <span class="glitch-text glitch-text--pseudo" data-text="Free logos">Free logos</span>
|
|
31
|
+
*
|
|
32
|
+
* `glitch-text--skew` is another glitch: the whole word shakes and skews
|
|
33
|
+
* while the copies tear through three bands each, shifted by a share of
|
|
34
|
+
* the type size (em), the second a touch fainter. With either markup.
|
|
35
|
+
*
|
|
36
|
+
* CSS only. From the Logomarks site's Custom card; the pseudo copies and
|
|
37
|
+
* the skew from its home page's headline.
|
|
27
38
|
* ───────────────────────────────────────────────────────────────────── */
|
|
28
39
|
|
|
29
40
|
.glitch-text {
|
|
@@ -162,8 +173,150 @@
|
|
|
162
173
|
}
|
|
163
174
|
}
|
|
164
175
|
|
|
176
|
+
/* The copies as the element's ::before and ::after, from its data-text: one element, plain text. */
|
|
177
|
+
.glitch-text--pseudo::before,
|
|
178
|
+
.glitch-text--pseudo::after {
|
|
179
|
+
content: attr(data-text);
|
|
180
|
+
position: absolute;
|
|
181
|
+
inset: 0;
|
|
182
|
+
opacity: 0;
|
|
183
|
+
pointer-events: none;
|
|
184
|
+
mix-blend-mode: var(--glitch-blend, multiply);
|
|
185
|
+
animation: effect-glitch-text-a var(--glitch-every, 5s) steps(1, end) infinite;
|
|
186
|
+
animation-delay: var(--glitch-delay, 0s);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.glitch-text--pseudo::before {
|
|
190
|
+
color: var(--glitch-a, #ff3ea5);
|
|
191
|
+
-webkit-text-fill-color: currentColor;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.glitch-text--pseudo::after {
|
|
195
|
+
color: var(--glitch-b, #2e4bff);
|
|
196
|
+
-webkit-text-fill-color: currentColor;
|
|
197
|
+
animation-name: effect-glitch-text-b;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/* Here the element itself nudges, its copies with it. */
|
|
201
|
+
.glitch-text--pseudo {
|
|
202
|
+
animation: effect-glitch-text-main var(--glitch-every, 5s) steps(1, end) infinite;
|
|
203
|
+
animation-delay: var(--glitch-delay, 0s);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/* The skew: the whole word shakes and skews while the copies tear through three bands. */
|
|
207
|
+
.glitch-text--skew {
|
|
208
|
+
animation: effect-glitch-text-skew var(--glitch-every, 5s) steps(1, end) infinite;
|
|
209
|
+
animation-delay: var(--glitch-delay, 0s);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.glitch-text--skew > :not(.glitch-text-a, .glitch-text-b) {
|
|
213
|
+
animation: none;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.glitch-text--skew > .glitch-text-a,
|
|
217
|
+
.glitch-text--skew::before {
|
|
218
|
+
animation-name: effect-glitch-text-skew-a;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.glitch-text--skew > .glitch-text-b,
|
|
222
|
+
.glitch-text--skew::after {
|
|
223
|
+
animation-name: effect-glitch-text-skew-b;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.glitch-text:is(.glitch-text--pseudo, .glitch-text--skew):hover,
|
|
227
|
+
.glitch-text--pseudo:hover::before,
|
|
228
|
+
.glitch-text--pseudo:hover::after,
|
|
229
|
+
:is(a, button):is(:hover, :focus-visible) .glitch-text:is(.glitch-text--pseudo, .glitch-text--skew),
|
|
230
|
+
:is(a, button):is(:hover, :focus-visible) .glitch-text--pseudo::before,
|
|
231
|
+
:is(a, button):is(:hover, :focus-visible) .glitch-text--pseudo::after {
|
|
232
|
+
animation-duration: var(--glitch-hover, 1.6s);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
@keyframes effect-glitch-text-skew-a {
|
|
236
|
+
0%,
|
|
237
|
+
88%,
|
|
238
|
+
100% {
|
|
239
|
+
opacity: 0;
|
|
240
|
+
transform: none;
|
|
241
|
+
clip-path: inset(0 0 100% 0);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
89% {
|
|
245
|
+
opacity: 1;
|
|
246
|
+
transform: translate(-0.04em, 0.01em);
|
|
247
|
+
clip-path: inset(12% 0 58% 0);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
91% {
|
|
251
|
+
opacity: 1;
|
|
252
|
+
transform: translate(0.05em, -0.01em);
|
|
253
|
+
clip-path: inset(62% 0 8% 0);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
93% {
|
|
257
|
+
opacity: 1;
|
|
258
|
+
transform: translate(-0.02em, 0);
|
|
259
|
+
clip-path: inset(38% 0 40% 0);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
95% {
|
|
263
|
+
opacity: 0;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
@keyframes effect-glitch-text-skew-b {
|
|
268
|
+
0%,
|
|
269
|
+
89%,
|
|
270
|
+
100% {
|
|
271
|
+
opacity: 0;
|
|
272
|
+
transform: none;
|
|
273
|
+
clip-path: inset(0 0 100% 0);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
90% {
|
|
277
|
+
opacity: 0.9;
|
|
278
|
+
transform: translate(0.05em, 0);
|
|
279
|
+
clip-path: inset(48% 0 22% 0);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
92% {
|
|
283
|
+
opacity: 0.9;
|
|
284
|
+
transform: translate(-0.04em, 0.01em);
|
|
285
|
+
clip-path: inset(6% 0 70% 0);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
94% {
|
|
289
|
+
opacity: 0;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
@keyframes effect-glitch-text-skew {
|
|
294
|
+
0%,
|
|
295
|
+
88%,
|
|
296
|
+
95%,
|
|
297
|
+
100% {
|
|
298
|
+
transform: none;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
89% {
|
|
302
|
+
transform: translateX(0.012em) skewX(-4deg);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
91% {
|
|
306
|
+
transform: translateX(-0.012em);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
93% {
|
|
310
|
+
transform: skewX(3deg);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
165
314
|
@media (prefers-reduced-motion: reduce) {
|
|
166
|
-
.glitch-text >
|
|
315
|
+
.glitch-text > *,
|
|
316
|
+
.glitch-text--pseudo,
|
|
317
|
+
.glitch-text--pseudo::before,
|
|
318
|
+
.glitch-text--pseudo::after,
|
|
319
|
+
.glitch-text--skew {
|
|
167
320
|
animation: none !important;
|
|
168
321
|
}
|
|
169
322
|
}
|