@arraypress/effects-astro 0.0.0-stage → 0.1.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.
Files changed (314) hide show
  1. package/AGENTS.md +85 -0
  2. package/COMPONENTS.md +1264 -0
  3. package/LICENSE +139 -0
  4. package/README.md +197 -2
  5. package/package.json +60 -4
  6. package/src/components/AsciiRain.astro +36 -0
  7. package/src/components/BorderSweep.astro +39 -0
  8. package/src/components/Caustics.astro +39 -0
  9. package/src/components/ColorPanels.astro +62 -0
  10. package/src/components/Cursor.astro +97 -0
  11. package/src/components/DotGrid.astro +34 -0
  12. package/src/components/DotSurface.astro +35 -0
  13. package/src/components/EffectCanvas.astro +152 -0
  14. package/src/components/FitText.astro +35 -0
  15. package/src/components/FlutedGlass.astro +36 -0
  16. package/src/components/Glass.astro +69 -0
  17. package/src/components/GlassGlyph.astro +38 -0
  18. package/src/components/GlowField.astro +177 -0
  19. package/src/components/Grain.astro +98 -0
  20. package/src/components/HaloRing.astro +38 -0
  21. package/src/components/HighlightSweep.astro +74 -0
  22. package/src/components/ImageRipple.astro +56 -0
  23. package/src/components/Ink.astro +37 -0
  24. package/src/components/InkField.astro +45 -0
  25. package/src/components/IsoCity.astro +54 -0
  26. package/src/components/LightField.astro +40 -0
  27. package/src/components/LiquidMetal.astro +41 -0
  28. package/src/components/Magnetic.astro +52 -0
  29. package/src/components/Marquee.astro +216 -0
  30. package/src/components/MosaicReveal.astro +196 -0
  31. package/src/components/NebulaLogo.astro +38 -0
  32. package/src/components/NeonSwarm.astro +38 -0
  33. package/src/components/Ocean.astro +40 -0
  34. package/src/components/OutlineWordmark.astro +222 -0
  35. package/src/components/PaperBackground.astro +40 -0
  36. package/src/components/PaperShader.astro +55 -0
  37. package/src/components/Parallax.astro +49 -0
  38. package/src/components/ParticleLogo.astro +37 -0
  39. package/src/components/PixelGlitchText.astro +70 -0
  40. package/src/components/PointCloud.astro +37 -0
  41. package/src/components/ProductStack.astro +298 -0
  42. package/src/components/PulseMark.astro +189 -0
  43. package/src/components/RadiantGlass.astro +38 -0
  44. package/src/components/RainOnGlass.astro +71 -0
  45. package/src/components/Reveal.astro +115 -0
  46. package/src/components/ScrambleText.astro +52 -0
  47. package/src/components/ScrollReveal.astro +38 -0
  48. package/src/components/ShaderBackground.astro +55 -0
  49. package/src/components/SignalLines.astro +41 -0
  50. package/src/components/SilkRibbon.astro +37 -0
  51. package/src/components/SpotlightText.astro +131 -0
  52. package/src/components/Tilt.astro +79 -0
  53. package/src/components/Topography.astro +38 -0
  54. package/src/components/Typewriter.astro +66 -0
  55. package/src/components/VariableType.astro +59 -0
  56. package/src/components/VoxelLogo.astro +46 -0
  57. package/src/components/WaveBars.astro +41 -0
  58. package/src/components/WorldRoutes.astro +41 -0
  59. package/src/components/style.js +19 -0
  60. package/src/index.d.ts +143 -0
  61. package/src/index.js +105 -0
  62. package/src/runtime/ascii-rain.d.ts +53 -0
  63. package/src/runtime/ascii-rain.js +355 -0
  64. package/src/runtime/audio-meter.d.ts +65 -0
  65. package/src/runtime/audio-meter.js +282 -0
  66. package/src/runtime/audio.d.ts +26 -0
  67. package/src/runtime/audio.js +453 -0
  68. package/src/runtime/blur.d.ts +2 -0
  69. package/src/runtime/blur.js +56 -0
  70. package/src/runtime/canvas2d.d.ts +23 -0
  71. package/src/runtime/canvas2d.js +105 -0
  72. package/src/runtime/caustics.d.ts +40 -0
  73. package/src/runtime/caustics.js +286 -0
  74. package/src/runtime/color.d.ts +33 -0
  75. package/src/runtime/color.js +213 -0
  76. package/src/runtime/curl.d.ts +5 -0
  77. package/src/runtime/curl.js +81 -0
  78. package/src/runtime/cursor.d.ts +9 -0
  79. package/src/runtime/cursor.js +80 -0
  80. package/src/runtime/device.d.ts +14 -0
  81. package/src/runtime/device.js +73 -0
  82. package/src/runtime/dot-grid.d.ts +27 -0
  83. package/src/runtime/dot-grid.js +245 -0
  84. package/src/runtime/dot-surface.d.ts +46 -0
  85. package/src/runtime/dot-surface.js +429 -0
  86. package/src/runtime/feedback.d.ts +18 -0
  87. package/src/runtime/feedback.js +131 -0
  88. package/src/runtime/fit-text.d.ts +5 -0
  89. package/src/runtime/fit-text.js +60 -0
  90. package/src/runtime/fluid.d.ts +55 -0
  91. package/src/runtime/fluid.js +504 -0
  92. package/src/runtime/fluted-glass.d.ts +27 -0
  93. package/src/runtime/fluted-glass.js +157 -0
  94. package/src/runtime/gl.d.ts +19 -0
  95. package/src/runtime/gl.js +104 -0
  96. package/src/runtime/glass-glyph.d.ts +49 -0
  97. package/src/runtime/glass-glyph.js +355 -0
  98. package/src/runtime/glass-sheen.d.ts +2 -0
  99. package/src/runtime/glass-sheen.js +30 -0
  100. package/src/runtime/glsl.d.ts +17 -0
  101. package/src/runtime/glsl.js +78 -0
  102. package/src/runtime/glyphs.d.ts +22 -0
  103. package/src/runtime/glyphs.js +107 -0
  104. package/src/runtime/halo-ring.d.ts +47 -0
  105. package/src/runtime/halo-ring.js +334 -0
  106. package/src/runtime/height-field.d.ts +50 -0
  107. package/src/runtime/height-field.js +176 -0
  108. package/src/runtime/image-ripple.d.ts +25 -0
  109. package/src/runtime/image-ripple.js +353 -0
  110. package/src/runtime/image.d.ts +11 -0
  111. package/src/runtime/image.js +81 -0
  112. package/src/runtime/in-view.d.ts +6 -0
  113. package/src/runtime/in-view.js +36 -0
  114. package/src/runtime/ink-field/shaders.js +258 -0
  115. package/src/runtime/ink-field/sim.js +582 -0
  116. package/src/runtime/ink-field.d.ts +39 -0
  117. package/src/runtime/ink-field.js +311 -0
  118. package/src/runtime/ink.d.ts +31 -0
  119. package/src/runtime/ink.js +109 -0
  120. package/src/runtime/instancing.d.ts +12 -0
  121. package/src/runtime/instancing.js +37 -0
  122. package/src/runtime/iso-camera.d.ts +35 -0
  123. package/src/runtime/iso-camera.js +85 -0
  124. package/src/runtime/iso-city/figures.d.ts +30 -0
  125. package/src/runtime/iso-city/figures.js +136 -0
  126. package/src/runtime/iso-city/look.d.ts +34 -0
  127. package/src/runtime/iso-city/look.js +105 -0
  128. package/src/runtime/iso-city/plan.d.ts +59 -0
  129. package/src/runtime/iso-city/plan.js +463 -0
  130. package/src/runtime/iso-city/roads.d.ts +64 -0
  131. package/src/runtime/iso-city/roads.js +320 -0
  132. package/src/runtime/iso-city/scene.d.ts +27 -0
  133. package/src/runtime/iso-city/scene.js +432 -0
  134. package/src/runtime/iso-city/shaders.d.ts +6 -0
  135. package/src/runtime/iso-city/shaders.js +233 -0
  136. package/src/runtime/iso-city/shadows.d.ts +13 -0
  137. package/src/runtime/iso-city/shadows.js +148 -0
  138. package/src/runtime/iso-city/traffic.d.ts +80 -0
  139. package/src/runtime/iso-city/traffic.js +457 -0
  140. package/src/runtime/iso-city.d.ts +37 -0
  141. package/src/runtime/iso-city.js +458 -0
  142. package/src/runtime/lens-map.d.ts +11 -0
  143. package/src/runtime/lens-map.js +146 -0
  144. package/src/runtime/light-field.d.ts +29 -0
  145. package/src/runtime/light-field.js +292 -0
  146. package/src/runtime/liquid-glass.d.ts +48 -0
  147. package/src/runtime/liquid-glass.js +423 -0
  148. package/src/runtime/liquid-metal/beads.js +217 -0
  149. package/src/runtime/liquid-metal/field.js +88 -0
  150. package/src/runtime/liquid-metal/look.js +64 -0
  151. package/src/runtime/liquid-metal/shaders.js +255 -0
  152. package/src/runtime/liquid-metal/wave.js +53 -0
  153. package/src/runtime/liquid-metal.d.ts +46 -0
  154. package/src/runtime/liquid-metal.js +366 -0
  155. package/src/runtime/loop.d.ts +7 -0
  156. package/src/runtime/loop.js +112 -0
  157. package/src/runtime/magnetic.d.ts +9 -0
  158. package/src/runtime/magnetic.js +46 -0
  159. package/src/runtime/marquee.d.ts +2 -0
  160. package/src/runtime/marquee.js +27 -0
  161. package/src/runtime/mesh.d.ts +30 -0
  162. package/src/runtime/mesh.js +217 -0
  163. package/src/runtime/mosaic-reveal.d.ts +34 -0
  164. package/src/runtime/mosaic-reveal.js +504 -0
  165. package/src/runtime/motion.d.ts +2 -0
  166. package/src/runtime/motion.js +21 -0
  167. package/src/runtime/mount.d.ts +13 -0
  168. package/src/runtime/mount.js +120 -0
  169. package/src/runtime/nebula-logo.d.ts +31 -0
  170. package/src/runtime/nebula-logo.js +282 -0
  171. package/src/runtime/neon-swarm.d.ts +31 -0
  172. package/src/runtime/neon-swarm.js +258 -0
  173. package/src/runtime/ocean/presets.d.ts +54 -0
  174. package/src/runtime/ocean/presets.js +184 -0
  175. package/src/runtime/ocean/shader.d.ts +14 -0
  176. package/src/runtime/ocean/shader.js +389 -0
  177. package/src/runtime/ocean/view.d.ts +24 -0
  178. package/src/runtime/ocean/view.js +98 -0
  179. package/src/runtime/ocean/waves.d.ts +29 -0
  180. package/src/runtime/ocean/waves.js +119 -0
  181. package/src/runtime/ocean.d.ts +31 -0
  182. package/src/runtime/ocean.js +173 -0
  183. package/src/runtime/palettes.d.ts +37 -0
  184. package/src/runtime/palettes.js +75 -0
  185. package/src/runtime/paper-look.d.ts +42 -0
  186. package/src/runtime/paper-look.js +91 -0
  187. package/src/runtime/paper-looks.d.ts +17 -0
  188. package/src/runtime/paper-looks.js +21 -0
  189. package/src/runtime/paper.d.ts +37 -0
  190. package/src/runtime/paper.js +303 -0
  191. package/src/runtime/particle-logo.d.ts +31 -0
  192. package/src/runtime/particle-logo.js +196 -0
  193. package/src/runtime/ping-pong.d.ts +43 -0
  194. package/src/runtime/ping-pong.js +175 -0
  195. package/src/runtime/pixel-glitch.d.ts +17 -0
  196. package/src/runtime/pixel-glitch.js +287 -0
  197. package/src/runtime/point-cloud.d.ts +33 -0
  198. package/src/runtime/point-cloud.js +287 -0
  199. package/src/runtime/pointer.d.ts +27 -0
  200. package/src/runtime/pointer.js +128 -0
  201. package/src/runtime/points.d.ts +25 -0
  202. package/src/runtime/points.js +130 -0
  203. package/src/runtime/pools.d.ts +2 -0
  204. package/src/runtime/pools.js +25 -0
  205. package/src/runtime/product-stack.d.ts +24 -0
  206. package/src/runtime/product-stack.js +210 -0
  207. package/src/runtime/radiant-glass.d.ts +29 -0
  208. package/src/runtime/radiant-glass.js +282 -0
  209. package/src/runtime/rain-on-glass/backdrop.d.ts +22 -0
  210. package/src/runtime/rain-on-glass/backdrop.js +185 -0
  211. package/src/runtime/rain-on-glass/shader.d.ts +2 -0
  212. package/src/runtime/rain-on-glass/shader.js +168 -0
  213. package/src/runtime/rain-on-glass/wipe.d.ts +16 -0
  214. package/src/runtime/rain-on-glass/wipe.js +65 -0
  215. package/src/runtime/rain-on-glass.d.ts +27 -0
  216. package/src/runtime/rain-on-glass.js +210 -0
  217. package/src/runtime/ramp.d.ts +2 -0
  218. package/src/runtime/ramp.js +30 -0
  219. package/src/runtime/random.d.ts +2 -0
  220. package/src/runtime/random.js +22 -0
  221. package/src/runtime/scroll-reveal.d.ts +22 -0
  222. package/src/runtime/scroll-reveal.js +73 -0
  223. package/src/runtime/shader-background.d.ts +42 -0
  224. package/src/runtime/shader-background.js +261 -0
  225. package/src/runtime/shader-backgrounds/band-lens.js +72 -0
  226. package/src/runtime/shader-backgrounds/common.js +53 -0
  227. package/src/runtime/shader-backgrounds/grain-gradient.js +87 -0
  228. package/src/runtime/shader-backgrounds/grid.js +33 -0
  229. package/src/runtime/shader-backgrounds/mesh-gradient.js +74 -0
  230. package/src/runtime/shader-backgrounds/silk.js +57 -0
  231. package/src/runtime/shader-backgrounds/waves.js +31 -0
  232. package/src/runtime/shape.d.ts +42 -0
  233. package/src/runtime/shape.js +313 -0
  234. package/src/runtime/silk-ribbon.d.ts +23 -0
  235. package/src/runtime/silk-ribbon.js +206 -0
  236. package/src/runtime/slideshow.d.ts +27 -0
  237. package/src/runtime/slideshow.js +234 -0
  238. package/src/runtime/spotlight.d.ts +9 -0
  239. package/src/runtime/spotlight.js +97 -0
  240. package/src/runtime/stack-poses.d.ts +53 -0
  241. package/src/runtime/stack-poses.js +273 -0
  242. package/src/runtime/stage.d.ts +47 -0
  243. package/src/runtime/stage.js +187 -0
  244. package/src/runtime/swarm.d.ts +49 -0
  245. package/src/runtime/swarm.js +199 -0
  246. package/src/runtime/text-motion.d.ts +41 -0
  247. package/src/runtime/text-motion.js +165 -0
  248. package/src/runtime/text.d.ts +11 -0
  249. package/src/runtime/text.js +90 -0
  250. package/src/runtime/tilt.d.ts +19 -0
  251. package/src/runtime/tilt.js +116 -0
  252. package/src/runtime/topography.d.ts +71 -0
  253. package/src/runtime/topography.js +650 -0
  254. package/src/runtime/trackers.d.ts +21 -0
  255. package/src/runtime/trackers.js +76 -0
  256. package/src/runtime/variable-type.d.ts +43 -0
  257. package/src/runtime/variable-type.js +358 -0
  258. package/src/runtime/voxel-logo.d.ts +31 -0
  259. package/src/runtime/voxel-logo.js +237 -0
  260. package/src/runtime/waves.d.ts +70 -0
  261. package/src/runtime/waves.js +799 -0
  262. package/src/runtime/world-labels.d.ts +29 -0
  263. package/src/runtime/world-labels.js +59 -0
  264. package/src/runtime/world-land.d.ts +8 -0
  265. package/src/runtime/world-land.js +105 -0
  266. package/src/runtime/world-map.d.ts +69 -0
  267. package/src/runtime/world-map.js +308 -0
  268. package/src/runtime/world-plan.d.ts +101 -0
  269. package/src/runtime/world-plan.js +333 -0
  270. package/src/runtime/world-routes.d.ts +75 -0
  271. package/src/runtime/world-routes.js +673 -0
  272. package/src/styles/border-sweep.css +82 -0
  273. package/src/styles/glass.css +104 -0
  274. package/src/styles/motion.css +218 -0
  275. package/src/styles/reveal.css +51 -0
  276. package/src/vendor/paper/LICENSE +201 -0
  277. package/src/vendor/paper/NOTICE +5 -0
  278. package/src/vendor/paper/README.md +8 -0
  279. package/src/vendor/paper/get-shader-color-from-string.js +100 -0
  280. package/src/vendor/paper/get-shader-noise-texture.js +17 -0
  281. package/src/vendor/paper/presets.js +3678 -0
  282. package/src/vendor/paper/shader-sizing.js +37 -0
  283. package/src/vendor/paper/shader-utils.js +130 -0
  284. package/src/vendor/paper/shaders/color-panels.js +223 -0
  285. package/src/vendor/paper/shaders/dithering.js +270 -0
  286. package/src/vendor/paper/shaders/dot-grid.js +109 -0
  287. package/src/vendor/paper/shaders/dot-orbit.js +122 -0
  288. package/src/vendor/paper/shaders/fluted-glass.js +360 -0
  289. package/src/vendor/paper/shaders/gem-smoke.js +572 -0
  290. package/src/vendor/paper/shaders/god-rays.js +132 -0
  291. package/src/vendor/paper/shaders/grain-gradient.js +300 -0
  292. package/src/vendor/paper/shaders/halftone-cmyk.js +294 -0
  293. package/src/vendor/paper/shaders/halftone-dots.js +320 -0
  294. package/src/vendor/paper/shaders/heatmap.js +383 -0
  295. package/src/vendor/paper/shaders/image-dithering.js +198 -0
  296. package/src/vendor/paper/shaders/lens-distortion.js +275 -0
  297. package/src/vendor/paper/shaders/liquid-metal.js +632 -0
  298. package/src/vendor/paper/shaders/mesh-gradient.js +130 -0
  299. package/src/vendor/paper/shaders/metaballs.js +110 -0
  300. package/src/vendor/paper/shaders/neuro-noise.js +76 -0
  301. package/src/vendor/paper/shaders/paper-texture.js +526 -0
  302. package/src/vendor/paper/shaders/perlin-noise.js +166 -0
  303. package/src/vendor/paper/shaders/pulsing-border.js +238 -0
  304. package/src/vendor/paper/shaders/simplex-noise.js +91 -0
  305. package/src/vendor/paper/shaders/smoke-ring.js +132 -0
  306. package/src/vendor/paper/shaders/spiral.js +82 -0
  307. package/src/vendor/paper/shaders/static-mesh-gradient.js +130 -0
  308. package/src/vendor/paper/shaders/static-radial-gradient.js +187 -0
  309. package/src/vendor/paper/shaders/swirl.js +103 -0
  310. package/src/vendor/paper/shaders/voronoi.js +138 -0
  311. package/src/vendor/paper/shaders/warp.js +129 -0
  312. package/src/vendor/paper/shaders/water.js +121 -0
  313. package/src/vendor/paper/shaders/waves.js +65 -0
  314. package/src/vendor/paper/vertex-shader.js +159 -0
