@arraypress/effects-astro 0.0.0-stage → 0.1.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 +85 -0
- package/COMPONENTS.md +1264 -0
- package/LICENSE +139 -0
- package/README.md +197 -2
- package/package.json +60 -4
- package/src/components/AsciiRain.astro +36 -0
- package/src/components/BorderSweep.astro +39 -0
- package/src/components/Caustics.astro +39 -0
- package/src/components/ColorPanels.astro +62 -0
- package/src/components/Cursor.astro +97 -0
- package/src/components/DotGrid.astro +34 -0
- package/src/components/DotSurface.astro +35 -0
- package/src/components/EffectCanvas.astro +152 -0
- package/src/components/FitText.astro +35 -0
- package/src/components/FlutedGlass.astro +36 -0
- package/src/components/Glass.astro +69 -0
- package/src/components/GlassGlyph.astro +38 -0
- package/src/components/GlowField.astro +177 -0
- package/src/components/Grain.astro +98 -0
- package/src/components/HaloRing.astro +38 -0
- package/src/components/HighlightSweep.astro +74 -0
- package/src/components/ImageRipple.astro +56 -0
- package/src/components/Ink.astro +37 -0
- package/src/components/InkField.astro +45 -0
- package/src/components/IsoCity.astro +54 -0
- package/src/components/LightField.astro +40 -0
- package/src/components/LiquidMetal.astro +41 -0
- package/src/components/Magnetic.astro +52 -0
- package/src/components/Marquee.astro +216 -0
- package/src/components/MosaicReveal.astro +196 -0
- package/src/components/NebulaLogo.astro +38 -0
- package/src/components/NeonSwarm.astro +38 -0
- package/src/components/Ocean.astro +40 -0
- package/src/components/OutlineWordmark.astro +222 -0
- package/src/components/PaperBackground.astro +40 -0
- package/src/components/PaperShader.astro +55 -0
- package/src/components/Parallax.astro +49 -0
- package/src/components/ParticleLogo.astro +37 -0
- package/src/components/PixelGlitchText.astro +70 -0
- package/src/components/PointCloud.astro +37 -0
- package/src/components/ProductStack.astro +298 -0
- package/src/components/PulseMark.astro +189 -0
- package/src/components/RadiantGlass.astro +38 -0
- package/src/components/RainOnGlass.astro +71 -0
- package/src/components/Reveal.astro +115 -0
- package/src/components/ScrambleText.astro +52 -0
- package/src/components/ScrollReveal.astro +38 -0
- package/src/components/ShaderBackground.astro +55 -0
- package/src/components/SignalLines.astro +41 -0
- package/src/components/SilkRibbon.astro +37 -0
- package/src/components/SpotlightText.astro +131 -0
- package/src/components/Tilt.astro +79 -0
- package/src/components/Topography.astro +38 -0
- package/src/components/Typewriter.astro +66 -0
- package/src/components/VariableType.astro +59 -0
- package/src/components/VoxelLogo.astro +46 -0
- package/src/components/WaveBars.astro +41 -0
- package/src/components/WorldRoutes.astro +41 -0
- package/src/components/style.js +19 -0
- package/src/index.d.ts +143 -0
- package/src/index.js +105 -0
- package/src/runtime/ascii-rain.d.ts +53 -0
- package/src/runtime/ascii-rain.js +355 -0
- package/src/runtime/audio-meter.d.ts +65 -0
- package/src/runtime/audio-meter.js +282 -0
- package/src/runtime/audio.d.ts +26 -0
- package/src/runtime/audio.js +453 -0
- package/src/runtime/blur.d.ts +2 -0
- package/src/runtime/blur.js +56 -0
- package/src/runtime/canvas2d.d.ts +23 -0
- package/src/runtime/canvas2d.js +105 -0
- package/src/runtime/caustics.d.ts +40 -0
- package/src/runtime/caustics.js +286 -0
- package/src/runtime/color.d.ts +33 -0
- package/src/runtime/color.js +213 -0
- package/src/runtime/curl.d.ts +5 -0
- package/src/runtime/curl.js +81 -0
- package/src/runtime/cursor.d.ts +9 -0
- package/src/runtime/cursor.js +80 -0
- package/src/runtime/device.d.ts +14 -0
- package/src/runtime/device.js +73 -0
- package/src/runtime/dot-grid.d.ts +27 -0
- package/src/runtime/dot-grid.js +245 -0
- package/src/runtime/dot-surface.d.ts +46 -0
- package/src/runtime/dot-surface.js +429 -0
- package/src/runtime/feedback.d.ts +18 -0
- package/src/runtime/feedback.js +131 -0
- package/src/runtime/fit-text.d.ts +5 -0
- package/src/runtime/fit-text.js +60 -0
- package/src/runtime/fluid.d.ts +55 -0
- package/src/runtime/fluid.js +504 -0
- package/src/runtime/fluted-glass.d.ts +27 -0
- package/src/runtime/fluted-glass.js +157 -0
- package/src/runtime/gl.d.ts +19 -0
- package/src/runtime/gl.js +104 -0
- package/src/runtime/glass-glyph.d.ts +49 -0
- package/src/runtime/glass-glyph.js +355 -0
- package/src/runtime/glass-sheen.d.ts +2 -0
- package/src/runtime/glass-sheen.js +30 -0
- package/src/runtime/glsl.d.ts +17 -0
- package/src/runtime/glsl.js +78 -0
- package/src/runtime/glyphs.d.ts +22 -0
- package/src/runtime/glyphs.js +107 -0
- package/src/runtime/halo-ring.d.ts +47 -0
- package/src/runtime/halo-ring.js +334 -0
- package/src/runtime/height-field.d.ts +50 -0
- package/src/runtime/height-field.js +176 -0
- package/src/runtime/image-ripple.d.ts +25 -0
- package/src/runtime/image-ripple.js +353 -0
- package/src/runtime/image.d.ts +11 -0
- package/src/runtime/image.js +81 -0
- package/src/runtime/in-view.d.ts +6 -0
- package/src/runtime/in-view.js +36 -0
- package/src/runtime/ink-field/shaders.js +258 -0
- package/src/runtime/ink-field/sim.js +582 -0
- package/src/runtime/ink-field.d.ts +39 -0
- package/src/runtime/ink-field.js +311 -0
- package/src/runtime/ink.d.ts +31 -0
- package/src/runtime/ink.js +109 -0
- package/src/runtime/instancing.d.ts +12 -0
- package/src/runtime/instancing.js +37 -0
- package/src/runtime/iso-camera.d.ts +35 -0
- package/src/runtime/iso-camera.js +85 -0
- package/src/runtime/iso-city/figures.d.ts +30 -0
- package/src/runtime/iso-city/figures.js +136 -0
- package/src/runtime/iso-city/look.d.ts +34 -0
- package/src/runtime/iso-city/look.js +105 -0
- package/src/runtime/iso-city/plan.d.ts +59 -0
- package/src/runtime/iso-city/plan.js +463 -0
- package/src/runtime/iso-city/roads.d.ts +64 -0
- package/src/runtime/iso-city/roads.js +320 -0
- package/src/runtime/iso-city/scene.d.ts +27 -0
- package/src/runtime/iso-city/scene.js +432 -0
- package/src/runtime/iso-city/shaders.d.ts +6 -0
- package/src/runtime/iso-city/shaders.js +233 -0
- package/src/runtime/iso-city/shadows.d.ts +13 -0
- package/src/runtime/iso-city/shadows.js +148 -0
- package/src/runtime/iso-city/traffic.d.ts +80 -0
- package/src/runtime/iso-city/traffic.js +457 -0
- package/src/runtime/iso-city.d.ts +37 -0
- package/src/runtime/iso-city.js +458 -0
- package/src/runtime/lens-map.d.ts +11 -0
- package/src/runtime/lens-map.js +146 -0
- package/src/runtime/light-field.d.ts +29 -0
- package/src/runtime/light-field.js +292 -0
- package/src/runtime/liquid-glass.d.ts +48 -0
- package/src/runtime/liquid-glass.js +423 -0
- package/src/runtime/liquid-metal/beads.js +217 -0
- package/src/runtime/liquid-metal/field.js +88 -0
- package/src/runtime/liquid-metal/look.js +64 -0
- package/src/runtime/liquid-metal/shaders.js +255 -0
- package/src/runtime/liquid-metal/wave.js +53 -0
- package/src/runtime/liquid-metal.d.ts +46 -0
- package/src/runtime/liquid-metal.js +366 -0
- package/src/runtime/loop.d.ts +7 -0
- package/src/runtime/loop.js +112 -0
- package/src/runtime/magnetic.d.ts +9 -0
- package/src/runtime/magnetic.js +46 -0
- package/src/runtime/marquee.d.ts +2 -0
- package/src/runtime/marquee.js +27 -0
- package/src/runtime/mesh.d.ts +30 -0
- package/src/runtime/mesh.js +217 -0
- package/src/runtime/mosaic-reveal.d.ts +34 -0
- package/src/runtime/mosaic-reveal.js +504 -0
- package/src/runtime/motion.d.ts +2 -0
- package/src/runtime/motion.js +21 -0
- package/src/runtime/mount.d.ts +13 -0
- package/src/runtime/mount.js +120 -0
- package/src/runtime/nebula-logo.d.ts +31 -0
- package/src/runtime/nebula-logo.js +282 -0
- package/src/runtime/neon-swarm.d.ts +31 -0
- package/src/runtime/neon-swarm.js +258 -0
- package/src/runtime/ocean/presets.d.ts +54 -0
- package/src/runtime/ocean/presets.js +184 -0
- package/src/runtime/ocean/shader.d.ts +14 -0
- package/src/runtime/ocean/shader.js +389 -0
- package/src/runtime/ocean/view.d.ts +24 -0
- package/src/runtime/ocean/view.js +98 -0
- package/src/runtime/ocean/waves.d.ts +29 -0
- package/src/runtime/ocean/waves.js +119 -0
- package/src/runtime/ocean.d.ts +31 -0
- package/src/runtime/ocean.js +173 -0
- package/src/runtime/palettes.d.ts +37 -0
- package/src/runtime/palettes.js +75 -0
- package/src/runtime/paper-look.d.ts +42 -0
- package/src/runtime/paper-look.js +91 -0
- package/src/runtime/paper-looks.d.ts +17 -0
- package/src/runtime/paper-looks.js +21 -0
- package/src/runtime/paper.d.ts +37 -0
- package/src/runtime/paper.js +285 -0
- package/src/runtime/particle-logo.d.ts +31 -0
- package/src/runtime/particle-logo.js +196 -0
- package/src/runtime/ping-pong.d.ts +43 -0
- package/src/runtime/ping-pong.js +175 -0
- package/src/runtime/pixel-glitch.d.ts +17 -0
- package/src/runtime/pixel-glitch.js +287 -0
- package/src/runtime/point-cloud.d.ts +33 -0
- package/src/runtime/point-cloud.js +287 -0
- package/src/runtime/pointer.d.ts +27 -0
- package/src/runtime/pointer.js +128 -0
- package/src/runtime/points.d.ts +25 -0
- package/src/runtime/points.js +130 -0
- package/src/runtime/pools.d.ts +2 -0
- package/src/runtime/pools.js +25 -0
- package/src/runtime/product-stack.d.ts +24 -0
- package/src/runtime/product-stack.js +210 -0
- package/src/runtime/radiant-glass.d.ts +29 -0
- package/src/runtime/radiant-glass.js +282 -0
- package/src/runtime/rain-on-glass/backdrop.d.ts +22 -0
- package/src/runtime/rain-on-glass/backdrop.js +185 -0
- package/src/runtime/rain-on-glass/shader.d.ts +2 -0
- package/src/runtime/rain-on-glass/shader.js +168 -0
- package/src/runtime/rain-on-glass/wipe.d.ts +16 -0
- package/src/runtime/rain-on-glass/wipe.js +65 -0
- package/src/runtime/rain-on-glass.d.ts +27 -0
- package/src/runtime/rain-on-glass.js +210 -0
- package/src/runtime/ramp.d.ts +2 -0
- package/src/runtime/ramp.js +30 -0
- package/src/runtime/random.d.ts +2 -0
- package/src/runtime/random.js +22 -0
- package/src/runtime/scroll-reveal.d.ts +22 -0
- package/src/runtime/scroll-reveal.js +73 -0
- package/src/runtime/shader-background.d.ts +42 -0
- package/src/runtime/shader-background.js +261 -0
- package/src/runtime/shader-backgrounds/band-lens.js +72 -0
- package/src/runtime/shader-backgrounds/common.js +53 -0
- package/src/runtime/shader-backgrounds/grain-gradient.js +87 -0
- package/src/runtime/shader-backgrounds/grid.js +33 -0
- package/src/runtime/shader-backgrounds/mesh-gradient.js +74 -0
- package/src/runtime/shader-backgrounds/silk.js +57 -0
- package/src/runtime/shader-backgrounds/waves.js +31 -0
- package/src/runtime/shape.d.ts +42 -0
- package/src/runtime/shape.js +313 -0
- package/src/runtime/silk-ribbon.d.ts +23 -0
- package/src/runtime/silk-ribbon.js +206 -0
- package/src/runtime/slideshow.d.ts +27 -0
- package/src/runtime/slideshow.js +234 -0
- package/src/runtime/spotlight.d.ts +9 -0
- package/src/runtime/spotlight.js +97 -0
- package/src/runtime/stack-poses.d.ts +53 -0
- package/src/runtime/stack-poses.js +273 -0
- package/src/runtime/stage.d.ts +47 -0
- package/src/runtime/stage.js +187 -0
- package/src/runtime/swarm.d.ts +49 -0
- package/src/runtime/swarm.js +199 -0
- package/src/runtime/text-motion.d.ts +41 -0
- package/src/runtime/text-motion.js +165 -0
- package/src/runtime/text.d.ts +11 -0
- package/src/runtime/text.js +90 -0
- package/src/runtime/tilt.d.ts +19 -0
- package/src/runtime/tilt.js +116 -0
- package/src/runtime/topography.d.ts +71 -0
- package/src/runtime/topography.js +650 -0
- package/src/runtime/trackers.d.ts +21 -0
- package/src/runtime/trackers.js +76 -0
- package/src/runtime/variable-type.d.ts +43 -0
- package/src/runtime/variable-type.js +358 -0
- package/src/runtime/voxel-logo.d.ts +31 -0
- package/src/runtime/voxel-logo.js +237 -0
- package/src/runtime/waves.d.ts +70 -0
- package/src/runtime/waves.js +799 -0
- package/src/runtime/world-labels.d.ts +29 -0
- package/src/runtime/world-labels.js +59 -0
- package/src/runtime/world-land.d.ts +8 -0
- package/src/runtime/world-land.js +105 -0
- package/src/runtime/world-map.d.ts +69 -0
- package/src/runtime/world-map.js +308 -0
- package/src/runtime/world-plan.d.ts +101 -0
- package/src/runtime/world-plan.js +333 -0
- package/src/runtime/world-routes.d.ts +75 -0
- package/src/runtime/world-routes.js +673 -0
- package/src/styles/border-sweep.css +82 -0
- package/src/styles/glass.css +104 -0
- package/src/styles/motion.css +218 -0
- package/src/styles/reveal.css +51 -0
- package/src/vendor/paper/LICENSE +201 -0
- package/src/vendor/paper/NOTICE +5 -0
- package/src/vendor/paper/README.md +8 -0
- package/src/vendor/paper/get-shader-color-from-string.js +100 -0
- package/src/vendor/paper/get-shader-noise-texture.js +17 -0
- package/src/vendor/paper/presets.js +3678 -0
- package/src/vendor/paper/shader-sizing.js +37 -0
- package/src/vendor/paper/shader-utils.js +130 -0
- package/src/vendor/paper/shaders/color-panels.js +223 -0
- package/src/vendor/paper/shaders/dithering.js +270 -0
- package/src/vendor/paper/shaders/dot-grid.js +109 -0
- package/src/vendor/paper/shaders/dot-orbit.js +122 -0
- package/src/vendor/paper/shaders/fluted-glass.js +360 -0
- package/src/vendor/paper/shaders/gem-smoke.js +572 -0
- package/src/vendor/paper/shaders/god-rays.js +132 -0
- package/src/vendor/paper/shaders/grain-gradient.js +300 -0
- package/src/vendor/paper/shaders/halftone-cmyk.js +294 -0
- package/src/vendor/paper/shaders/halftone-dots.js +320 -0
- package/src/vendor/paper/shaders/heatmap.js +383 -0
- package/src/vendor/paper/shaders/image-dithering.js +198 -0
- package/src/vendor/paper/shaders/lens-distortion.js +275 -0
- package/src/vendor/paper/shaders/liquid-metal.js +632 -0
- package/src/vendor/paper/shaders/mesh-gradient.js +130 -0
- package/src/vendor/paper/shaders/metaballs.js +110 -0
- package/src/vendor/paper/shaders/neuro-noise.js +76 -0
- package/src/vendor/paper/shaders/paper-texture.js +526 -0
- package/src/vendor/paper/shaders/perlin-noise.js +166 -0
- package/src/vendor/paper/shaders/pulsing-border.js +238 -0
- package/src/vendor/paper/shaders/simplex-noise.js +91 -0
- package/src/vendor/paper/shaders/smoke-ring.js +132 -0
- package/src/vendor/paper/shaders/spiral.js +82 -0
- package/src/vendor/paper/shaders/static-mesh-gradient.js +130 -0
- package/src/vendor/paper/shaders/static-radial-gradient.js +187 -0
- package/src/vendor/paper/shaders/swirl.js +103 -0
- package/src/vendor/paper/shaders/voronoi.js +138 -0
- package/src/vendor/paper/shaders/warp.js +129 -0
- package/src/vendor/paper/shaders/water.js +121 -0
- package/src/vendor/paper/shaders/waves.js +65 -0
- package/src/vendor/paper/vertex-shader.js +159 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Cursor: a custom cursor for the whole page: a dot at the pointer and a
|
|
4
|
+
* ring that trails it. Over links, buttons and anything with
|
|
5
|
+
* `data-cursor` the ring swells, showing that element's `data-cursor`
|
|
6
|
+
* text as a label (`<a data-cursor="View">`). The system cursor stays; it
|
|
7
|
+
* is not hidden. Only with a mouse or trackpad; no trail with reduced
|
|
8
|
+
* motion. Place it once, in the layout. See src/runtime/cursor.js.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Cursor color="#ffffff" />
|
|
12
|
+
*/
|
|
13
|
+
import type { CursorConfig } from '../runtime/cursor.js';
|
|
14
|
+
|
|
15
|
+
interface Props extends CursorConfig {
|
|
16
|
+
/** The dot's and ring's colour. Default white. */
|
|
17
|
+
color?: string;
|
|
18
|
+
/** The ring's size at rest, px. Default 32. */
|
|
19
|
+
size?: number;
|
|
20
|
+
/** Blend with the page: `difference` inverts what is under it, readable on any ground. Default `difference`. */
|
|
21
|
+
blend?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { color = '#ffffff', size = 32, blend = 'difference', ...config } = Astro.props;
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<div
|
|
28
|
+
class="effect-cursor"
|
|
29
|
+
data-effect-cursor
|
|
30
|
+
data-effect-config={JSON.stringify(config)}
|
|
31
|
+
style={`--cursor-color: ${color}; --cursor-size: ${size}px; mix-blend-mode: ${blend}`}
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
>
|
|
34
|
+
<span class="dot"></span>
|
|
35
|
+
<span class="ring"><span class="label"></span></span>
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<script>
|
|
39
|
+
import { mount } from '../runtime/mount.js';
|
|
40
|
+
import { cursor } from '../runtime/cursor.js';
|
|
41
|
+
|
|
42
|
+
mount('[data-effect-cursor]', cursor);
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<style>
|
|
46
|
+
.effect-cursor {
|
|
47
|
+
position: fixed;
|
|
48
|
+
inset: 0;
|
|
49
|
+
z-index: 9999;
|
|
50
|
+
pointer-events: none;
|
|
51
|
+
opacity: 0;
|
|
52
|
+
transition: opacity 0.3s ease;
|
|
53
|
+
}
|
|
54
|
+
.effect-cursor:global(.is-active) {
|
|
55
|
+
opacity: 1;
|
|
56
|
+
}
|
|
57
|
+
.dot,
|
|
58
|
+
.ring {
|
|
59
|
+
position: absolute;
|
|
60
|
+
top: 0;
|
|
61
|
+
left: 0;
|
|
62
|
+
border-radius: 999px;
|
|
63
|
+
}
|
|
64
|
+
.dot {
|
|
65
|
+
width: 6px;
|
|
66
|
+
height: 6px;
|
|
67
|
+
margin: -3px 0 0 -3px;
|
|
68
|
+
background: var(--cursor-color);
|
|
69
|
+
}
|
|
70
|
+
.ring {
|
|
71
|
+
display: grid;
|
|
72
|
+
place-items: center;
|
|
73
|
+
width: var(--cursor-size);
|
|
74
|
+
height: var(--cursor-size);
|
|
75
|
+
margin: calc(var(--cursor-size) / -2) 0 0 calc(var(--cursor-size) / -2);
|
|
76
|
+
border: 1.5px solid var(--cursor-color);
|
|
77
|
+
transition:
|
|
78
|
+
width 0.25s ease,
|
|
79
|
+
height 0.25s ease,
|
|
80
|
+
margin 0.25s ease,
|
|
81
|
+
background-color 0.25s ease;
|
|
82
|
+
}
|
|
83
|
+
.effect-cursor:global(.is-over) .ring {
|
|
84
|
+
--cursor-size: 64px;
|
|
85
|
+
background: color-mix(in srgb, var(--cursor-color) 12%, transparent);
|
|
86
|
+
}
|
|
87
|
+
.effect-cursor:global(.is-down) .ring {
|
|
88
|
+
--cursor-size: 24px;
|
|
89
|
+
}
|
|
90
|
+
.label {
|
|
91
|
+
font: 600 10px/1 ui-sans-serif, system-ui, sans-serif;
|
|
92
|
+
letter-spacing: 0.06em;
|
|
93
|
+
text-transform: uppercase;
|
|
94
|
+
color: var(--cursor-color);
|
|
95
|
+
white-space: nowrap;
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* DotGrid: a sea of dots you can drop stones into. A slow current moves
|
|
4
|
+
* through a fixed grid of dots, a swell sits under the pointer, and a
|
|
5
|
+
* click sends a widening ripple across, lifting and pushing the dots.
|
|
6
|
+
* See src/runtime/dot-grid.js.
|
|
7
|
+
*
|
|
8
|
+
* Transparent: it lays over the section's background. Fills its nearest
|
|
9
|
+
* positioned ancestor, or the viewport behind the page with `fixed` (give
|
|
10
|
+
* `body` a transparent background so it shows).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <DotGrid fixed color="#ffffff" pitch={26} />
|
|
14
|
+
*/
|
|
15
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
16
|
+
import type { DotGridConfig } from '../runtime/dot-grid.js';
|
|
17
|
+
|
|
18
|
+
interface Props extends DotGridConfig {
|
|
19
|
+
/** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
|
|
20
|
+
fixed?: boolean;
|
|
21
|
+
class?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const { fixed = false, class: className, ...config } = Astro.props;
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
<EffectCanvas name="dot-grid" config={config} fixed={fixed} class={className} behind />
|
|
28
|
+
|
|
29
|
+
<script>
|
|
30
|
+
import { mount } from '../runtime/mount.js';
|
|
31
|
+
import { dotGrid } from '../runtime/dot-grid.js';
|
|
32
|
+
|
|
33
|
+
mount('[data-effect-dot-grid]', dotGrid);
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* DotSurface: a halftone sea. A grid of round dots lies on a slowly
|
|
4
|
+
* rolling sheet seen in perspective, each dot sized and lit by how the
|
|
5
|
+
* light catches the sheet: lit crests swell into large bright dots,
|
|
6
|
+
* troughs shrink to pinpoints. The pointer raises a soft swell; a click
|
|
7
|
+
* sends a ring across. See src/runtime/dot-surface.js.
|
|
8
|
+
*
|
|
9
|
+
* Transparent: it lays over the section's background. Fills its nearest
|
|
10
|
+
* positioned ancestor, or the viewport behind the page with `fixed` (give
|
|
11
|
+
* `body` a transparent background so it shows).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <DotSurface color="#ff8a1f" quiet={{ x: 0.3, y: 0.3, radius: 0.5 }} />
|
|
15
|
+
*/
|
|
16
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
17
|
+
import type { DotSurfaceConfig } from '../runtime/dot-surface.js';
|
|
18
|
+
|
|
19
|
+
interface Props extends DotSurfaceConfig {
|
|
20
|
+
/** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
|
|
21
|
+
fixed?: boolean;
|
|
22
|
+
class?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const { fixed = false, class: className, ...config } = Astro.props;
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
<EffectCanvas name="dot-surface" config={config} fixed={fixed} class={className} behind />
|
|
29
|
+
|
|
30
|
+
<script>
|
|
31
|
+
import { mount } from '../runtime/mount.js';
|
|
32
|
+
import { dotSurface } from '../runtime/dot-surface.js';
|
|
33
|
+
|
|
34
|
+
mount('[data-effect-dot-surface]', dotSurface);
|
|
35
|
+
</script>
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* EffectCanvas: the element and canvas every canvas effect renders, so
|
|
4
|
+
* each effect's component is only its props and its `mount` script.
|
|
5
|
+
*
|
|
6
|
+
* Renders `<div data-effect-<name> data-effect-config="…"><canvas>`,
|
|
7
|
+
* filling its nearest positioned ancestor, or the viewport with `fixed`
|
|
8
|
+
* (behind the page, at z-index -1, when `behind` is set too). Hidden from
|
|
9
|
+
* assistive technology: effects are decoration. Also styles the tracker
|
|
10
|
+
* boxes some effects lay over themselves (src/runtime/trackers.js).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* <EffectCanvas name="ink" config={config} fixed={fixed} class={className} />
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
/** The effect's name: the element gets `data-effect-<name>`. */
|
|
18
|
+
name: string;
|
|
19
|
+
/** The settings the runtime reads, as JSON in `data-effect-config`. */
|
|
20
|
+
config: Record<string, unknown>;
|
|
21
|
+
/** Fill the viewport (position: fixed). Default false. */
|
|
22
|
+
fixed?: boolean;
|
|
23
|
+
/** With `fixed`, sit behind the page (z-index -1). Default false. */
|
|
24
|
+
behind?: boolean;
|
|
25
|
+
/** CSS `background` for the element: what shows before the canvas draws, and without WebGL. */
|
|
26
|
+
background?: string;
|
|
27
|
+
/** Keep the canvas's pixels square when it is scaled up (for dithered effects). Default false. */
|
|
28
|
+
pixelated?: boolean;
|
|
29
|
+
/** Fade edges out, so it blends into the section: true for the left and right, or 'top', 'bottom' or 'both' (top and bottom). Default false. */
|
|
30
|
+
fade?: boolean | 'top' | 'bottom' | 'both';
|
|
31
|
+
/** Its opacity, 0–1. Default 1. */
|
|
32
|
+
opacity?: number;
|
|
33
|
+
/** CSS `mix-blend-mode` with what is behind it (`screen`, `plus-lighter`…). Default normal. */
|
|
34
|
+
blend?: string;
|
|
35
|
+
class?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const { name, config, fixed = false, behind = false, background, pixelated = false, fade = false, opacity, blend, class: className } = Astro.props;
|
|
39
|
+
const style = [
|
|
40
|
+
background && `background: ${background}`,
|
|
41
|
+
opacity !== undefined && opacity < 1 && `opacity: ${opacity}`,
|
|
42
|
+
blend && blend !== 'normal' && `mix-blend-mode: ${blend}`,
|
|
43
|
+
]
|
|
44
|
+
.filter(Boolean)
|
|
45
|
+
.join('; ');
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
<div
|
|
49
|
+
class:list={['effect-canvas', { 'is-fixed': fixed, 'is-behind': fixed && behind, 'is-pixelated': pixelated, 'is-faded': fade === true }, typeof fade === 'string' && `is-faded-${fade}`, className]}
|
|
50
|
+
data-effect-config={JSON.stringify(config)}
|
|
51
|
+
style={style || undefined}
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
{...{ [`data-effect-${name}`]: '' }}
|
|
54
|
+
>
|
|
55
|
+
<canvas></canvas>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<style>
|
|
59
|
+
.effect-canvas {
|
|
60
|
+
position: absolute;
|
|
61
|
+
inset: 0;
|
|
62
|
+
overflow: hidden;
|
|
63
|
+
pointer-events: none;
|
|
64
|
+
}
|
|
65
|
+
.effect-canvas.is-fixed {
|
|
66
|
+
position: fixed;
|
|
67
|
+
}
|
|
68
|
+
.effect-canvas.is-behind {
|
|
69
|
+
z-index: -1;
|
|
70
|
+
}
|
|
71
|
+
canvas {
|
|
72
|
+
display: block;
|
|
73
|
+
width: 100%;
|
|
74
|
+
height: 100%;
|
|
75
|
+
}
|
|
76
|
+
.effect-canvas.is-faded {
|
|
77
|
+
-webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
|
|
78
|
+
mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
|
|
79
|
+
}
|
|
80
|
+
.effect-canvas.is-faded-bottom {
|
|
81
|
+
-webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
|
|
82
|
+
mask-image: linear-gradient(to bottom, #000 55%, transparent 100%);
|
|
83
|
+
}
|
|
84
|
+
.effect-canvas.is-faded-top {
|
|
85
|
+
-webkit-mask-image: linear-gradient(to top, #000 55%, transparent 100%);
|
|
86
|
+
mask-image: linear-gradient(to top, #000 55%, transparent 100%);
|
|
87
|
+
}
|
|
88
|
+
.effect-canvas.is-faded-both {
|
|
89
|
+
-webkit-mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
|
|
90
|
+
mask-image: linear-gradient(to bottom, transparent, #000 18%, #000 82%, transparent);
|
|
91
|
+
}
|
|
92
|
+
/* Dithered effects draw at a low resolution on purpose: keep their pixels square. */
|
|
93
|
+
.effect-canvas.is-pixelated canvas {
|
|
94
|
+
image-rendering: pixelated;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/* Tracker boxes (src/runtime/trackers.js), added by the runtime, so styled
|
|
98
|
+
through :global. Colour from --effect-tracker-color. */
|
|
99
|
+
.effect-canvas :global(.effect-trackers) {
|
|
100
|
+
position: absolute;
|
|
101
|
+
inset: 0;
|
|
102
|
+
--c: var(--effect-tracker-color, rgb(255 255 255 / 0.9));
|
|
103
|
+
--arm: 12px;
|
|
104
|
+
--line: 1.5px;
|
|
105
|
+
}
|
|
106
|
+
.effect-canvas :global(.effect-tracker) {
|
|
107
|
+
position: absolute;
|
|
108
|
+
top: 0;
|
|
109
|
+
left: 0;
|
|
110
|
+
opacity: 0;
|
|
111
|
+
transition: opacity 0.4s ease;
|
|
112
|
+
}
|
|
113
|
+
/* A box: four corner brackets over a faint fill. */
|
|
114
|
+
.effect-canvas :global(.effect-tracker.is-box) {
|
|
115
|
+
background:
|
|
116
|
+
linear-gradient(var(--c), var(--c)) top left / var(--arm) var(--line) no-repeat,
|
|
117
|
+
linear-gradient(var(--c), var(--c)) top left / var(--line) var(--arm) no-repeat,
|
|
118
|
+
linear-gradient(var(--c), var(--c)) top right / var(--arm) var(--line) no-repeat,
|
|
119
|
+
linear-gradient(var(--c), var(--c)) top right / var(--line) var(--arm) no-repeat,
|
|
120
|
+
linear-gradient(var(--c), var(--c)) bottom left / var(--arm) var(--line) no-repeat,
|
|
121
|
+
linear-gradient(var(--c), var(--c)) bottom left / var(--line) var(--arm) no-repeat,
|
|
122
|
+
linear-gradient(var(--c), var(--c)) bottom right / var(--arm) var(--line) no-repeat,
|
|
123
|
+
linear-gradient(var(--c), var(--c)) bottom right / var(--line) var(--arm) no-repeat,
|
|
124
|
+
rgb(0 0 0 / 0.25);
|
|
125
|
+
}
|
|
126
|
+
/* A marker: a small crosshair at the box's centre. */
|
|
127
|
+
.effect-canvas :global(.effect-tracker.is-marker) {
|
|
128
|
+
background:
|
|
129
|
+
linear-gradient(var(--c), var(--c)) center / var(--arm) var(--line) no-repeat,
|
|
130
|
+
linear-gradient(var(--c), var(--c)) center / var(--line) var(--arm) no-repeat;
|
|
131
|
+
outline: var(--line) solid color-mix(in srgb, var(--c) 45%, transparent);
|
|
132
|
+
outline-offset: -4px;
|
|
133
|
+
}
|
|
134
|
+
.effect-canvas :global(.effect-tracker span) {
|
|
135
|
+
position: absolute;
|
|
136
|
+
left: 4px;
|
|
137
|
+
bottom: 4px;
|
|
138
|
+
padding: 1px 4px;
|
|
139
|
+
font: 500 9px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
140
|
+
letter-spacing: 0.04em;
|
|
141
|
+
color: #000;
|
|
142
|
+
background: var(--c);
|
|
143
|
+
white-space: nowrap;
|
|
144
|
+
}
|
|
145
|
+
.effect-canvas :global(.effect-tracker.is-marker span) {
|
|
146
|
+
left: calc(100% + 4px);
|
|
147
|
+
bottom: auto;
|
|
148
|
+
top: 0;
|
|
149
|
+
color: var(--c);
|
|
150
|
+
background: none;
|
|
151
|
+
}
|
|
152
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* FitText: one line of text sized to exactly span its parent's content
|
|
4
|
+
* width, whatever the text and the window. See src/runtime/fit-text.js.
|
|
5
|
+
* Give it a CSS font-size as the fallback without script.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* <FitText as="div" class="wordmark">Northwave</FitText>
|
|
9
|
+
*/
|
|
10
|
+
import type { HTMLTag } from 'astro/types';
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
/** The element to render. Default `div`. */
|
|
14
|
+
as?: HTMLTag;
|
|
15
|
+
class?: string;
|
|
16
|
+
[attribute: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const { as: Tag = 'div', class: className, ...attributes } = Astro.props;
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
<Tag class:list={['effect-fit-text', className]} data-fit-text {...attributes}><slot /></Tag>
|
|
23
|
+
|
|
24
|
+
<script>
|
|
25
|
+
import { mount } from '../runtime/mount.js';
|
|
26
|
+
import { fitText } from '../runtime/fit-text.js';
|
|
27
|
+
|
|
28
|
+
mount('[data-fit-text]', fitText);
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.effect-fit-text {
|
|
33
|
+
white-space: nowrap;
|
|
34
|
+
}
|
|
35
|
+
</style>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* FlutedGlass: a pane of slanted fluted glass over soft blooms of colour,
|
|
4
|
+
* the main one following the pointer. Each rib bends what is behind it and
|
|
5
|
+
* fringes it with a thin rainbow. See src/runtime/fluted-glass.js.
|
|
6
|
+
*
|
|
7
|
+
* Opaque: it is the whole background of what it fills (its nearest
|
|
8
|
+
* positioned ancestor, or the viewport with `fixed`). Without WebGL the
|
|
9
|
+
* `background` colour shows.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <section class="hero" style="position: relative">
|
|
13
|
+
* <FlutedGlass colors={['#4f46e5', '#a78bfa', '#f0abfc']} />
|
|
14
|
+
* <h1>Brands seen through <em>a different light.</em></h1>
|
|
15
|
+
* </section>
|
|
16
|
+
*/
|
|
17
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
18
|
+
import type { FlutedGlassConfig } from '../runtime/fluted-glass.js';
|
|
19
|
+
|
|
20
|
+
interface Props extends FlutedGlassConfig {
|
|
21
|
+
/** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
|
|
22
|
+
fixed?: boolean;
|
|
23
|
+
class?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const { fixed = false, class: className, ...config } = Astro.props;
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
<EffectCanvas name="fluted-glass" config={config} fixed={fixed} class={className} behind background={config.background ?? '#f4f4f5'} />
|
|
30
|
+
|
|
31
|
+
<script>
|
|
32
|
+
import { mount } from '../runtime/mount.js';
|
|
33
|
+
import { flutedGlass } from '../runtime/fluted-glass.js';
|
|
34
|
+
|
|
35
|
+
mount('[data-effect-fluted-glass]', flutedGlass);
|
|
36
|
+
</script>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Glass: a liquid glass panel, with a rim that catches the light and a
|
|
4
|
+
* sheen that follows the pointer. A wrapper for `class="glass"` from
|
|
5
|
+
* glass.css that also starts the sheen; for elements you render yourself,
|
|
6
|
+
* import `@arraypress/effects-astro/glass.css` and add the class, then
|
|
7
|
+
* call `glassSheen()` once.
|
|
8
|
+
*
|
|
9
|
+
* Glass blurs what is behind it, so it needs something behind: a
|
|
10
|
+
* `<LightField>`, an image, a gradient. With `refract` it bends it too, as
|
|
11
|
+
* a thick lens does at its rim (Chromium; Safari and Firefox keep the
|
|
12
|
+
* frost); text behind stays live and links stay clickable.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <Glass as="article" class="card" tint="#08080a">…</Glass>
|
|
16
|
+
* <Glass refract dispersion={0.5} style="border-radius: 28px">…</Glass>
|
|
17
|
+
*/
|
|
18
|
+
import type { HTMLTag } from 'astro/types';
|
|
19
|
+
import '../styles/glass.css';
|
|
20
|
+
import { withStyle } from './style.js';
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
/** The element to render. Default `div`. */
|
|
24
|
+
as?: HTMLTag;
|
|
25
|
+
/** The body's tint colour. Default near-black. */
|
|
26
|
+
tint?: string;
|
|
27
|
+
/** How much of the tint the body takes, 0–100 (%). Default 30. */
|
|
28
|
+
amount?: number;
|
|
29
|
+
/** How much it blurs what is behind, px. Default 20, or 0.5 with `refract`. */
|
|
30
|
+
blur?: number;
|
|
31
|
+
/** How far it rises on hover, px; 0 for none. Default 2. */
|
|
32
|
+
lift?: number;
|
|
33
|
+
/** Bends what is behind like a thick lens at the rim, 0–2, or `true` for 1. Chromium only; elsewhere the frost stays. Default false. */
|
|
34
|
+
refract?: boolean | number;
|
|
35
|
+
/** With `refract`, how much the rim splits what it bends into colours, 0–1. Default 0.35. */
|
|
36
|
+
dispersion?: number;
|
|
37
|
+
/** With `refract`, how wide the bending rim is, px. Default 28. */
|
|
38
|
+
bezel?: number;
|
|
39
|
+
/** With `refract`, how bright the highlight along the rim is, 0–1. Default 0.7. */
|
|
40
|
+
specular?: number;
|
|
41
|
+
class?: string;
|
|
42
|
+
[attribute: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const { as: Tag = 'div', tint, amount, blur, lift, refract, dispersion, bezel, specular, class: className, style: given, ...attributes } = Astro.props;
|
|
46
|
+
const style = [
|
|
47
|
+
tint && `--glass-tint: ${tint}`,
|
|
48
|
+
amount !== undefined && `--glass-tint-amount: ${amount}%`,
|
|
49
|
+
blur !== undefined && `--glass-blur: ${blur}px`,
|
|
50
|
+
lift !== undefined && `--glass-lift: ${lift}px`,
|
|
51
|
+
refract !== undefined && `--glass-refract: ${refract}`,
|
|
52
|
+
dispersion !== undefined && `--glass-dispersion: ${dispersion}`,
|
|
53
|
+
bezel !== undefined && `--glass-bezel: ${bezel}px`,
|
|
54
|
+
specular !== undefined && `--glass-specular: ${specular}`,
|
|
55
|
+
refract && blur !== undefined && `--glass-lens-blur: ${blur}px`,
|
|
56
|
+
]
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join('; ');
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
<Tag class:list={['glass', className]} style={withStyle(style, given)} {...attributes}><slot /></Tag>
|
|
62
|
+
|
|
63
|
+
<script>
|
|
64
|
+
import { glassSheen } from '../runtime/glass-sheen.js';
|
|
65
|
+
import { glassLens } from '../runtime/liquid-glass.js';
|
|
66
|
+
|
|
67
|
+
glassSheen();
|
|
68
|
+
glassLens();
|
|
69
|
+
</script>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* GlassGlyph: a character or a logo as a thick slab of dark, smoked glass,
|
|
4
|
+
* lit from behind by beams of one coloured light. The light barely shows on
|
|
5
|
+
* the near-black ground; the glass catches it and glows with it through its
|
|
6
|
+
* body and bevels. The slab turns slowly on its own and leans away from the
|
|
7
|
+
* pointer; the light stays put. See src/runtime/glass-glyph.js.
|
|
8
|
+
*
|
|
9
|
+
* Opaque: it is the whole background of what it fills (its nearest
|
|
10
|
+
* positioned ancestor, or the viewport with `fixed`). Without WebGL the
|
|
11
|
+
* `background` colour shows.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <section class="hero" style="position: relative">
|
|
15
|
+
* <GlassGlyph text="7" font="900 Anton, sans-serif" colors={['#c6ff00', '#9fb08a']} />
|
|
16
|
+
* <h1>…</h1>
|
|
17
|
+
* </section>
|
|
18
|
+
*/
|
|
19
|
+
import EffectCanvas from './EffectCanvas.astro';
|
|
20
|
+
import type { GlassGlyphConfig } from '../runtime/glass-glyph.js';
|
|
21
|
+
|
|
22
|
+
interface Props extends GlassGlyphConfig {
|
|
23
|
+
/** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
|
|
24
|
+
fixed?: boolean;
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { fixed = false, class: className, ...config } = Astro.props;
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
<EffectCanvas name="glass-glyph" config={config} fixed={fixed} class={className} behind background={config.background ?? '#050505'} />
|
|
32
|
+
|
|
33
|
+
<script>
|
|
34
|
+
import { mount } from '../runtime/mount.js';
|
|
35
|
+
import { glassGlyph } from '../runtime/glass-glyph.js';
|
|
36
|
+
|
|
37
|
+
mount('[data-effect-glass-glyph]', glassGlyph);
|
|
38
|
+
</script>
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* GlowField: a light laid over a section's background, or over a shader: a
|
|
4
|
+
* hard light source above an organic wash, so a headline has something to
|
|
5
|
+
* sit in. Pure CSS gradients that move only by transform and opacity, so it
|
|
6
|
+
* costs next to nothing and cannot fail to start.
|
|
7
|
+
*
|
|
8
|
+
* Variants:
|
|
9
|
+
* - `bloom`: a soft ellipse of light high on the section. The safe default.
|
|
10
|
+
* - `beam`: a stage spotlight: a cone from the top edge with a hot origin,
|
|
11
|
+
* landing in a pool of light low on the section; wants a short headline
|
|
12
|
+
* under it.
|
|
13
|
+
* - `horizon`: a bright band along the top edge, like a light just out of
|
|
14
|
+
* frame. Suits a grid or waves underneath.
|
|
15
|
+
* - `wash`: a diagonal tint from one corner fading into the ground.
|
|
16
|
+
*
|
|
17
|
+
* On a dark ground the light adds (`screen`). On a light one a coloured
|
|
18
|
+
* light would read as a stain, so `tone="light"` multiplies instead, at
|
|
19
|
+
* about a fifth of the strength. Fills its nearest positioned ancestor;
|
|
20
|
+
* put it before the content, which needs to sit above it. The light
|
|
21
|
+
* breathes, and a beam sways slowly on its rig; `still` holds it, and so
|
|
22
|
+
* does reduced motion.
|
|
23
|
+
*
|
|
24
|
+
* From the AgentGrid and LinkGrid themes.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* <section class="hero" style="position: relative">
|
|
28
|
+
* <GlowField variant="beam" color="#a5b4fc" />
|
|
29
|
+
* <h1>…</h1>
|
|
30
|
+
* </section>
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
interface Props {
|
|
34
|
+
/** The shape of the light. Default `bloom`. */
|
|
35
|
+
variant?: 'bloom' | 'beam' | 'horizon' | 'wash';
|
|
36
|
+
/** The light's colour. Default white. */
|
|
37
|
+
color?: string;
|
|
38
|
+
/** A multiplier on its strength; 1 as designed. Default 1. */
|
|
39
|
+
intensity?: number;
|
|
40
|
+
/** The ground it is on: `dark` adds light, `light` shades. Default `dark`. */
|
|
41
|
+
tone?: 'dark' | 'light';
|
|
42
|
+
/** Where across the top the light comes from, 0–100 (%). Default 50. */
|
|
43
|
+
x?: number;
|
|
44
|
+
/** Hold the light still. Default false. */
|
|
45
|
+
still?: boolean;
|
|
46
|
+
class?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { variant = 'bloom', color = '#ffffff', intensity = 1, tone = 'dark', x = 50, still = false, class: className } = Astro.props;
|
|
50
|
+
// Light on a light ground is a fifth as strong: see the docblock.
|
|
51
|
+
const scale = intensity * (tone === 'light' ? 0.2 : 1);
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
<div
|
|
55
|
+
class:list={['effect-glow-field', `is-${variant}`, `on-${tone}`, { 'is-still': still }, className]}
|
|
56
|
+
style={`--glow-color: ${color}; --glow-scale: ${scale}; --glow-x: ${x}%`}
|
|
57
|
+
aria-hidden="true"
|
|
58
|
+
>
|
|
59
|
+
</div>
|
|
60
|
+
|
|
61
|
+
<style>
|
|
62
|
+
.effect-glow-field {
|
|
63
|
+
position: absolute;
|
|
64
|
+
inset: 0;
|
|
65
|
+
overflow: hidden;
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
--glow-core: calc(60% * var(--glow-scale));
|
|
68
|
+
--glow-halo: calc(22% * var(--glow-scale));
|
|
69
|
+
--glow-edge: calc(85% * var(--glow-scale));
|
|
70
|
+
/* Light adds to what is underneath rather than painting over it. */
|
|
71
|
+
mix-blend-mode: screen;
|
|
72
|
+
}
|
|
73
|
+
/* Screening a dark light over white does nothing: multiply is the dual. */
|
|
74
|
+
.effect-glow-field.on-light {
|
|
75
|
+
mix-blend-mode: multiply;
|
|
76
|
+
}
|
|
77
|
+
/* Two layers: the light itself (::before), which moves, and its source
|
|
78
|
+
and spill (::after), which breathe. */
|
|
79
|
+
.effect-glow-field::before,
|
|
80
|
+
.effect-glow-field::after {
|
|
81
|
+
content: '';
|
|
82
|
+
position: absolute;
|
|
83
|
+
inset: 0;
|
|
84
|
+
}
|
|
85
|
+
.effect-glow-field::after {
|
|
86
|
+
animation: glow-breathe 7s ease-in-out infinite;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.is-bloom::before {
|
|
90
|
+
inset: -10%;
|
|
91
|
+
background: radial-gradient(ellipse 52% 44% at var(--glow-x) 14%, color-mix(in srgb, var(--glow-color) var(--glow-core), transparent), transparent 72%);
|
|
92
|
+
animation: glow-drift 16s ease-in-out infinite alternate;
|
|
93
|
+
}
|
|
94
|
+
.is-bloom::after {
|
|
95
|
+
background: radial-gradient(ellipse 90% 70% at var(--glow-x) 0%, color-mix(in srgb, var(--glow-color) var(--glow-halo), transparent), transparent 78%);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* The cone: a conic gradient, softened, swinging a few degrees about the
|
|
99
|
+
rig at the top edge. Faded out before it reaches the foot. */
|
|
100
|
+
.is-beam::before {
|
|
101
|
+
inset: -12% -30% 0;
|
|
102
|
+
background: conic-gradient(
|
|
103
|
+
at var(--glow-x) 0%,
|
|
104
|
+
transparent 0deg,
|
|
105
|
+
transparent 156deg,
|
|
106
|
+
color-mix(in srgb, var(--glow-color) calc(var(--glow-core) * 0.35), transparent) 166deg,
|
|
107
|
+
color-mix(in srgb, var(--glow-color) var(--glow-core), transparent) 180deg,
|
|
108
|
+
color-mix(in srgb, var(--glow-color) calc(var(--glow-core) * 0.35), transparent) 194deg,
|
|
109
|
+
transparent 204deg,
|
|
110
|
+
transparent 360deg
|
|
111
|
+
);
|
|
112
|
+
filter: blur(14px);
|
|
113
|
+
-webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 45%, transparent 92%);
|
|
114
|
+
mask-image: linear-gradient(to bottom, #000 0%, #000 45%, transparent 92%);
|
|
115
|
+
transform-origin: var(--glow-x) 0%;
|
|
116
|
+
animation: glow-sway 11s ease-in-out infinite alternate;
|
|
117
|
+
}
|
|
118
|
+
/* The hot source at the rig, the haze round it, and the pool where the
|
|
119
|
+
beam lands. */
|
|
120
|
+
.is-beam::after {
|
|
121
|
+
background:
|
|
122
|
+
radial-gradient(ellipse 14% 9% at var(--glow-x) 0%, color-mix(in srgb, var(--glow-color) var(--glow-edge), transparent), transparent 70%),
|
|
123
|
+
radial-gradient(ellipse 34% 7% at var(--glow-x) 84%, color-mix(in srgb, var(--glow-color) calc(var(--glow-core) * 0.55), transparent), transparent 72%),
|
|
124
|
+
radial-gradient(ellipse 80% 60% at var(--glow-x) 0%, color-mix(in srgb, var(--glow-color) var(--glow-halo), transparent), transparent 76%);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.is-horizon::before {
|
|
128
|
+
background: linear-gradient(to bottom, color-mix(in srgb, var(--glow-color) var(--glow-edge), transparent) 0%, transparent 14%);
|
|
129
|
+
}
|
|
130
|
+
.is-horizon::after {
|
|
131
|
+
background: radial-gradient(ellipse 70% 40% at var(--glow-x) 0%, color-mix(in srgb, var(--glow-color) var(--glow-core), transparent), transparent 70%);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.is-wash::before {
|
|
135
|
+
inset: -15%;
|
|
136
|
+
background: linear-gradient(
|
|
137
|
+
155deg,
|
|
138
|
+
color-mix(in srgb, var(--glow-color) var(--glow-core), transparent) 0%,
|
|
139
|
+
color-mix(in srgb, var(--glow-color) calc(var(--glow-halo) * 0.5), transparent) 52%,
|
|
140
|
+
transparent 100%
|
|
141
|
+
);
|
|
142
|
+
animation: glow-drift 18s ease-in-out infinite alternate;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
@keyframes glow-breathe {
|
|
146
|
+
50% {
|
|
147
|
+
opacity: 0.72;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
@keyframes glow-sway {
|
|
151
|
+
from {
|
|
152
|
+
transform: rotate(-4deg);
|
|
153
|
+
}
|
|
154
|
+
to {
|
|
155
|
+
transform: rotate(4deg);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
@keyframes glow-drift {
|
|
159
|
+
from {
|
|
160
|
+
transform: translate(-3%, -1%) scale(1);
|
|
161
|
+
}
|
|
162
|
+
to {
|
|
163
|
+
transform: translate(3%, 2%) scale(1.06);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
.is-still::before,
|
|
168
|
+
.is-still::after {
|
|
169
|
+
animation: none;
|
|
170
|
+
}
|
|
171
|
+
@media (prefers-reduced-motion: reduce) {
|
|
172
|
+
.effect-glow-field::before,
|
|
173
|
+
.effect-glow-field::after {
|
|
174
|
+
animation: none;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
</style>
|