@hortonstudio/main 1.9.3 → 1.9.4
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/autoInit/button.js +51 -0
- package/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export function init() {
|
|
2
|
+
function setupButtonIcons() {
|
|
3
|
+
const buttonWrappers = document.querySelectorAll('[data-site-button="wrapper"]');
|
|
4
|
+
|
|
5
|
+
buttonWrappers.forEach(wrapper => {
|
|
6
|
+
// Check if this wrapper has an icon wrapper
|
|
7
|
+
const iconWrapper = wrapper.querySelector('[data-site-button-icon="wrapper"]');
|
|
8
|
+
|
|
9
|
+
if (!iconWrapper) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Find the main icon and get the first slot
|
|
14
|
+
const mainIcon = iconWrapper.querySelector('[data-site-button-icon="main"]');
|
|
15
|
+
if (!mainIcon) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const mainSlot = mainIcon.querySelector('[data-site-icon="slot"]');
|
|
20
|
+
if (!mainSlot) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Clone the main slot
|
|
25
|
+
const clonedSlot = mainSlot.cloneNode(true);
|
|
26
|
+
|
|
27
|
+
// Find the placeholder icon and get the first slot
|
|
28
|
+
const placeholderIcon = iconWrapper.querySelector('[data-site-button-icon="placeholder"]');
|
|
29
|
+
if (!placeholderIcon) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const placeholderSlot = placeholderIcon.querySelector('[data-site-icon="slot"]');
|
|
34
|
+
if (!placeholderSlot) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Replace the placeholder slot with the cloned main slot
|
|
39
|
+
placeholderSlot.parentNode.replaceChild(clonedSlot, placeholderSlot);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setupButtonIcons();
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
result: "button initialized",
|
|
47
|
+
destroy: () => {
|
|
48
|
+
// No cleanup needed - this module only modifies DOM during init
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
package/index.js
CHANGED
|
@@ -33,6 +33,7 @@ const initializeHsMain = async () => {
|
|
|
33
33
|
counter: () => import("./autoInit/counter.js"),
|
|
34
34
|
form: () => import("./autoInit/form.js"),
|
|
35
35
|
"site-settings": () => import("./autoInit/site-settings.js"),
|
|
36
|
+
button: () => import("./autoInit/button.js"),
|
|
36
37
|
};
|
|
37
38
|
|
|
38
39
|
let scripts = [
|
|
@@ -73,6 +74,7 @@ const initializeHsMain = async () => {
|
|
|
73
74
|
counter: true,
|
|
74
75
|
form: true,
|
|
75
76
|
"site-settings": true,
|
|
77
|
+
button: true,
|
|
76
78
|
// Only include transition if no-transition attribute is NOT present
|
|
77
79
|
...(hasNoTransition ? {} : { transition: true }),
|
|
78
80
|
};
|