@@ -0,0 +1,298 @@
1
+ ---
2
+ /**
3
+ * ProductStack: a store's product covers floating in 3D, in a fan, a
4
+ * stack or a carousel arc, with depth of field, soft shadows and a gloss
5
+ * that sweeps across the cover in front. The stack leans towards the
6
+ * pointer; hovered, the covers fan apart and the one under the pointer
7
+ * lifts forward and comes into focus; left alone, they drift. See
8
+ * src/runtime/product-stack.js.
9
+ *
10
+ * The covers are real links and images moved by CSS transforms (no
11
+ * canvas): crisp at any size, focusable from the keyboard (focus lifts a
12
+ * cover as hover does), and clicked like any link. Give them as `items`,
13
+ * or as children: each a link (or another element) holding one image.
14
+ * It fills its container's width, shrinking the covers to fit. Still with
15
+ * reduced motion; no lean or fanning on a touch screen.
16
+ *
17
+ * @example
18
+ * <ProductStack items={[{ src: '/covers/drums.webp', href: '/p/drums', alt: 'Night Drums, a sample pack' }, …]} />
19
+ * <ProductStack layout="arc"><a href="/p/serif"><img src="/covers/serif.webp" alt="Halden Serif" /></a>…</ProductStack>
20
+ */
21
+ import { withStyle } from './style.js';
22
+ import { layoutOf, poseFilter, poseTransform, stackBounds, stackPoses } from '../runtime/stack-poses.js';
23
+
24
+ /** One cover. */
25
+ interface StackItem {
26
+ /** The cover image. */
27
+ src: string;
28
+ /** What it shows, for screen readers: the product's name and kind. */
29
+ alt: string;
30
+ /** The product's page. Without it the cover is not a link. */
31
+ href?: string;
32
+ }
33
+
34
+ interface Props {
35
+ /** The covers. Without them, the children are the covers: each a link (or another element) holding one image. */
36
+ items?: StackItem[];
37
+ /** How the covers are laid out: a hand of cards (`fan`, the middle cover in front), a deck seen at an angle (`stack`, the first in front) or a carousel arc (`arc`). Default `fan`. */
38
+ layout?: 'fan' | 'stack' | 'arc';
39
+ /** How far apart the covers sit, 0–2. Default 1. */
40
+ spread?: number;
41
+ /** How far the stack leans towards the pointer, degrees, 0–30. Default 12. */
42
+ tilt?: number;
43
+ /** How far the covers drift when left alone, 0–1; 0 holds them still. Default 0.5. */
44
+ float?: number;
45
+ /** Depth of field: how much the covers behind dim and soften, 0–1. Default 0.6. */
46
+ depth?: number;
47
+ /** Lean towards the pointer, fan apart on hover and lift the cover under the pointer or in focus. Default true. */
48
+ interactive?: boolean;
49
+ /** The widest a cover gets, a CSS length; covers shrink to fit the container. Default `280px`. */
50
+ size?: string;
51
+ /** A cover's width over its height: 1 square, 0.75 a book. Default 1. */
52
+ ratio?: number;
53
+ /** The covers' corner radius, px, 0–40. Default 10. */
54
+ radius?: number;
55
+ /** The group's name for screen readers. Default `Products`. */
56
+ label?: string;
57
+ class?: string;
58
+ [attribute: string]: unknown;
59
+ }
60
+
61
+ const {
62
+ items,
63
+ layout = 'fan',
64
+ spread = 1,
65
+ tilt = 12,
66
+ float = 0.5,
67
+ depth = 0.6,
68
+ interactive = true,
69
+ size = '280px',
70
+ ratio = 1,
71
+ radius = 10,
72
+ label = 'Products',
73
+ class: className,
74
+ style: given,
75
+ ...attributes
76
+ } = Astro.props;
77
+
78
+ // With items, the resting poses are written here, so the stack stands before any script runs.
79
+ const shape = layoutOf(layout);
80
+ const poses = items ? stackPoses(shape, items.length, { spread }) : [];
81
+ const bounds = items ? stackBounds(shape, items.length, spread, ratio) : null;
82
+ const geometry = bounds ? `--ps-wide: ${bounds.wide}; --ps-tall: ${bounds.tall}` : '';
83
+ ---
84
+
85
+ <div
86
+ class:list={['effect-product-stack', { 'is-still': float === 0 }, className]}
87
+ data-effect-product-stack
88
+ data-effect-config={JSON.stringify({ layout, spread, tilt, depth, interactive, ratio })}
89
+ style={withStyle(`--ps-size: ${size}; --ps-ratio: ${ratio}; --ps-float: ${float}; --ps-radius: ${radius}px; ${geometry}`, given)}
90
+ {...attributes}
91
+ >
92
+ <div class="ps-scene" role="group" aria-label={label}>
93
+ <span class="ps-ground" aria-hidden="true"></span>
94
+ <div class="ps-stage">
95
+ {
96
+ items
97
+ ? items.map((item, i) => {
98
+ const style = `--ps-i: ${i}; transform: ${poseTransform(poses[i])}; filter: ${poseFilter(poses[i], depth)}`;
99
+ const image = <img src={item.src} alt={item.alt} decoding="async" draggable="false" />;
100
+ return item.href ? (
101
+ <a href={item.href} style={style}>
102
+ {image}
103
+ </a>
104
+ ) : (
105
+ <div style={style}>{image}</div>
106
+ );
107
+ })
108
+ : <slot />
109
+ }
110
+ </div>
111
+ </div>
112
+ </div>
113
+
114
+ <script>
115
+ import { mount } from '../runtime/mount.js';
116
+ import { productStack } from '../runtime/product-stack.js';
117
+
118
+ mount('[data-effect-product-stack]', productStack);
119
+ </script>
120
+
121
+ <style>
122
+ .effect-product-stack {
123
+ --ps-wide: 2.6;
124
+ --ps-tall: 1.6;
125
+ --ps-shadow: rgb(0 0 0 / 0.5);
126
+ container-type: inline-size;
127
+ display: grid;
128
+ place-items: center;
129
+ width: 100%;
130
+ }
131
+ /* The box the stack needs at its widest, so nothing it does leaves it. */
132
+ .ps-scene {
133
+ --ps-w: min(var(--ps-size), calc(100cqi / var(--ps-wide)));
134
+ position: relative;
135
+ display: grid;
136
+ place-items: center;
137
+ width: calc(var(--ps-w) * var(--ps-wide));
138
+ height: calc(var(--ps-w) * var(--ps-tall));
139
+ perspective: calc(var(--ps-w) * 5);
140
+ }
141
+ .ps-stage {
142
+ position: relative;
143
+ width: var(--ps-w);
144
+ aspect-ratio: var(--ps-ratio);
145
+ transform-style: preserve-3d;
146
+ transform: rotateX(var(--ps-lean-x, 0deg)) rotateY(var(--ps-lean-y, 0deg));
147
+ /* Its own box sits at the front of the 3D scene: it must not catch the pointer over the covers behind it. */
148
+ pointer-events: none;
149
+ transition: transform 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
150
+ animation: ps-sway 13s ease-in-out infinite alternate;
151
+ }
152
+ /* A soft shadow on the ground under the stack, breathing with the float. */
153
+ .ps-ground {
154
+ position: absolute;
155
+ left: 50%;
156
+ top: calc(50% + var(--ps-w) / var(--ps-ratio) * 0.56);
157
+ width: calc(var(--ps-w) * min(var(--ps-wide) * 0.72, 2.4));
158
+ height: calc(var(--ps-w) * 0.2);
159
+ translate: -50% -50%;
160
+ border-radius: 50%;
161
+ background: radial-gradient(closest-side, var(--ps-shadow), transparent);
162
+ pointer-events: none;
163
+ animation: ps-ground 7s ease-in-out infinite alternate;
164
+ }
165
+
166
+ /* The covers: the items, or the children given. */
167
+ .ps-stage > :global(*) {
168
+ position: absolute;
169
+ inset: 0;
170
+ display: block;
171
+ border-radius: var(--ps-radius);
172
+ overflow: hidden;
173
+ pointer-events: auto;
174
+ color: inherit;
175
+ background: #111;
176
+ box-shadow:
177
+ 0 calc(var(--ps-w) * 0.09) calc(var(--ps-w) * 0.16) calc(var(--ps-w) * -0.05) var(--ps-shadow),
178
+ 0 calc(var(--ps-w) * 0.015) calc(var(--ps-w) * 0.03) rgb(0 0 0 / 0.22);
179
+ outline: 1px solid rgb(255 255 255 / 0.12);
180
+ outline-offset: -1px;
181
+ backface-visibility: hidden;
182
+ -webkit-tap-highlight-color: transparent;
183
+ animation: ps-float calc(3.4s + var(--ps-i, 0) * 0.45s) ease-in-out calc(var(--ps-i, 0) * -1.3s) infinite alternate;
184
+ }
185
+ .effect-product-stack:global(.is-ready) .ps-stage > :global(*) {
186
+ transition:
187
+ transform 0.75s cubic-bezier(0.2, 0.85, 0.25, 1),
188
+ filter 0.6s ease;
189
+ }
190
+ .ps-stage > :global(*:focus-visible) {
191
+ outline: 2px solid currentColor;
192
+ outline-offset: 4px;
193
+ }
194
+ .ps-stage :global(img) {
195
+ display: block;
196
+ width: 100%;
197
+ height: 100%;
198
+ object-fit: cover;
199
+ user-select: none;
200
+ -webkit-user-drag: none;
201
+ }
202
+ /* The gloss: a laminate's soft highlight and a hairline edge, moving against the lean as a light would. */
203
+ .ps-stage > :global(*)::before {
204
+ content: '';
205
+ position: absolute;
206
+ inset: -20%;
207
+ z-index: 1;
208
+ pointer-events: none;
209
+ background:
210
+ radial-gradient(70% 55% at 30% 22%, rgb(255 255 255 / 0.2), transparent 70%),
211
+ linear-gradient(180deg, rgb(255 255 255 / 0.08), transparent 40%, rgb(0 0 0 / 0.14));
212
+ translate: calc(var(--ps-glint-x, 0) * 8%) calc(var(--ps-glint-y, 0) * 8%);
213
+ transition: translate 1.1s cubic-bezier(0.2, 0.7, 0.2, 1);
214
+ }
215
+ /* The sheen: a band of light that sweeps across the cover in front now and then, and once over a cover as it lifts. */
216
+ .ps-stage > :global(*)::after {
217
+ content: '';
218
+ position: absolute;
219
+ inset: 0;
220
+ z-index: 2;
221
+ pointer-events: none;
222
+ background: linear-gradient(105deg, transparent 28%, rgb(255 255 255 / 0.06) 40%, rgb(255 255 255 / 0.36) 50%, rgb(255 255 255 / 0.06) 60%, transparent 72%);
223
+ translate: -100% 0;
224
+ }
225
+ .ps-stage > :global(.is-front)::after {
226
+ animation: ps-sheen 8s ease-in-out 1.5s infinite;
227
+ }
228
+ .ps-stage > :global(.is-lifted)::after {
229
+ animation: ps-sheen-once 1.2s cubic-bezier(0.3, 0.6, 0.2, 1) both;
230
+ }
231
+
232
+ .effect-product-stack.is-still .ps-stage,
233
+ .effect-product-stack.is-still .ps-ground,
234
+ .effect-product-stack.is-still .ps-stage > :global(*) {
235
+ animation: none;
236
+ }
237
+ .effect-product-stack:global(.is-asleep) *,
238
+ .effect-product-stack:global(.is-asleep) :global(*)::after {
239
+ animation-play-state: paused;
240
+ }
241
+ @media (prefers-reduced-motion: reduce) {
242
+ .ps-stage,
243
+ .ps-ground,
244
+ .ps-stage > :global(*),
245
+ .ps-stage > :global(*)::after {
246
+ animation: none !important;
247
+ }
248
+ .effect-product-stack:global(.is-ready) .ps-stage > :global(*),
249
+ .ps-stage > :global(*)::before {
250
+ transition: none;
251
+ }
252
+ }
253
+
254
+ @keyframes ps-float {
255
+ from {
256
+ translate: 0 calc(var(--ps-w) * var(--ps-float) * 0.03) 0;
257
+ }
258
+ to {
259
+ translate: 0 calc(var(--ps-w) * var(--ps-float) * -0.03) 0;
260
+ }
261
+ }
262
+ @keyframes ps-sway {
263
+ from {
264
+ rotate: 0.25 1 0 calc(var(--ps-float) * -7deg);
265
+ }
266
+ to {
267
+ rotate: -0.25 1 0 calc(var(--ps-float) * 7deg);
268
+ }
269
+ }
270
+ @keyframes ps-ground {
271
+ from {
272
+ scale: 1;
273
+ opacity: 1;
274
+ }
275
+ to {
276
+ scale: calc(1 - var(--ps-float) * 0.12);
277
+ opacity: calc(1 - var(--ps-float) * 0.3);
278
+ }
279
+ }
280
+ /* The band starts off the left edge and sweeps off the right; then it waits. */
281
+ @keyframes ps-sheen {
282
+ 0% {
283
+ translate: -100% 0;
284
+ }
285
+ 22%,
286
+ 100% {
287
+ translate: 100% 0;
288
+ }
289
+ }
290
+ @keyframes ps-sheen-once {
291
+ from {
292
+ translate: -100% 0;
293
+ }
294
+ to {
295
+ translate: 100% 0;
296
+ }
297
+ }
298
+ </style>
@@ -0,0 +1,189 @@
1
+ ---
2
+ /**
3
+ * PulseMark: a small animated mark for a logo, a loading state or a
4
+ * "live" badge, drawn in SVG and moved by CSS alone (no script).
5
+ *
6
+ * - `matrix`: a grid of LED blocks, each blinking on its own rhythm.
7
+ * - `rings`: two dashed rings turning against each other round a beating dot.
8
+ * - `sonar`: rings that swell out from a centre, each a beat behind the last.
9
+ *
10
+ * It takes the text colour unless given one, and holds still with reduced
11
+ * motion. From the Graphic Foundry, Loopcuts and Producer Space sites.
12
+ *
13
+ * @example
14
+ * <PulseMark variant="sonar" size={40} color="#00ff88" glow />
15
+ */
16
+
17
+ interface Props {
18
+ /** The mark. Default `matrix`. */
19
+ variant?: 'matrix' | 'rings' | 'sonar';
20
+ /** Its width and height, px or any CSS length. Default `1em`. */
21
+ size?: number | string;
22
+ /** Its colour. Default the text colour. */
23
+ color?: string;
24
+ /** A soft glow round it. Default false. */
25
+ glow?: boolean;
26
+ /** Blocks along each side of the matrix. Default 6. */
27
+ cells?: number;
28
+ /** Speed, as a multiple. Default 1. */
29
+ speed?: number;
30
+ /** Its accessible name; without one it is decorative. */
31
+ label?: string;
32
+ class?: string;
33
+ }
34
+
35
+ const { variant = 'matrix', size = '1em', color, glow = false, cells = 6, speed = 1, label, class: className } = Astro.props;
36
+
37
+ /** Each LED's rhythm, from a fixed shuffle so a page renders the same every time. */
38
+ const rhythms = Array.from({ length: cells * cells }, (_, i) => ((i * 7 + Math.floor(i / cells) * 3) % 5) + 1);
39
+ const pitch = 120 / cells;
40
+ const style = [
41
+ `--mark-size: ${typeof size === 'number' ? `${size}px` : size}`,
42
+ color && `--mark-color: ${color}`,
43
+ speed !== 1 && `--mark-speed: ${1 / speed}`,
44
+ ]
45
+ .filter(Boolean)
46
+ .join('; ');
47
+ ---
48
+
49
+ <span
50
+ class:list={['effect-pulse-mark', `is-${variant}`, { 'has-glow': glow }, className]}
51
+ style={style}
52
+ role={label ? 'img' : undefined}
53
+ aria-label={label}
54
+ aria-hidden={label ? undefined : 'true'}
55
+ >
56
+ {
57
+ variant === 'matrix' && (
58
+ <svg class="layer" viewBox="0 0 120 120">
59
+ {rhythms.map((rhythm, i) => (
60
+ <rect
61
+ class={`led r${rhythm}`}
62
+ x={(i % cells) * pitch + pitch * 0.1}
63
+ y={Math.floor(i / cells) * pitch + pitch * 0.1}
64
+ width={pitch * 0.8}
65
+ height={pitch * 0.8}
66
+ rx={pitch * 0.12}
67
+ />
68
+ ))}
69
+ </svg>
70
+ )
71
+ }
72
+ {
73
+ variant === 'rings' && (
74
+ <>
75
+ <svg class="layer outer" viewBox="0 0 120 120"><circle cx="60" cy="60" r="38" fill="none" stroke-width="4" stroke-dasharray="45 14.69" /></svg>
76
+ <svg class="layer inner" viewBox="0 0 120 120"><circle cx="60" cy="60" r="25" fill="none" stroke-width="4" stroke-dasharray="40 12.36" /></svg>
77
+ <svg class="layer core" viewBox="0 0 120 120"><circle cx="60" cy="60" r="5" stroke="none" /></svg>
78
+ </>
79
+ )
80
+ }
81
+ {
82
+ variant === 'sonar' &&
83
+ [
84
+ [8, 3],
85
+ [20, 2.5],
86
+ [34, 2],
87
+ [50, 1.5],
88
+ ].map(([r, width], i) => (
89
+ <svg class={`layer wave w${i}`} viewBox="0 0 120 120"><circle cx="60" cy="60" r={r} fill="none" stroke-width={width} /></svg>
90
+ ))
91
+ }
92
+ </span>
93
+
94
+ <style>
95
+ /* Each moving part is a layer of its own, an SVG turned or scaled as a
96
+ whole: the browser does that on the GPU. Moving shapes inside one
97
+ SVG would mean laying the page out again every frame. */
98
+ .effect-pulse-mark {
99
+ --k: var(--mark-speed, 1);
100
+ display: inline-grid;
101
+ width: var(--mark-size);
102
+ height: var(--mark-size);
103
+ color: var(--mark-color, currentColor);
104
+ fill: currentColor;
105
+ stroke: currentColor;
106
+ vertical-align: middle;
107
+ }
108
+ .layer {
109
+ grid-area: 1 / 1;
110
+ width: 100%;
111
+ height: 100%;
112
+ overflow: visible;
113
+ }
114
+ .has-glow {
115
+ filter: drop-shadow(0 0 calc(var(--mark-size) * 0.06) currentColor);
116
+ }
117
+
118
+ .led {
119
+ stroke: none;
120
+ opacity: 0.2;
121
+ animation: effect-mark-blink calc(var(--k) * var(--d)) ease-in-out infinite;
122
+ }
123
+ .r1 { --d: 2s; }
124
+ .r2 { --d: 1.5s; animation-delay: -0.4s; }
125
+ .r3 { --d: 2.5s; animation-delay: -1.1s; }
126
+ .r4 { --d: 1.8s; animation-delay: -0.7s; }
127
+ .r5 { --d: 2.2s; animation-delay: -1.5s; }
128
+
129
+ .outer {
130
+ animation: effect-mark-turn calc(var(--k) * 20s) linear infinite;
131
+ }
132
+ .inner {
133
+ animation: effect-mark-turn calc(var(--k) * 15s) linear infinite reverse;
134
+ }
135
+ .core {
136
+ animation: effect-mark-beat calc(var(--k) * 2s) ease-in-out infinite;
137
+ }
138
+
139
+ .wave {
140
+ animation: effect-mark-swell calc(var(--k) * 2s) ease-in-out infinite;
141
+ }
142
+ .w0 { --o: 1; --s: 1.05; }
143
+ .w1 { --o: 0.7; --s: 1.1; animation-delay: calc(var(--k) * 0.1s); }
144
+ .w2 { --o: 0.4; --s: 1.15; animation-delay: calc(var(--k) * 0.2s); }
145
+ .w3 { --o: 0.2; --s: 1.2; animation-delay: calc(var(--k) * 0.3s); }
146
+
147
+ @keyframes effect-mark-blink {
148
+ 50% {
149
+ opacity: 1;
150
+ }
151
+ }
152
+ @keyframes effect-mark-turn {
153
+ to {
154
+ rotate: 360deg;
155
+ }
156
+ }
157
+ @keyframes effect-mark-beat {
158
+ 50% {
159
+ opacity: 0.3;
160
+ }
161
+ }
162
+ @keyframes effect-mark-swell {
163
+ 0%,
164
+ 100% {
165
+ opacity: var(--o);
166
+ scale: 1;
167
+ }
168
+ 50% {
169
+ opacity: calc(var(--o) + 0.2);
170
+ scale: var(--s);
171
+ }
172
+ }
173
+
174
+ @media (prefers-reduced-motion: reduce) {
175
+ .led,
176
+ .outer,
177
+ .inner,
178
+ .core,
179
+ .wave {
180
+ animation: none;
181
+ }
182
+ .led:nth-child(3n) {
183
+ opacity: 0.9;
184
+ }
185
+ .wave {
186
+ opacity: var(--o);
187
+ }
188
+ }
189
+ </style>
@@ -0,0 +1,38 @@
1
+ ---
2
+ /**
3
+ * RadiantGlass: a cluster of frosted glass tiles on a dark ground, lit
4
+ * from inside by big soft lights drifting behind them, which shift with
5
+ * the pointer. Each tile has a thin two-tone rim and a soft halo. See
6
+ * src/runtime/radiant-glass.js.
7
+ *
8
+ * Opaque: it is the whole background of what it fills (its nearest
9
+ * positioned ancestor, or the viewport with `fixed`). Without WebGL the
10
+ * `background` colour shows. The cluster takes one side (`side`); put the
11
+ * copy on the other.
12
+ *
13
+ * @example
14
+ * <section class="hero" style="position: relative">
15
+ * <RadiantGlass side="left" />
16
+ * <h1 style="text-align: right">…</h1>
17
+ * </section>
18
+ */
19
+ import EffectCanvas from './EffectCanvas.astro';
20
+ import type { RadiantGlassConfig } from '../runtime/radiant-glass.js';
21
+
22
+ interface Props extends RadiantGlassConfig {
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="radiant-glass" config={config} fixed={fixed} class={className} behind background={config.background ?? '#060818'} />
32
+
33
+ <script>
34
+ import { mount } from '../runtime/mount.js';
35
+ import { radiantGlass } from '../runtime/radiant-glass.js';
36
+
37
+ mount('[data-effect-radiant-glass]', radiantGlass);
38
+ </script>
@@ -0,0 +1,71 @@
1
+ ---
2
+ /**
3
+ * RainOnGlass: rain on a window over a photo, like looking out of a café on
4
+ * a wet evening. Beads sit on the glass; larger drops run down it, leaving
5
+ * clear trails that fog over again; each drop holds the photo sharp and
6
+ * upside down, while the rest is soft behind the condensation, its lights
7
+ * opened into bokeh. The pointer wipes a clear patch. See
8
+ * src/runtime/rain-on-glass.js.
9
+ *
10
+ * A real `<img>` sits under the glass, with its `alt`: it is what shows,
11
+ * softened, without WebGL and while the photo loads. Fills its nearest
12
+ * positioned ancestor, or the viewport with `fixed`.
13
+ *
14
+ * @example
15
+ * <section class="hero" style="position: relative">
16
+ * <RainOnGlass src="/photos/street-at-night.jpg" alt="A wet street of neon signs at night" />
17
+ * <h1>Come in out of the rain.</h1>
18
+ * </section>
19
+ */
20
+ import EffectCanvas from './EffectCanvas.astro';
21
+ import type { RainOnGlassConfig } from '../runtime/rain-on-glass.js';
22
+
23
+ interface Props extends RainOnGlassConfig {
24
+ /** What the photo shows, for the `<img>` under the glass. Default empty (decorative). */
25
+ alt?: string;
26
+ /** Fill the viewport, behind the page (position: fixed, z-index -1). Default false. */
27
+ fixed?: boolean;
28
+ class?: string;
29
+ }
30
+
31
+ const { alt = '', fixed = false, class: className, ...config } = Astro.props;
32
+ ---
33
+
34
+ <div class:list={['rain-on-glass', { 'is-fixed': fixed }, className]} style={`--rain-soft: ${4 + (config.blur ?? 0.6) * 18}px`}>
35
+ <img src={config.src} alt={alt} decoding="async" />
36
+ <EffectCanvas name="rain-on-glass" config={config} />
37
+ </div>
38
+
39
+ <style>
40
+ .rain-on-glass {
41
+ position: absolute;
42
+ inset: 0;
43
+ overflow: hidden;
44
+ pointer-events: none;
45
+ }
46
+ .rain-on-glass.is-fixed {
47
+ position: fixed;
48
+ z-index: -1;
49
+ }
50
+ /* The photo, softened as the glass would soften it: what shows without
51
+ WebGL and while the photo loads, hidden once the glass has drawn. */
52
+ img {
53
+ position: absolute;
54
+ inset: 0;
55
+ width: 100%;
56
+ height: 100%;
57
+ object-fit: cover;
58
+ filter: blur(var(--rain-soft)) brightness(0.85);
59
+ transform: scale(1.06);
60
+ }
61
+ .rain-on-glass:has([data-drawn]) img {
62
+ opacity: 0;
63
+ }
64
+ </style>
65
+
66
+ <script>
67
+ import { mount } from '../runtime/mount.js';
68
+ import { rainOnGlass } from '../runtime/rain-on-glass.js';
69
+
70
+ mount('[data-effect-rain-on-glass]', rainOnGlass);
71
+ </script>