aleman 1.9.0 → 1.9.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.
- package/ChangeLog +5 -0
- package/menu/addons/shift-g.js +4 -1
- package/menu/menu.js +32 -4
- package/package.json +3 -2
package/ChangeLog
CHANGED
package/menu/addons/shift-g.js
CHANGED
package/menu/menu.js
CHANGED
|
@@ -7,7 +7,7 @@ export const createMenu = async (elementName, options, menu) => {
|
|
|
7
7
|
const hydrateElement = createHydrate(name);
|
|
8
8
|
|
|
9
9
|
await createMap();
|
|
10
|
-
await
|
|
10
|
+
await loadStyle();
|
|
11
11
|
|
|
12
12
|
createStateElement(name);
|
|
13
13
|
const {hydrateMenu} = await import('./hydrate-menu.js');
|
|
@@ -19,21 +19,40 @@ export const createMenu = async (elementName, options, menu) => {
|
|
|
19
19
|
});
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
async function
|
|
22
|
+
async function loadStyle() {
|
|
23
23
|
const name = 'aleman-menu-style';
|
|
24
24
|
|
|
25
25
|
if (findByName(name))
|
|
26
26
|
return;
|
|
27
27
|
|
|
28
|
-
const
|
|
28
|
+
const [error] = await tryToCatch(importCSS);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
if (!error)
|
|
31
|
+
return;
|
|
32
|
+
|
|
33
|
+
createLink();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function createLink() {
|
|
37
|
+
const href = new URL('menu.css', import.meta.url).pathname;
|
|
38
|
+
const link = document.createElement('link');
|
|
39
|
+
|
|
40
|
+
link.rel = 'stylesheet';
|
|
41
|
+
link.href = href;
|
|
42
|
+
document.head.appendChild(link);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function importCSS() {
|
|
31
46
|
const content = await import('./menu.css', {
|
|
32
47
|
with: {
|
|
33
48
|
type: 'css',
|
|
34
49
|
},
|
|
35
50
|
});
|
|
36
51
|
|
|
52
|
+
const style = document.createElement('style');
|
|
53
|
+
|
|
54
|
+
style.dataset.name = name;
|
|
55
|
+
|
|
37
56
|
for (const rule of content.default.cssRules) {
|
|
38
57
|
style.innerHTML += rule.cssText;
|
|
39
58
|
}
|
|
@@ -89,3 +108,12 @@ async function createMap() {
|
|
|
89
108
|
function findByName(name) {
|
|
90
109
|
return document.querySelector(`[data-name=${name}]`);
|
|
91
110
|
}
|
|
111
|
+
|
|
112
|
+
async function tryToCatch(fn, args) {
|
|
113
|
+
try {
|
|
114
|
+
return [null, await fn(...args)];
|
|
115
|
+
} catch(error) {
|
|
116
|
+
return [error];
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aleman",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊Putout-based framework for web",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"html-escaper": "^3.0.3",
|
|
30
30
|
"jessy": "^4.1.0",
|
|
31
31
|
"once": "^1.4.0",
|
|
32
|
-
"putout": "^40.5.1"
|
|
32
|
+
"putout": "^40.5.1",
|
|
33
|
+
"try-to-catch": "^3.0.1"
|
|
33
34
|
},
|
|
34
35
|
"keywords": [
|
|
35
36
|
"putout",
|