snowies 0.1.0 → 0.2.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 +2 -1
- package/dist/auto.cjs +101 -40
- package/dist/auto.cjs.map +1 -1
- package/dist/auto.d.cts +1 -1
- package/dist/auto.d.ts +1 -1
- package/dist/auto.js +3 -1
- package/dist/auto.js.map +1 -1
- package/dist/{chunk-XFLVBGZZ.js → chunk-MOABF6MI.js} +102 -43
- package/dist/chunk-MOABF6MI.js.map +1 -0
- package/dist/index.cjs +100 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -3
- package/dist/index.d.ts +8 -3
- package/dist/index.js +1 -1
- package/dist/snowies.global.js +59 -39
- package/dist/snowies.global.js.map +1 -1
- package/dist/{types-CMTuJTs7.d.cts → types-DQkmf0l1.d.cts} +17 -5
- package/dist/{types-CMTuJTs7.d.ts → types-DQkmf0l1.d.ts} +17 -5
- package/package.json +2 -2
- package/dist/chunk-XFLVBGZZ.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/modules/buttonBurst.ts
|
|
4
|
-
var SNOW_CAP_SVG = encodeURIComponent(
|
|
5
|
-
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 120 14" preserveAspectRatio="none"><path d="M0 10 Q10 2 22 7 T48 6 T76 8 T102 5 T120 9 L120 0 L0 0 Z" fill="#ffffff"/><path d="M0 10 Q10 2 22 7 T48 6 T76 8 T102 5 T120 9" fill="none" stroke="#d7edff" stroke-width="1.2"/></svg>`
|
|
6
|
-
);
|
|
7
4
|
var CRYSTAL_SVG = `<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"><path d="M8 1.5v13M2.4 4.75l11.2 6.5M13.6 4.75l-11.2 6.5"/></svg>`;
|
|
8
5
|
function createButtonBurst(options) {
|
|
9
6
|
if (typeof document === "undefined" || typeof window === "undefined") {
|
|
@@ -62,33 +59,6 @@ function createButtonBurst(options) {
|
|
|
62
59
|
`;
|
|
63
60
|
shadow.appendChild(style);
|
|
64
61
|
document.body.appendChild(overlayHost);
|
|
65
|
-
let snowCapStyleEl = null;
|
|
66
|
-
if (options.snowCap && options.snowCapSelector) {
|
|
67
|
-
const capSelectors = options.snowCapSelector.split(",").map((s) => s.trim()).filter(Boolean);
|
|
68
|
-
if (capSelectors.length > 0) {
|
|
69
|
-
const baseSelector = capSelectors.join(", ");
|
|
70
|
-
const afterSelector = capSelectors.map((s) => `${s}::after`).join(", ");
|
|
71
|
-
snowCapStyleEl = document.createElement("style");
|
|
72
|
-
snowCapStyleEl.setAttribute("data-snowies-snowcap", "");
|
|
73
|
-
snowCapStyleEl.textContent = `
|
|
74
|
-
${baseSelector} {
|
|
75
|
-
position: relative;
|
|
76
|
-
}
|
|
77
|
-
${afterSelector} {
|
|
78
|
-
content: "";
|
|
79
|
-
position: absolute;
|
|
80
|
-
top: -3px;
|
|
81
|
-
left: 8px;
|
|
82
|
-
right: 8px;
|
|
83
|
-
height: 9px;
|
|
84
|
-
pointer-events: none;
|
|
85
|
-
background: url("data:image/svg+xml,${SNOW_CAP_SVG}") no-repeat top center / 100% 100%;
|
|
86
|
-
filter: drop-shadow(0 1px 2px rgba(71, 130, 180, 0.45));
|
|
87
|
-
}
|
|
88
|
-
`;
|
|
89
|
-
document.head.appendChild(snowCapStyleEl);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
62
|
const activeTimers = /* @__PURE__ */ new Set();
|
|
93
63
|
const isMobile = () => window.innerWidth <= 640;
|
|
94
64
|
const trigger = (target) => {
|
|
@@ -154,7 +124,81 @@ function createButtonBurst(options) {
|
|
|
154
124
|
activeTimers.forEach((id) => window.clearTimeout(id));
|
|
155
125
|
activeTimers.clear();
|
|
156
126
|
overlayHost.remove();
|
|
157
|
-
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// src/modules/buttonSnow.ts
|
|
132
|
+
var SUBTLE_SNOW_SVG = encodeURIComponent(
|
|
133
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 16" preserveAspectRatio="none">
|
|
134
|
+
<defs>
|
|
135
|
+
<linearGradient id="sg" x1="0" y1="0" x2="0" y2="1">
|
|
136
|
+
<stop offset="0%" stop-color="#ffffff"/>
|
|
137
|
+
<stop offset="72%" stop-color="#f2f8ff"/>
|
|
138
|
+
<stop offset="100%" stop-color="#dceeff"/>
|
|
139
|
+
</linearGradient>
|
|
140
|
+
</defs>
|
|
141
|
+
<path d="M4 9 C6 5.5, 16 4, 30 4.5 C46 5, 62 3.2, 82 4 C102 4.8, 120 3.4, 136 4.6 C148 5.5, 154 6.5, 156 9 C155 11.2, 148 11.5, 140 10 C130 8.2, 122 12.2, 110 11.4 C98 10.6, 90 8.5, 76 10.8 C64 12.6, 54 9.2, 42 10.6 C30 12, 20 8.8, 12 10.6 C7 11.6, 4.5 10.6, 4 9 Z" fill="url(#sg)" stroke="#cbe3fa" stroke-width="0.7" stroke-linejoin="round"/>
|
|
142
|
+
</svg>`
|
|
143
|
+
);
|
|
144
|
+
var FLUFFY_SNOW_SVG = encodeURIComponent(
|
|
145
|
+
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 160 24" preserveAspectRatio="none">
|
|
146
|
+
<defs>
|
|
147
|
+
<linearGradient id="fg" x1="0" y1="0" x2="0" y2="1">
|
|
148
|
+
<stop offset="0%" stop-color="#ffffff"/>
|
|
149
|
+
<stop offset="62%" stop-color="#f4f9ff"/>
|
|
150
|
+
<stop offset="100%" stop-color="#d4eaff"/>
|
|
151
|
+
</linearGradient>
|
|
152
|
+
</defs>
|
|
153
|
+
<path d="M3 13 C5 6, 18 3, 34 4.5 C46 5.6, 56 1.5, 74 2.8 C90 4, 102 1.8, 118 3.6 C134 5.4, 150 4.5, 157 12.5 C157 16, 151 17.2, 145 15 C140 13.2, 138 19.5, 131 19.5 C124 19.5, 122 13.8, 112 14.4 C100 15, 95 21.5, 86 21.5 C77 21.5, 74 14.5, 62 14.8 C50 15.1, 46 19.8, 38 19.6 C30 19.4, 28 14.2, 19 15.2 C11 16.2, 3.5 16.2, 3 13 Z" fill="url(#fg)" stroke="#c2dff8" stroke-width="0.85" stroke-linejoin="round"/>
|
|
154
|
+
</svg>`
|
|
155
|
+
);
|
|
156
|
+
var ALL_BUTTONS_SELECTOR = 'button:not([data-snowies-ignore]):not([disabled]), [role="button"]:not([data-snowies-ignore]):not([aria-disabled="true"])';
|
|
157
|
+
function buildSelectors(options) {
|
|
158
|
+
const raw = options.mode === "all" ? ALL_BUTTONS_SELECTOR : options.selector;
|
|
159
|
+
return raw.split(",").map((s) => s.trim()).filter(Boolean);
|
|
160
|
+
}
|
|
161
|
+
function createButtonSnow(options) {
|
|
162
|
+
if (typeof document === "undefined") {
|
|
163
|
+
return { destroy() {
|
|
164
|
+
} };
|
|
165
|
+
}
|
|
166
|
+
const selectors = buildSelectors(options);
|
|
167
|
+
if (selectors.length === 0) {
|
|
168
|
+
return { destroy() {
|
|
169
|
+
} };
|
|
170
|
+
}
|
|
171
|
+
const isFluffy = options.style === "fluffy";
|
|
172
|
+
const svg = isFluffy ? FLUFFY_SNOW_SVG : SUBTLE_SNOW_SVG;
|
|
173
|
+
const height = isFluffy ? "16px" : "11px";
|
|
174
|
+
const topOffset = isFluffy ? "-7px" : "-4px";
|
|
175
|
+
const insetX = isFluffy ? "3px" : "4px";
|
|
176
|
+
const baseRule = selectors.map((s) => `:where(${s})`).join(", ");
|
|
177
|
+
const afterRule = selectors.map((s) => `:where(${s})::after`).join(", ");
|
|
178
|
+
const styleEl = document.createElement("style");
|
|
179
|
+
styleEl.setAttribute("data-snowies-button-snow", "");
|
|
180
|
+
styleEl.textContent = `
|
|
181
|
+
${baseRule} {
|
|
182
|
+
position: relative;
|
|
183
|
+
overflow: visible;
|
|
184
|
+
}
|
|
185
|
+
${afterRule} {
|
|
186
|
+
content: "";
|
|
187
|
+
position: absolute;
|
|
188
|
+
top: ${topOffset};
|
|
189
|
+
left: ${insetX};
|
|
190
|
+
right: ${insetX};
|
|
191
|
+
height: ${height};
|
|
192
|
+
pointer-events: none;
|
|
193
|
+
z-index: 1;
|
|
194
|
+
background: url("data:image/svg+xml,${svg}") no-repeat top center / 100% 100%;
|
|
195
|
+
filter: drop-shadow(0 1.5px 2px rgba(30, 64, 110, 0.24));
|
|
196
|
+
}
|
|
197
|
+
`;
|
|
198
|
+
document.head.appendChild(styleEl);
|
|
199
|
+
return {
|
|
200
|
+
destroy() {
|
|
201
|
+
styleEl.remove();
|
|
158
202
|
}
|
|
159
203
|
};
|
|
160
204
|
}
|
|
@@ -869,10 +913,14 @@ var DEFAULT_CONFIG = {
|
|
|
869
913
|
selector: 'button, [role="button"], [data-snowies-burst]',
|
|
870
914
|
particles: 48,
|
|
871
915
|
crystals: true,
|
|
872
|
-
snowCap: true,
|
|
873
|
-
snowCapSelector: "[data-snowies-btn], .snowies-btn",
|
|
874
916
|
zIndex: 9998
|
|
875
917
|
},
|
|
918
|
+
buttonSnow: {
|
|
919
|
+
enabled: true,
|
|
920
|
+
mode: "manual",
|
|
921
|
+
style: "subtle",
|
|
922
|
+
selector: "[data-snowies-snow], [data-snowies-btn], .snowies-snow"
|
|
923
|
+
},
|
|
876
924
|
toggleButton: {
|
|
877
925
|
enabled: true,
|
|
878
926
|
position: "bottom-right",
|
|
@@ -893,37 +941,43 @@ var PRESETS = {
|
|
|
893
941
|
classic: {
|
|
894
942
|
snow: { enabled: true, density: "medium", contrasting: false },
|
|
895
943
|
lights: { enabled: true, position: "fixed", backdrop: "transparent", palette: "classic" },
|
|
896
|
-
buttonBurst: { enabled: true
|
|
944
|
+
buttonBurst: { enabled: true },
|
|
945
|
+
buttonSnow: { enabled: true, mode: "manual", style: "subtle" },
|
|
897
946
|
toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
|
|
898
947
|
},
|
|
899
948
|
minimal: {
|
|
900
949
|
snow: { enabled: true, density: "light", contrasting: false, speed: 0.85 },
|
|
901
950
|
lights: { enabled: false },
|
|
902
|
-
buttonBurst: { enabled: false
|
|
951
|
+
buttonBurst: { enabled: false },
|
|
952
|
+
buttonSnow: { enabled: false },
|
|
903
953
|
toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
|
|
904
954
|
},
|
|
905
955
|
festive: {
|
|
906
956
|
snow: { enabled: true, density: "heavy", contrasting: false, speed: 1.1 },
|
|
907
957
|
lights: { enabled: true, position: "fixed", backdrop: "pine", palette: "classic" },
|
|
908
|
-
buttonBurst: { enabled: true, particles: 56, crystals: true
|
|
958
|
+
buttonBurst: { enabled: true, particles: 56, crystals: true },
|
|
959
|
+
buttonSnow: { enabled: true, mode: "manual", style: "fluffy" },
|
|
909
960
|
toggleButton: { enabled: true, variant: "pill", theme: "festive" }
|
|
910
961
|
},
|
|
911
962
|
light: {
|
|
912
963
|
snow: { enabled: true, density: "medium", contrasting: true },
|
|
913
964
|
lights: { enabled: true, position: "fixed", backdrop: "transparent", palette: "ice" },
|
|
914
|
-
buttonBurst: { enabled: true
|
|
965
|
+
buttonBurst: { enabled: true },
|
|
966
|
+
buttonSnow: { enabled: true, mode: "manual", style: "subtle" },
|
|
915
967
|
toggleButton: { enabled: true, variant: "icon", theme: "light" }
|
|
916
968
|
},
|
|
917
969
|
"lights-only": {
|
|
918
970
|
snow: { enabled: false },
|
|
919
971
|
lights: { enabled: true, position: "fixed", backdrop: "transparent", palette: "classic" },
|
|
920
|
-
buttonBurst: { enabled: false
|
|
972
|
+
buttonBurst: { enabled: false },
|
|
973
|
+
buttonSnow: { enabled: false },
|
|
921
974
|
toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
|
|
922
975
|
},
|
|
923
976
|
"snow-only": {
|
|
924
977
|
snow: { enabled: true, density: "medium", contrasting: false },
|
|
925
978
|
lights: { enabled: false },
|
|
926
|
-
buttonBurst: { enabled: false
|
|
979
|
+
buttonBurst: { enabled: false },
|
|
980
|
+
buttonSnow: { enabled: false },
|
|
927
981
|
toggleButton: { enabled: true, variant: "icon", theme: "minimal" }
|
|
928
982
|
}
|
|
929
983
|
};
|
|
@@ -959,6 +1013,7 @@ function resolveConfig(options = {}, previous) {
|
|
|
959
1013
|
snow: mergeFeature(base.snow, presetDef.snow, options.snow),
|
|
960
1014
|
lights: mergeFeature(base.lights, presetDef.lights, options.lights),
|
|
961
1015
|
buttonBurst: mergeFeature(base.buttonBurst, presetDef.buttonBurst, options.buttonBurst),
|
|
1016
|
+
buttonSnow: mergeFeature(base.buttonSnow, presetDef.buttonSnow, options.buttonSnow),
|
|
962
1017
|
toggleButton,
|
|
963
1018
|
onChange: options.onChange ?? base.onChange
|
|
964
1019
|
};
|
|
@@ -1034,6 +1089,7 @@ function createSnowies(options = {}) {
|
|
|
1034
1089
|
let snowMod = null;
|
|
1035
1090
|
let lightsMod = null;
|
|
1036
1091
|
let burstMod = null;
|
|
1092
|
+
let buttonSnowMod = null;
|
|
1037
1093
|
let toggleMod = null;
|
|
1038
1094
|
const computeState = () => {
|
|
1039
1095
|
const inSchedule = isWithinSchedule(config.schedule);
|
|
@@ -1062,6 +1118,8 @@ function createSnowies(options = {}) {
|
|
|
1062
1118
|
lightsMod = null;
|
|
1063
1119
|
burstMod?.destroy();
|
|
1064
1120
|
burstMod = null;
|
|
1121
|
+
buttonSnowMod?.destroy();
|
|
1122
|
+
buttonSnowMod = null;
|
|
1065
1123
|
};
|
|
1066
1124
|
const destroyToggle = () => {
|
|
1067
1125
|
toggleMod?.destroy();
|
|
@@ -1075,6 +1133,7 @@ function createSnowies(options = {}) {
|
|
|
1075
1133
|
if (config.snow.enabled) snowMod = createSnow(config.snow);
|
|
1076
1134
|
if (config.lights.enabled) lightsMod = createLights(config.lights);
|
|
1077
1135
|
if (config.buttonBurst.enabled) burstMod = createButtonBurst(config.buttonBurst);
|
|
1136
|
+
if (config.buttonSnow.enabled) buttonSnowMod = createButtonSnow(config.buttonSnow);
|
|
1078
1137
|
}
|
|
1079
1138
|
const shouldShowToggle = state.inSchedule && config.enabled && config.toggleButton.enabled;
|
|
1080
1139
|
destroyToggle();
|
|
@@ -1121,7 +1180,7 @@ function createSnowies(options = {}) {
|
|
|
1121
1180
|
if (burstMod) {
|
|
1122
1181
|
burstMod.trigger(target);
|
|
1123
1182
|
} else {
|
|
1124
|
-
const temp = createButtonBurst(
|
|
1183
|
+
const temp = createButtonBurst(config.buttonBurst);
|
|
1125
1184
|
temp.trigger(target);
|
|
1126
1185
|
window.setTimeout(() => temp.destroy(), 1500);
|
|
1127
1186
|
}
|
|
@@ -1149,6 +1208,7 @@ function createSnowies(options = {}) {
|
|
|
1149
1208
|
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
1150
1209
|
exports.PRESETS = PRESETS;
|
|
1151
1210
|
exports.createButtonBurst = createButtonBurst;
|
|
1211
|
+
exports.createButtonSnow = createButtonSnow;
|
|
1152
1212
|
exports.createLights = createLights;
|
|
1153
1213
|
exports.createSnow = createSnow;
|
|
1154
1214
|
exports.createSnowies = createSnowies;
|