snowies 0.2.0 → 0.4.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/README.md CHANGED
@@ -1,65 +1,76 @@
1
1
  # snowies
2
2
 
3
- Paquete navideño **cero dependencias**, escrito en **TypeScript puro** y optimizado para GPU/batería. Funciona en cualquier proyecto web (HTML, Vue, React, Astro, Next.js, Laravel, etc.).
3
+ Zero-dependency, GPU-optimized Christmas effects package for the web written in pure TypeScript. Works with any stack (HTML, React, Vue, Svelte, Astro, Next.js, Laravel, etc.).
4
4
 
5
- ## Características
5
+ Live playground: https://l2ernestoo.github.io/snowies/
6
6
 
7
- - **Nieve en Canvas 2D**: 3 capas de profundidad, sprites pre-renderizados, pausa automática al cambiar de pestaña (`visibilitychange`) y modo `contrasting` para fondos claros.
8
- - **Luces navideñas fijas arriba**: cable SVG, focos con filamento y halo, balanceo suave, iluminación al pasar el mouse y destello al hacer clic (encapsulado en Shadow DOM).
9
- - **Snow Burst en botones**: explosión radial de nieve y cristales SVG al hacer clic en botones.
10
- - **Nieve encima de botones (`buttonSnow`)**: módulo independiente y desactivable con dos estilos orgánicos (`subtle` y `fluffy`) y dos modos: manual por defecto (`data-snowies-snow`) o automático (`mode: 'all'`, respetando `data-snowies-ignore`).
11
- - **Botón flotante ON/OFF discreto y personalizable**: encapsulado en Shadow DOM, modo solo icono por defecto (`variant: 'icon' | 'pill'`), tamaños, temas, icono SVG propio, estilos custom y persistencia en `localStorage`.
12
- - **Presets y programación por fechas**: activa Navidad automáticamente entre fechas (ej. `12-01` a `01-06`).
13
- - **Accesible**: respeta `prefers-reduced-motion: reduce`.
7
+ ## Features
14
8
 
15
- ## Instalación
9
+ - **Canvas 2D Snowfall**: 3 depth layers, pre-rendered sprites, automatic pause on hidden tabs (`visibilitychange`), interactive pointer breeze (`mouseWind`), and automatic light/dark background detection (`contrasting: 'auto'`).
10
+ - **Animated Fixed Top Lights**: SVG wire, filament bulbs with halos, neighbor hover glow, click celebration burst, and 3 animation modes (`twinkle`, `wave`, `steady`) isolated in Shadow DOM.
11
+ - **Button Snow Burst**: Radial snow + SVG crystal burst on button clicks via event delegation.
12
+ - **Button Snow (`buttonSnow`)**: Independent decorative organic snow resting on top of buttons with 2 styles (`subtle` and `fluffy`) and 2 modes (`manual` via `data-snowies-snow` by default, or `all` with `data-snowies-ignore` opt-out).
13
+ - **Discreet & Customizable Floating Toggle**: Shadow DOM button (`variant: 'icon' | 'pill'`, `position`, `size`, `theme`, custom SVG `icon`, custom labels, `style` overrides, and `localStorage` persistence).
14
+ - **Presets & Date Scheduling**: Built-in presets (`classic`, `festive`, `minimal`, `light`, `lights-only`, `snow-only`) and optional active date window (`schedule: { from: '12-01', to: '01-06' }`).
15
+ - **Accessible**: Respects `prefers-reduced-motion: reduce`.
16
+
17
+ ## Install
16
18
 
17
19
  ```bash
18
20
  npm install snowies
19
21
  ```
20
22
 
21
- ## Uso rápido (ESM / TypeScript)
23
+ ## Quick Start (ESM / TypeScript)
22
24
 
