aleman 1.1.3 → 1.1.5
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/menu/menu.js +33 -6
- package/package.json +1 -1
package/menu/menu.js
CHANGED
|
@@ -1,21 +1,26 @@
|
|
|
1
|
-
import {importmap} from './importmap.js';
|
|
2
|
-
import {hydrateMenu} from './hydrate-menu.js';
|
|
3
|
-
|
|
4
1
|
const {stringify} = JSON;
|
|
5
2
|
|
|
6
3
|
export const createMenu = async (element, options, menuData) => {
|
|
7
4
|
const hydrateElement = createHydrate();
|
|
8
5
|
|
|
9
|
-
createMap();
|
|
6
|
+
await createMap();
|
|
10
7
|
await createLink();
|
|
11
8
|
|
|
12
9
|
createStateElement();
|
|
10
|
+
const {hydrateMenu} = await import('./hydrate-menu.js');
|
|
13
11
|
|
|
14
12
|
hydrateMenu(hydrateElement, options, menuData);
|
|
15
13
|
};
|
|
16
14
|
|
|
17
15
|
async function createLink() {
|
|
16
|
+
const name = 'aleman-menu-style';
|
|
17
|
+
|
|
18
|
+
if (findByName(name))
|
|
19
|
+
return;
|
|
20
|
+
|
|
18
21
|
const style = document.createElement('style');
|
|
22
|
+
|
|
23
|
+
style.dataset.name = name;
|
|
19
24
|
const content = await import('./menu.css', {
|
|
20
25
|
with: {
|
|
21
26
|
type: 'css',
|
|
@@ -30,9 +35,15 @@ async function createLink() {
|
|
|
30
35
|
}
|
|
31
36
|
|
|
32
37
|
function createHydrate() {
|
|
38
|
+
const name = 'aleman-hydrate-menu';
|
|
39
|
+
const hydrateElement = findByName(name);
|
|
40
|
+
|
|
41
|
+
if (hydrateElement)
|
|
42
|
+
return;
|
|
43
|
+
|
|
33
44
|
const section = document.createElement('section');
|
|
34
45
|
|
|
35
|
-
section.dataset.name =
|
|
46
|
+
section.dataset.name = name;
|
|
36
47
|
section.innerHTML = `<ul data-name="menu" class="menu menu-hidden"></ul>`;
|
|
37
48
|
document.body.append(section);
|
|
38
49
|
|
|
@@ -40,18 +51,34 @@ function createHydrate() {
|
|
|
40
51
|
}
|
|
41
52
|
|
|
42
53
|
function createStateElement() {
|
|
54
|
+
const name = 'aleman-state-menu';
|
|
55
|
+
|
|
56
|
+
if (findByName(name))
|
|
57
|
+
return;
|
|
58
|
+
|
|
43
59
|
const section = document.createElement('section');
|
|
44
60
|
|
|
61
|
+
section.dataset.name = name;
|
|
45
62
|
section.classList.add('menu-hidden');
|
|
46
63
|
section.dataset.name = 'aleman-state-menu';
|
|
47
64
|
document.body.append(section);
|
|
48
65
|
}
|
|
49
66
|
|
|
50
|
-
function createMap() {
|
|
67
|
+
async function createMap() {
|
|
68
|
+
const name = 'aleman-importmap';
|
|
69
|
+
|
|
70
|
+
if (findByName(name))
|
|
71
|
+
return;
|
|
72
|
+
|
|
51
73
|
const script = document.createElement('script');
|
|
74
|
+
const {importmap} = await import('./importmap.js');
|
|
52
75
|
|
|
76
|
+
script.dataset.name = name;
|
|
53
77
|
script.type = 'importmap';
|
|
54
78
|
script.innerHTML = stringify(importmap, null, 4);
|
|
55
79
|
document.body.append(script);
|
|
56
80
|
}
|
|
57
81
|
|
|
82
|
+
function findByName(name) {
|
|
83
|
+
return document.querySelector(`[data-name=${name}]`);
|
|
84
|
+
}
|