23
25
  ```ts
24
26
  import { createSnowies } from 'snowies';
25
27
 
26
28
  const snowies = createSnowies({
27
- preset: 'classic', // 'classic' | 'minimal' | 'festive' | 'light' | 'lights-only' | 'snow-only'
28
- schedule: { from: '12-01', to: '01-06' },
29
+ preset: 'classic',
30
+ snow: { contrasting: 'auto', mouseWind: true },
31
+ lights: { animation: 'wave' },
32
+ buttonSnow: { enabled: true, mode: 'manual', style: 'subtle' },
29
33
  toggleButton: {
30
- variant: 'icon', // 'icon' | 'pill'
31
- size: 'sm', // 'sm' | 'md'
32
- theme: 'minimal', // 'minimal' | 'dark' | 'light' | 'festive'
34
+ position: 'bottom-right',
35
+ variant: 'icon',
36
+ // Override any built-in text in your own language:
37
+ textOn: 'Holiday',
38
+ textOff: 'Paused',
39
+ labelOn: 'Disable Christmas effects',
40
+ labelOff: 'Enable Christmas effects',
33
41
  },
42
+ schedule: { from: '12-01', to: '01-06' },
34
43
  });
35
44
 
36
- // Control programático
45
+ // Programmatic control
37
46
  snowies.toggle();
38
- snowies.update({ snow: { density: 'heavy', contrasting: true } });
47
+ snowies.update({ snow: { density: 'heavy' } });
39
48
  snowies.destroy();
40
49
  ```
41
50
 
42
- ## Uso directo por CDN
51
+ ## Direct CDN Usage
43
52
 
44
53
  ```html
45
54
  <script
46
55
  src="https://unpkg.com/snowies"
47
56
  data-preset="classic"
57
+ data-lights-animation="wave"
58
+ data-toggle-position="bottom-left"
48
59
  data-from="12-01"
49
60
  data-to="01-06"
50
61
  defer
51
62
  ></script>
52
63
  ```
53
64
 
54
- ## Desarrollo local
65
+ ## Local Development
55
66
 
56
67
  ```bash
57
68
  npm install
58
- npm run dev # Abre el playground interactivo
59
- npm run test # Ejecuta los tests unitarios
60
- npm run build # Genera dist/ (ESM, CJS, .d.ts y CDN global)
69
+ npm run dev # Start interactive playground
70
+ npm run test # Run unit tests
71
+ npm run build # Build dist/ (ESM, CJS, .d.ts, and CDN global)
61
72
  ```
62
73
 
63
- ## Licencia
74
+ ## License
64
75
 
65
76
  MIT
package/dist/auto.cjs CHANGED
@@ -313,7 +313,10 @@ function createLights(options) {
313
313
  const colors = resolvePalette(options.palette);
314
314
  const bulbCount = Math.max(6, Math.min(64, Math.round(options.bulbs)));
315
315
  const mobileCutoff = Math.max(10, Math.round(bulbCount * 0.45));
316
- const bg = BACKDROP_STYLES[options.backdrop] ?? BACKDROP_STYLES.pine;
316
+ const bg = BACKDROP_STYLES[options.backdrop] ?? BACKDROP_STYLES.transparent;
317
+ const animMode = options.animation ?? "twinkle";
318
+ const glassAnimCss = animMode === "steady" ? "opacity: 0.96;" : animMode === "wave" ? "animation: glass-wave 2.4s ease-in-out var(--wave-delay) infinite;" : "animation: glass-glow var(--bulb-duration) ease-in-out var(--bulb-delay) infinite alternate;";
319
+ const haloAnimCss = animMode === "steady" ? "opacity: 0.28;" : animMode === "wave" ? "animation: halo-wave 2.4s ease-in-out var(--wave-delay) infinite;" : "animation: halo-glow var(--bulb-duration) ease-in-out var(--bulb-delay) infinite alternate;";
317
320
  const style = document.createElement("style");
318
321
  style.textContent = `
319
322
  :host { display: block; line-height: 0; }
@@ -386,7 +389,7 @@ function createLights(options) {
386
389
  radial-gradient(ellipse at 50% 35%, var(--bulb-core) 5%, var(--bulb-color) 80%);
387
390
  box-shadow: 0 0 5px var(--bulb-color), 0 0 12px var(--bulb-color);
388
391
  will-change: opacity, transform;
389
- animation: glass-glow var(--bulb-duration) ease-in-out var(--bulb-delay) infinite alternate;
392
+ ${glassAnimCss}
390
393
  transition: transform 0.25s ease, opacity 0.25s ease;
391
394
  }
392
395
  .filament {
@@ -408,7 +411,7 @@ function createLights(options) {
408
411
  opacity: 0.2;
409
412
  pointer-events: none;
410
413
  will-change: opacity;
411
- animation: halo-glow var(--bulb-duration) ease-in-out var(--bulb-delay) infinite alternate;
414
+ ${haloAnimCss}
412
415
  transition: opacity 0.25s ease;
413
416
  }
414
417
  .lamp.is-near .glass,
@@ -434,6 +437,14 @@ function createLights(options) {
434
437
  from { opacity: 0.12; }
435
438
  to { opacity: 0.34; }
436
439
  }
440
+ @keyframes glass-wave {
441
+ 0%, 58%, 100% { opacity: 0.58; transform: scale(0.97); }
442
+ 22% { opacity: 1; transform: scale(1.1); }
443
+ }
444
+ @keyframes halo-wave {
445
+ 0%, 58%, 100% { opacity: 0.08; }
446
+ 22% { opacity: 0.52; }
447
+ }
437
448
  @media (max-width: 640px) {
438
449
  .lamp:nth-of-type(n + ${mobileCutoff + 1}) { display: none; }
439
450
  }
@@ -443,9 +454,10 @@ function createLights(options) {
443
454
  `;
444
455
  const strip = document.createElement(options.interactive ? "button" : "div");
445
456
  strip.className = "strip";
457
+ strip.setAttribute("data-animation", animMode);
446
458
  if (options.interactive) {
447
459
  strip.setAttribute("type", "button");
448
- strip.setAttribute("aria-label", "Hacer brillar las luces navide\xF1as");
460
+ strip.setAttribute("aria-label", options.ariaLabel || "Illuminate Christmas lights");
449
461
  } else {
450
462
  strip.setAttribute("aria-hidden", "true");
451
463
  }
@@ -464,6 +476,7 @@ function createLights(options) {
464
476
  lamp.style.setProperty("--bulb-color", c.color);
465
477
  lamp.style.setProperty("--bulb-core", c.core);
466
478
  lamp.style.setProperty("--bulb-delay", `${i * -0.43}s`);
479
+ lamp.style.setProperty("--wave-delay", `${(i * -0.1).toFixed(2)}s`);
467
480
  lamp.style.setProperty("--bulb-duration", `${3.4 + i % 5 * 0.35}s`);
468
481
  lamp.style.setProperty("--bulb-cord", `${4 + i % 3 * 2}px`);
469
482
  lamp.style.setProperty("--bulb-tilt", `${i % 2 ? 5 : -5}deg`);
@@ -546,6 +559,37 @@ function createPrng(initialSeed = 202611) {
546
559
  return seed / 4294967296;
547
560
  };
548
561
  }
562
+ function parseRgbLuminance(color) {
563
+ const match = /rgba?\(\s*(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)[,\s]+(\d+(?:\.\d+)?)(?:\s*[,/]\s*(\d*(?:\.\d+)?))?\s*\)/i.exec(
564
+ color
565
+ );
566
+ if (!match) return null;
567
+ const alpha = match[4] !== void 0 && match[4] !== "" ? Number(match[4]) : 1;
568
+ if (Number.isNaN(alpha) || alpha < 0.1) return null;
569
+ const r = Number(match[1]);
570
+ const g = Number(match[2]);
571
+ const b = Number(match[3]);
572
+ return (0.299 * r + 0.587 * g + 0.114 * b) / 255;
573
+ }
574
+ function detectLightBackground() {
575
+ if (typeof window === "undefined" || typeof document === "undefined") return false;
576
+ const candidates = [document.body, document.documentElement];
577
+ for (const el of candidates) {
578
+ if (!el) continue;
579
+ const bg = window.getComputedStyle(el).backgroundColor;
580
+ const lum = parseRgbLuminance(bg);
581
+ if (lum !== null) {
582
+ return lum > 0.55;
583
+ }
584
+ }
585
+ if (typeof window.matchMedia === "function") {
586
+ return window.matchMedia("(prefers-color-scheme: light)").matches;
587
+ }
588
+ return false;
589
+ }
590
+ function resolveContrasting(setting) {
591
+ return setting === "auto" ? detectLightBackground() : Boolean(setting);
592
+ }
549
593
  function createFlakeSprite(contrasting, soft) {
550
594
  if (typeof document === "undefined") return null;
551
595
  const size = soft ? 32 : 20;
@@ -594,8 +638,18 @@ function createSnow(options) {
594
638
  return { destroy() {
595
639
  } };
596
640
  }
597
- const sharpSprite = createFlakeSprite(options.contrasting, false);
598
- const softSprite = createFlakeSprite(options.contrasting, true);
641
+ let isContrasting = resolveContrasting(options.contrasting);
642
+ let sharpSprite = createFlakeSprite(isContrasting, false);
643
+ let softSprite = createFlakeSprite(isContrasting, true);
644
+ const refreshContrasting = () => {
645
+ if (options.contrasting !== "auto") return;
646
+ const next = detectLightBackground();
647
+ if (next !== isContrasting) {
648
+ isContrasting = next;
649
+ sharpSprite = createFlakeSprite(isContrasting, false);
650
+ softSprite = createFlakeSprite(isContrasting, true);
651
+ }
652
+ };
599
653
  let width = window.innerWidth;
600
654
  let height = window.innerHeight;
601
655
  let flakes = [];
@@ -603,6 +657,8 @@ function createSnow(options) {
603
657
  let lastTime = 0;
604
658
  let paused = document.visibilityState === "hidden";
605
659
  let destroyed = false;
660
+ let targetWind = 0;
661
+ let currentWind = 0;
606
662
  const initFlakes = () => {
607
663
  const random = createPrng(202611);
608
664
  const count = resolveCount(options.density, width);
@@ -641,10 +697,18 @@ function createSnow(options) {
641
697
  const dt = Math.min((now - lastTime) / 1e3, 0.05);
642
698
  lastTime = now;
643
699
  const t = now / 1e3;
700
+ if (options.mouseWind) {
701
+ currentWind += (targetWind - currentWind) * Math.min(1, dt * 3.2);
702
+ }
644
703
  ctx.clearRect(0, 0, width, height);
645
704
  for (let i = 0; i < flakes.length; i++) {
646
705
  const f = flakes[i];
647
706
  f.y += f.speedY * dt;
707
+ if (options.mouseWind && Math.abs(currentWind) > 2e-3) {
708
+ f.x += currentWind * 58 * (0.45 + f.layer * 0.42) * dt;
709
+ if (f.x < -24) f.x += width + 48;
710
+ else if (f.x > width + 24) f.x -= width + 48;
711
+ }
648
712
  const xOffset = options.wind ? Math.sin(t * f.driftFreq + f.phase) * f.driftAmp : 0;
649
713
  const drawX = f.x + xOffset;
650
714
  if (f.y > height + f.radius * 2) {
@@ -660,7 +724,7 @@ function createSnow(options) {
660
724
  const drawSize = f.radius * (f.layer === 2 ? 3.2 : 2.5);
661
725
  ctx.drawImage(sprite, drawX - drawSize / 2, f.y - drawSize / 2, drawSize, drawSize);
662
726
  } else {
663
- ctx.fillStyle = options.contrasting ? "#d7edff" : "#ffffff";
727
+ ctx.fillStyle = isContrasting ? "#d7edff" : "#ffffff";
664
728
  ctx.beginPath();
665
729
  ctx.arc(drawX, f.y, f.radius, 0, Math.PI * 2);
666
730
  ctx.fill();
@@ -680,9 +744,33 @@ function createSnow(options) {
680
744
  rafId = window.requestAnimationFrame(render);
681
745
  }
682
746
  };
747
+ const handlePointerMove = (event) => {
748
+ targetWind = (event.clientX / Math.max(1, width) - 0.5) * 2;
749
+ };
750
+ const handlePointerLeave = () => {
751
+ targetWind = 0;
752
+ };
683
753
  resize();
684
754
  window.addEventListener("resize", resize, { passive: true });
685
755
  document.addEventListener("visibilitychange", handleVisibility);
756
+ if (options.mouseWind) {
757
+ window.addEventListener("pointermove", handlePointerMove, { passive: true });
758
+ document.documentElement.addEventListener("pointerleave", handlePointerLeave, { passive: true });
759
+ }
760
+ let observer = null;
761
+ if (options.contrasting === "auto" && typeof MutationObserver !== "undefined") {
762
+ observer = new MutationObserver(refreshContrasting);
763
+ observer.observe(document.documentElement, {
764
+ attributes: true,
765
+ attributeFilter: ["class", "style", "data-theme"]
766
+ });
767
+ if (document.body) {
768
+ observer.observe(document.body, {
769
+ attributes: true,
770
+ attributeFilter: ["class", "style", "data-theme"]
771
+ });
772
+ }
773
+ }
686
774
  if (!paused) {
687
775
  rafId = window.requestAnimationFrame(render);
688
776
  }
@@ -692,6 +780,11 @@ function createSnow(options) {
692
780
  if (rafId) window.cancelAnimationFrame(rafId);
693
781
  window.removeEventListener("resize", resize);
694
782
  document.removeEventListener("visibilitychange", handleVisibility);
783
+ if (options.mouseWind) {
784
+ window.removeEventListener("pointermove", handlePointerMove);
785
+ document.documentElement.removeEventListener("pointerleave", handlePointerLeave);
786
+ }
787
+ observer?.disconnect();
695
788
  canvas.remove();
696
789
  }
697
790
  };
@@ -892,9 +985,10 @@ var DEFAULT_CONFIG = {
892
985
  snow: {
893
986
  enabled: true,
894
987
  density: "medium",
895
- contrasting: false,
988
+ contrasting: "auto",
896
989
  speed: 1,
897
990
  wind: true,
991
+ mouseWind: true,
898
992
  zIndex: 9990
899
993
  },
900
994
  lights: {
@@ -903,9 +997,11 @@ var DEFAULT_CONFIG = {
903
997
  backdrop: "transparent",
904
998
  bulbs: 32,
905
999
  palette: "classic",
1000
+ animation: "twinkle",
906
1001
  interactive: true,
907
1002
  pushBody: false,
908
1003
  zIndex: 9995,
1004
+ ariaLabel: "Illuminate Christmas lights",
909
1005
  container: null
910
1006
  },
911
1007
  buttonBurst: {
@@ -930,51 +1026,75 @@ var DEFAULT_CONFIG = {
930
1026
  offset: 16,
931
1027
  persist: true,
932
1028
  storageKey: "snowies:enabled",
933
- labelOn: "Desactivar efectos navide\xF1os",
934
- labelOff: "Activar efectos navide\xF1os",
935
- textOn: "Navidad",
936
- textOff: "Pausado",
1029
+ labelOn: "Disable Christmas effects",
1030
+ labelOff: "Enable Christmas effects",
1031
+ textOn: "Holiday",
1032
+ textOff: "Paused",
937
1033
  zIndex: 9999
938
1034
  }
939
1035
  };
940
1036
  var PRESETS = {
941
1037
  classic: {
942
- snow: { enabled: true, density: "medium", contrasting: false },
943
- lights: { enabled: true, position: "fixed", backdrop: "transparent", palette: "classic" },
1038
+ snow: { enabled: true, density: "medium", contrasting: "auto", mouseWind: true },
1039
+ lights: {
1040
+ enabled: true,
1041
+ position: "fixed",
1042
+ backdrop: "transparent",
1043
+ palette: "classic",
1044
+ animation: "twinkle"
1045
+ },
944
1046
  buttonBurst: { enabled: true },
945
1047
  buttonSnow: { enabled: true, mode: "manual", style: "subtle" },
946
1048
  toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
947
1049
  },
948
1050
  minimal: {
949
- snow: { enabled: true, density: "light", contrasting: false, speed: 0.85 },
1051
+ snow: { enabled: true, density: "light", contrasting: "auto", speed: 0.85, mouseWind: false },
950
1052
  lights: { enabled: false },
951
1053
  buttonBurst: { enabled: false },
952
1054
  buttonSnow: { enabled: false },
953
1055
  toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
954
1056
  },
955
1057
  festive: {
956
- snow: { enabled: true, density: "heavy", contrasting: false, speed: 1.1 },
957
- lights: { enabled: true, position: "fixed", backdrop: "pine", palette: "classic" },
1058
+ snow: { enabled: true, density: "heavy", contrasting: "auto", speed: 1.1, mouseWind: true },
1059
+ lights: {
1060
+ enabled: true,
1061
+ position: "fixed",
1062
+ backdrop: "pine",
1063
+ palette: "classic",
1064
+ animation: "wave"
1065
+ },
958
1066
  buttonBurst: { enabled: true, particles: 56, crystals: true },
959
1067
  buttonSnow: { enabled: true, mode: "manual", style: "fluffy" },
960
1068
  toggleButton: { enabled: true, variant: "pill", theme: "festive" }
961
1069
  },
962
1070
  light: {
963
- snow: { enabled: true, density: "medium", contrasting: true },
964
- lights: { enabled: true, position: "fixed", backdrop: "transparent", palette: "ice" },
1071
+ snow: { enabled: true, density: "medium", contrasting: true, mouseWind: true },
1072
+ lights: {
1073
+ enabled: true,
1074
+ position: "fixed",
1075
+ backdrop: "transparent",
1076
+ palette: "ice",
1077
+ animation: "twinkle"
1078
+ },
965
1079
  buttonBurst: { enabled: true },
966
1080
  buttonSnow: { enabled: true, mode: "manual", style: "subtle" },
967
1081
  toggleButton: { enabled: true, variant: "icon", theme: "light" }
968
1082
  },
969
1083
  "lights-only": {
970
1084
  snow: { enabled: false },
971
- lights: { enabled: true, position: "fixed", backdrop: "transparent", palette: "classic" },
1085
+ lights: {
1086
+ enabled: true,
1087
+ position: "fixed",
1088
+ backdrop: "transparent",
1089
+ palette: "classic",
1090
+ animation: "twinkle"
1091
+ },
972
1092
  buttonBurst: { enabled: false },
973
1093
  buttonSnow: { enabled: false },
974
1094
  toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
975
1095
  },
976
1096
  "snow-only": {
977
- snow: { enabled: true, density: "medium", contrasting: false },
1097
+ snow: { enabled: true, density: "medium", contrasting: "auto", mouseWind: true },
978
1098
  lights: { enabled: false },
979
1099
  buttonBurst: { enabled: false },
980
1100
  buttonSnow: { enabled: false },
@@ -1002,8 +1122,9 @@ function resolveConfig(options = {}, previous) {
1002
1122
  const presetDef = options.preset ? PRESETS[presetName] ?? {} : previous ? {} : PRESETS[presetName] ?? {};
1003
1123
  const base = previous && !options.preset ? previous : DEFAULT_CONFIG;
1004
1124
  const toggleButton = mergeFeature(base.toggleButton, presetDef.toggleButton, options.toggleButton);
1005
- if (typeof options.toggleButton === "object" && options.toggleButton?.style && base.toggleButton.style) {
1006
- toggleButton.style = { ...base.toggleButton.style, ...options.toggleButton.style };
1125
+ const userToggle = typeof options.toggleButton === "object" ? options.toggleButton : void 0;
1126
+ if (userToggle?.style && base.toggleButton.style) {
1127
+ toggleButton.style = { ...base.toggleButton.style, ...userToggle.style };
1007
1128
  }
1008
1129
  return {
1009
1130
  preset: presetName,
@@ -1212,6 +1333,13 @@ function parseBoolAttr(val) {
1212
1333
  if (val === "false" || val === "0") return false;
1213
1334
  return void 0;
1214
1335
  }
1336
+ var VALID_POSITIONS = /* @__PURE__ */ new Set([
1337
+ "bottom-right",
1338
+ "bottom-left",
1339
+ "top-right",
1340
+ "top-left"
1341
+ ]);
1342
+ var VALID_ANIMATIONS = /* @__PURE__ */ new Set(["twinkle", "wave", "steady"]);
1215
1343
  function autoInitFromScript(script) {
1216
1344
  if (typeof document === "undefined") return null;
1217
1345
  const el = script ?? document.currentScript ?? document.querySelector("script[data-snowies], script[data-preset]");
@@ -1221,15 +1349,37 @@ function autoInitFromScript(script) {
1221
1349
  const preset = el.getAttribute("data-preset");
1222
1350
  if (preset) options.preset = preset;
1223
1351
  const snow = parseBoolAttr(el.getAttribute("data-snow"));
1224
- if (snow !== void 0) options.snow = snow;
1352
+ const mouseWind = parseBoolAttr(el.getAttribute("data-mouse-wind"));
1353
+ if (snow !== void 0 || mouseWind !== void 0) {
1354
+ options.snow = {
1355
+ ...snow !== void 0 ? { enabled: snow } : {},
1356
+ ...mouseWind !== void 0 ? { mouseWind } : {}
1357
+ };
1358
+ }
1225
1359
  const lights = parseBoolAttr(el.getAttribute("data-lights"));
1226
- if (lights !== void 0) options.lights = lights;
1360
+ const lightsAnim = el.getAttribute("data-lights-animation");
1361
+ if (lights !== void 0 || lightsAnim && VALID_ANIMATIONS.has(lightsAnim)) {
1362
+ options.lights = {
1363
+ ...lights !== void 0 ? { enabled: lights } : {},
1364
+ ...lightsAnim && VALID_ANIMATIONS.has(lightsAnim) ? { animation: lightsAnim } : {}
1365
+ };
1366
+ }
1227
1367
  const burst = parseBoolAttr(el.getAttribute("data-burst"));
1228
1368
  if (burst !== void 0) options.buttonBurst = burst;
1229
1369
  const buttonSnow = parseBoolAttr(el.getAttribute("data-button-snow"));
1230
1370
  if (buttonSnow !== void 0) options.buttonSnow = buttonSnow;
1231
1371
  const toggle = parseBoolAttr(el.getAttribute("data-toggle"));
1232
- if (toggle !== void 0) options.toggleButton = toggle;
1372
+ const togglePos = el.getAttribute("data-toggle-position");
1373
+ const textOn = el.getAttribute("data-text-on");
1374
+ const textOff = el.getAttribute("data-text-off");
1375
+ if (toggle !== void 0 || togglePos && VALID_POSITIONS.has(togglePos) || textOn || textOff) {
1376
+ options.toggleButton = {
1377
+ ...toggle !== void 0 ? { enabled: toggle } : {},
1378
+ ...togglePos && VALID_POSITIONS.has(togglePos) ? { position: togglePos } : {},
1379
+ ...textOn ? { textOn } : {},
1380
+ ...textOff ? { textOff } : {}
1381
+ };
1382
+ }
1233
1383
  const from = el.getAttribute("data-from");
1234
1384
  const to = el.getAttribute("data-to");
1235
1385
  if (from && to) {