mypgs 1.5.1 → 1.6.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/AGENTS.md +6 -3
- package/README.md +1 -1
- package/assets/javascript/_imports.js +4 -0
- package/assets/javascript/_pgs.js +58 -0
- package/assets/javascript/base/_darkmode.js +27 -105
- package/assets/javascript/base/_svg.js +103 -0
- package/assets/javascript/components/_menu.js +1 -3
- package/assets/javascript/components/_search.js +391 -0
- package/assets/javascript/index.js +2 -0
- package/assets/javascript/layout/_header.js +26 -7
- package/assets/scss/base/_color.scss +5 -5
- package/assets/scss/base/_variables.scss +4 -2
- package/assets/scss/components/_dropdown.scss +2 -1
- package/assets/scss/components/_logo.scss +2 -2
- package/assets/scss/components/_menu.scss +20 -27
- package/assets/scss/components/_modals.scss +11 -1
- package/assets/scss/components/_search.scss +134 -0
- package/assets/scss/index.scss +2 -2
- package/assets/scss/layout/_header.scss +1 -1
- package/assets/scss/layout/_pageShell.scss +1 -0
- package/dist/css/index.css +121 -52
- package/dist/css/index.css.map +1 -1
- package/dist/css/index.min.css +1 -1
- package/dist/index.d.ts +70 -0
- package/dist/javascript/index.js +685 -153
- package/dist/javascript/index.js.map +1 -1
- package/dist/javascript/index.min.js +1 -1
- package/docs/componenti-e-markup.md +37 -1
- package/docs/helper-javascript.md +3 -0
- package/package.json +1 -1
- package/templates/html/components/logo.html +1 -1
- package/templates/html/components/menu.html +13 -1
- package/templates/html/components/{searchbar.html → search.html} +7 -5
- package/templates/html/demo.js +1 -8
- package/templates/html/layout/header.html +11 -5
- package/templates/react/components/logo.jsx +1 -1
- package/templates/react/components/{searchbar.jsx → search.jsx} +9 -7
- package/templates/react/patterns/header.jsx +16 -10
- package/assets/scss/components/_searchbar.scss +0 -70
package/AGENTS.md
CHANGED
|
@@ -8,7 +8,7 @@ This guide is for any AI/Codex agent that initializes or modifies a project base
|
|
|
8
8
|
|
|
9
9
|
- HTML `pgs` attributes as the contract between markup, SCSS, and JavaScript;
|
|
10
10
|
- SCSS sources with base styles, layouts, components, patterns, CSS variables, and mixins;
|
|
11
|
-
- JavaScript modules for recurring behaviors such as accordions, dropdowns, menus, modals, slides, steps, step tabs, notifications, header, cookie consent, and dark mode;
|
|
11
|
+
- JavaScript modules for recurring behaviors such as accordions, dropdowns, menus, modals, search suggestions, slides, steps, step tabs, notifications, header, cookie consent, and dark mode;
|
|
12
12
|
- example HTML templates in `templates/`;
|
|
13
13
|
- compiled assets in `dist/`.
|
|
14
14
|
|
|
@@ -26,7 +26,7 @@ Write custom code only when the pattern does not exist, or when you are adding a
|
|
|
26
26
|
## 2. General Usage Rules
|
|
27
27
|
|
|
28
28
|
- Use `mypgs` as the first choice for layouts, components, helpers, variables, utilities, and available patterns.
|
|
29
|
-
- Do not recreate existing components from scratch: buttons, forms, dropdowns, modals, menus, slides, accordions, steps, stepTabs, notifications, tooltips, tables,
|
|
29
|
+
- Do not recreate existing components from scratch: buttons, forms, dropdowns, modals, menus, slides, accordions, steps, stepTabs, notifications, tooltips, tables, search, logos, headers, footers, and cookie consent.
|
|
30
30
|
- Do not duplicate logic already handled by the `mypgs` JS modules, such as modal open/close, accordion state, Popover API dropdowns, step tabs, notifications, or form validation.
|
|
31
31
|
- Keep `pgs` tokens in markup, SCSS selectors, and JS queries consistent.
|
|
32
32
|
- Prefer composing `pgs` tokens over adding new CSS classes.
|
|
@@ -52,6 +52,7 @@ Files analyzed:
|
|
|
52
52
|
- `assets/javascript/components/_steps.js`
|
|
53
53
|
- `assets/javascript/components/_stepTabs.js`
|
|
54
54
|
- `assets/javascript/components/_notifications.js`
|
|
55
|
+
- `assets/javascript/components/_search.js`
|
|
55
56
|
- `assets/javascript/functions/_formValidate.js`
|
|
56
57
|
- `assets/javascript/functions/_scrollY.js`
|
|
57
58
|
- `assets/javascript/patterns/_header.js`
|
|
@@ -74,6 +75,7 @@ Patterns found:
|
|
|
74
75
|
- Components use a root token and child tokens with a consistent prefix. Use `templates/html/components/` as the canonical markup source.
|
|
75
76
|
|
|
76
77
|
- Runtime states use `pgs-state`, for example `open`, `is-active`, `is-completed`, `is-locked`, `success`, `error`, `warning`, and `info`.
|
|
78
|
+
- La ricerca componibile usa esclusivamente `pgs="search"` come root grafico e comportamentale e il figlio opzionale `pgs="search-suggestions"`. La sorgente dati si configura tramite `pgs.search.api(element)?.configure({ source })` e deve restare indipendente dal backend.
|
|
77
79
|
- Configurable options use `pgs-option`, with simple tokens or values inside square brackets. Prefer copying the current option syntax from the relevant template rather than duplicating examples in this guide.
|
|
78
80
|
|
|
79
81
|
- Naming is mostly camelCase for compound tokens (`menuHorizontal`, `buttonStrong`, `flexColumnElements`) and kebab-like for component sub-elements (`accordion-button`, `modal-dialog-content`, `cookieConsent-actionAccept`).
|
|
@@ -186,6 +188,7 @@ Recommended direct access:
|
|
|
186
188
|
```js
|
|
187
189
|
pgs.notification.toast.success("Saved");
|
|
188
190
|
pgs.modal.api(modalEl)?.open();
|
|
191
|
+
pgs.search.api(searchEl)?.setSource(async ({ query, signal }) => []);
|
|
189
192
|
```
|
|
190
193
|
|
|
191
194
|
`assets/javascript/_imports.js` registers modules with `pgs.registerModules`:
|
|
@@ -224,7 +227,7 @@ Use the templates as the single source of truth for component and layout markup.
|
|
|
224
227
|
Canonical template references:
|
|
225
228
|
|
|
226
229
|
- Layouts: `templates/html/layout/body.html`, `templates/html/layout/flex.html`, `templates/html/layout/grid.html`, `templates/html/layout/pageShell.html`, `templates/html/layout/section.html`
|
|
227
|
-
- Components: `templates/html/components/accordion.html`, `templates/html/components/breadcumbs.html`, `templates/html/components/button.html`, `templates/html/components/card.html`, `templates/html/components/dropdown.html`, `templates/html/components/form.html`, `templates/html/components/logo.html`, `templates/html/components/menu.html`, `templates/html/components/modal.html`, `templates/html/components/notification.html`, `templates/html/components/
|
|
230
|
+
- Components: `templates/html/components/accordion.html`, `templates/html/components/breadcumbs.html`, `templates/html/components/button.html`, `templates/html/components/card.html`, `templates/html/components/dropdown.html`, `templates/html/components/form.html`, `templates/html/components/logo.html`, `templates/html/components/menu.html`, `templates/html/components/modal.html`, `templates/html/components/notification.html`, `templates/html/components/search.html`, `templates/html/components/slides.html`, `templates/html/components/stepTabs.html`, `templates/html/components/steps.html`, `templates/html/components/table.html`, `templates/html/components/tooltip.html`
|
|
228
231
|
- Patterns: `templates/html/patterns/cookieConsent.html`, `templates/html/patterns/footer.html`, `templates/html/patterns/header.html`
|
|
229
232
|
- Complete demo assembly. DO NOT use this for inspiration. It is only used to show all the modules: `templates/demo.html`
|
|
230
233
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`mypgs` e' una libreria frontend condivisa per costruire interfacce coerenti tramite attributi `pgs`, SCSS sorgenti, componenti UI e comportamenti JavaScript riutilizzabili.
|
|
4
4
|
|
|
5
|
-
La libreria nasce come base di design system: layout, spacing, colori, bottoni, form, menu, modali, dropdown, slides, notifiche e pattern ricorrenti vengono definiti una volta sola e riusati nei progetti.
|
|
5
|
+
La libreria nasce come base di design system: layout, spacing, colori, bottoni, form, menu, modali, dropdown, ricerca con suggerimenti, slides, notifiche e pattern ricorrenti vengono definiti una volta sola e riusati nei progetti.
|
|
6
6
|
|
|
7
7
|
## Cosa contiene
|
|
8
8
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { pgs } from "./_pgs.js";
|
|
2
2
|
|
|
3
|
+
import { PGS_svg } from "./base/_svg.js";
|
|
3
4
|
import { PGS_accordion } from "./components/_accordion.js";
|
|
4
5
|
import { PGS_dropdown } from "./components/_dropdown.js";
|
|
5
6
|
import { PGS_menu } from "./components/_menu.js";
|
|
6
7
|
import { PGS_modal } from "./components/_modals.js";
|
|
7
8
|
import { PGS_notification } from "./components/_notifications.js";
|
|
9
|
+
import { PGS_search } from "./components/_search.js";
|
|
8
10
|
import { PGS_slides } from "./components/_slides.js";
|
|
9
11
|
import { PGS_stepTabs } from "./components/_stepTabs.js";
|
|
10
12
|
import { PGS_steps } from "./components/_steps.js";
|
|
@@ -13,11 +15,13 @@ import { PGS_formValidate } from "./functions/_formValidate.js";
|
|
|
13
15
|
import { PGS_scrollHorizontal } from "./functions/_scrollY.js";
|
|
14
16
|
|
|
15
17
|
pgs.registerModules({
|
|
18
|
+
svg: PGS_svg,
|
|
16
19
|
accordion: PGS_accordion,
|
|
17
20
|
dropdown: PGS_dropdown,
|
|
18
21
|
menu: PGS_menu,
|
|
19
22
|
modal: PGS_modal,
|
|
20
23
|
notification: PGS_notification,
|
|
24
|
+
search: PGS_search,
|
|
21
25
|
slides: PGS_slides,
|
|
22
26
|
stepTabs: PGS_stepTabs,
|
|
23
27
|
steps: PGS_steps,
|
|
@@ -185,10 +185,56 @@ export function pgs(root) {
|
|
|
185
185
|
function createOption(attribute) {
|
|
186
186
|
if (!canAttr) return undefined;
|
|
187
187
|
|
|
188
|
+
const read = () => (root.getAttribute(attribute) || "").match(/[^\s[\]]+(?:\[[^\]]*\])?/g) || [];
|
|
189
|
+
const write = values => root.setAttribute(attribute, values.join(" "));
|
|
190
|
+
const getKey = value => String(value).trim().match(/^[^\s[\]]+/)?.[0] || "";
|
|
191
|
+
const getValues = values => values
|
|
192
|
+
.flat()
|
|
193
|
+
.flatMap(value => String(value).match(/[^\s[\]]+(?:\[[^\]]*\])?/g) || [])
|
|
194
|
+
.filter(Boolean);
|
|
195
|
+
|
|
188
196
|
function api() {
|
|
189
197
|
return api;
|
|
190
198
|
}
|
|
191
199
|
|
|
200
|
+
api.add = function (...values) {
|
|
201
|
+
const current = read();
|
|
202
|
+
|
|
203
|
+
getValues(values).forEach(value => {
|
|
204
|
+
if (!current.includes(value)) current.push(value);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
write(current);
|
|
208
|
+
return api;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
api.remove = function (...values) {
|
|
212
|
+
const keys = getValues(values).map(getKey).filter(Boolean);
|
|
213
|
+
write(read().filter(value => !keys.includes(getKey(value))));
|
|
214
|
+
return api;
|
|
215
|
+
};
|
|
216
|
+
|
|
217
|
+
api.toggle = function (value, force) {
|
|
218
|
+
const key = getKey(value);
|
|
219
|
+
if (!key) return false;
|
|
220
|
+
|
|
221
|
+
const exists = api.contains(key);
|
|
222
|
+
|
|
223
|
+
if (force !== undefined) {
|
|
224
|
+
if (force && !exists) api.add(value);
|
|
225
|
+
if (!force && exists) api.remove(key);
|
|
226
|
+
return !!force;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
if (exists) {
|
|
230
|
+
api.remove(key);
|
|
231
|
+
return false;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
api.add(value);
|
|
235
|
+
return true;
|
|
236
|
+
};
|
|
237
|
+
|
|
192
238
|
api.contains = function (key) {
|
|
193
239
|
const source = root.getAttribute(attribute) || "";
|
|
194
240
|
const safeKey = String(key).replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -208,6 +254,18 @@ export function pgs(root) {
|
|
|
208
254
|
return match ? match[1] : undefined;
|
|
209
255
|
};
|
|
210
256
|
|
|
257
|
+
api.setValueBrackets = function (key, value = "") {
|
|
258
|
+
const optionKey = getKey(key);
|
|
259
|
+
if (!optionKey) return api;
|
|
260
|
+
|
|
261
|
+
const option = `${optionKey}[${String(value).trim()}]`;
|
|
262
|
+
const options = read().filter(item => getKey(item) !== optionKey);
|
|
263
|
+
|
|
264
|
+
options.push(option);
|
|
265
|
+
write(options);
|
|
266
|
+
return api;
|
|
267
|
+
};
|
|
268
|
+
|
|
211
269
|
Object.defineProperty(api, "value", {
|
|
212
270
|
get() { return root.getAttribute(attribute); },
|
|
213
271
|
set(v) { root.setAttribute(attribute, v); }
|
|
@@ -1,121 +1,43 @@
|
|
|
1
1
|
//# DARKMODE
|
|
2
2
|
|
|
3
|
+
const EVENT_SVG_CHANGE_COLOR = "pgs:svg:changeColor";
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
for (let I = 0; I < 20; I++) {
|
|
10
|
-
const color = ROOT.getPropertyValue('--' + type + '-color-' + I).toLocaleLowerCase().split("&");
|
|
11
|
-
if (!color[0] == "" && !color[1] == "") {
|
|
12
|
-
let lightDark = [color[0], color[1]]
|
|
13
|
-
colors.push(lightDark)
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
return colors;
|
|
17
|
-
}
|
|
18
|
-
const colors_svg_lottie = [searchColor("svg"), searchColor("lottie")];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
//+ change COLORS
|
|
22
|
-
function darkmodeColorSVG() {
|
|
23
|
-
function changecolor(svgDoc, type = "svg") {
|
|
24
|
-
let isDarkMode = (document.documentElement.getAttribute("data-darkmode") === "true") ? false : true;
|
|
25
|
-
|
|
26
|
-
svgDoc.querySelectorAll('[fill], [stroke]').forEach(fillStroke => {
|
|
27
|
-
|
|
28
|
-
for (const colors of colors_svg_lottie) {
|
|
29
|
-
for (const color of colors) {
|
|
30
|
-
let OLD = (color[0] || '').replace(/\s/g, '');
|
|
31
|
-
let NEW = (color[1] || '').replace(/\s/g, '');
|
|
32
|
-
|
|
33
|
-
["fill", "stroke"].forEach(attr => {
|
|
34
|
-
const current = fillStroke.getAttribute(attr);
|
|
35
|
-
|
|
36
|
-
fillStroke.style.transition = "fill 0.5s ease, stroke 0.5s ease";
|
|
37
|
-
|
|
38
|
-
if (!isDarkMode) {
|
|
39
|
-
if (current == OLD) fillStroke.setAttribute(attr, NEW)
|
|
40
|
-
} else {
|
|
41
|
-
if (current == NEW) fillStroke.setAttribute(attr, OLD)
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
//== OBJECTS
|
|
50
|
-
const objects = document.querySelectorAll('object[type="image/svg+xml"]');
|
|
51
|
-
objects.forEach(obj => {
|
|
52
|
-
|
|
53
|
-
//=== ALL FILL / STROKE
|
|
54
|
-
obj.addEventListener("load", () => {
|
|
55
|
-
const svgDoc = obj.contentDocument;
|
|
56
|
-
if (svgDoc) changecolor(svgDoc, "svg")
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
//=== In caso l'object sia già caricato
|
|
60
|
-
if (obj.contentDocument) {
|
|
61
|
-
const event = new Event("load");
|
|
62
|
-
obj.dispatchEvent(event);
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
//== LOTTIE
|
|
67
|
-
const lottiePlayers = document.querySelectorAll('lottie-player');
|
|
68
|
-
lottiePlayers.forEach(lottiePlayer => {
|
|
69
|
-
|
|
70
|
-
//=== ALL FILL / STROKE
|
|
71
|
-
lottiePlayer.addEventListener("load", () => {
|
|
72
|
-
const svg = lottiePlayer.shadowRoot.querySelector('svg');
|
|
73
|
-
if (svg) changecolor(svg, "lottie")
|
|
74
|
-
});
|
|
5
|
+
//+ CHANGE ICON
|
|
6
|
+
function changeIcon(selector, isDarkMode) {
|
|
7
|
+
selector.forEach(button => {
|
|
8
|
+
const ICON = button.querySelector("i");
|
|
9
|
+
if (!ICON) return;
|
|
75
10
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const event = new Event("load");
|
|
79
|
-
lottiePlayer.dispatchEvent(event);
|
|
80
|
-
}
|
|
11
|
+
ICON.classList.toggle("fa-moon", !isDarkMode);
|
|
12
|
+
ICON.classList.toggle("fa-sun", isDarkMode);
|
|
81
13
|
});
|
|
82
14
|
}
|
|
83
15
|
|
|
16
|
+
//+ SET STATUS
|
|
17
|
+
function setDarkmodeStatus(toggle = false, button) {
|
|
18
|
+
let isDarkMode = localStorage.getItem("screenIsDarkMode") === "true";
|
|
84
19
|
|
|
20
|
+
if (toggle) {
|
|
21
|
+
isDarkMode = !isDarkMode;
|
|
22
|
+
localStorage.setItem("screenIsDarkMode", isDarkMode);
|
|
23
|
+
}
|
|
85
24
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
document.body.classList.add("darkmode");
|
|
91
|
-
document.querySelector(":root").setAttribute("data-darkmode", "true");
|
|
92
|
-
document.body.setAttribute("data-darkmode", "true");
|
|
93
|
-
}
|
|
25
|
+
// SET
|
|
26
|
+
pgs(document.documentElement).state.toggle("darkmode", isDarkMode);
|
|
27
|
+
pgs(document.body).state.toggle("darkmode", isDarkMode);
|
|
28
|
+
// END SET
|
|
94
29
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const ICON = button.querySelector("i");
|
|
98
|
-
if (!ICON) return;
|
|
99
|
-
ICON.classList.toggle("fa-moon", !isDarkMode);
|
|
100
|
-
ICON.classList.toggle("fa-sun", isDarkMode);
|
|
101
|
-
});
|
|
102
|
-
darkmodeColorSVG();
|
|
30
|
+
changeIcon(button, isDarkMode);
|
|
31
|
+
document.dispatchEvent(new CustomEvent(EVENT_SVG_CHANGE_COLOR, { detail: { isDarkMode } }));
|
|
103
32
|
}
|
|
104
33
|
|
|
105
|
-
toggleDarkmode.forEach(button => {
|
|
106
34
|
|
|
107
|
-
//== EXECUTE IMMEDIATELY
|
|
108
|
-
let isDarkMode = document.documentElement.getAttribute("data-darkmode") === "true";
|
|
109
|
-
change(toggleDarkmode, isDarkMode);
|
|
110
35
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
localStorage.setItem("screenIsDarkMode", isDarkMode);
|
|
36
|
+
//= INIT
|
|
37
|
+
const toggleDarkmode = pgs(document).querySelectorAll("toggleDarkmode");
|
|
38
|
+
setDarkmodeStatus(false, toggleDarkmode);
|
|
115
39
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
change(toggleDarkmode, isDarkMode);
|
|
120
|
-
});
|
|
40
|
+
//= BUTTON DARKMODE
|
|
41
|
+
toggleDarkmode.forEach(button => {
|
|
42
|
+
button.addEventListener("click", () => setDarkmodeStatus(true, toggleDarkmode));
|
|
121
43
|
});
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
//# SVG & LOTTIE COLORS
|
|
2
|
+
|
|
3
|
+
const svgColors = {
|
|
4
|
+
eventChangeColor: "pgs:svg:changeColor",
|
|
5
|
+
watchedObjects: new WeakSet(),
|
|
6
|
+
watchedLotties: new WeakSet(),
|
|
7
|
+
|
|
8
|
+
_normalizeColor: (color = "") => {
|
|
9
|
+
return color.replace(/\s/g, "").toLocaleLowerCase();
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
_getCurrentDarkmode: () => {
|
|
13
|
+
return pgs(document.documentElement).state.contains("darkmode");
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
searchColor(type = "svg") {
|
|
17
|
+
const ROOT = getComputedStyle(document.documentElement);
|
|
18
|
+
const colors = [];
|
|
19
|
+
|
|
20
|
+
for (let I = 0; I < 20; I++) {
|
|
21
|
+
const color = ROOT.getPropertyValue("--" + type + "-color-" + I).toLocaleLowerCase().split("&").map(value => value.trim());
|
|
22
|
+
if (color[0] && color[1]) colors.push([color[0], color[1]]);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return colors;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
_changeColor(svgDoc, isDarkMode, colors) {
|
|
29
|
+
if (!svgDoc) return;
|
|
30
|
+
|
|
31
|
+
svgDoc.querySelectorAll("[fill], [stroke]").forEach(fillStroke => {
|
|
32
|
+
for (const color of colors) {
|
|
33
|
+
const OLD = svgColors._normalizeColor(color[0]);
|
|
34
|
+
const NEW = svgColors._normalizeColor(color[1]);
|
|
35
|
+
|
|
36
|
+
["fill", "stroke"].forEach(attr => {
|
|
37
|
+
const current = svgColors._normalizeColor(fillStroke.getAttribute(attr) || "");
|
|
38
|
+
if (!current) return;
|
|
39
|
+
|
|
40
|
+
fillStroke.style.transition = "fill 0.5s ease, stroke 0.5s ease";
|
|
41
|
+
|
|
42
|
+
if (isDarkMode && current === OLD) fillStroke.setAttribute(attr, NEW);
|
|
43
|
+
if (!isDarkMode && current === NEW) fillStroke.setAttribute(attr, OLD);
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
_getLottieSvg(lottiePlayer) {
|
|
50
|
+
return lottiePlayer.shadowRoot?.querySelector("svg") || null;
|
|
51
|
+
},
|
|
52
|
+
|
|
53
|
+
init() {
|
|
54
|
+
document.addEventListener(svgColors.eventChangeColor, event => {
|
|
55
|
+
svgColors.applyColorsSVG(event.detail?.isDarkMode ?? svgColors._getCurrentDarkmode());
|
|
56
|
+
svgColors.applyColorsLottie(event.detail?.isDarkMode ?? svgColors._getCurrentDarkmode());
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
60
|
+
svgColors.applyColorsSVG();
|
|
61
|
+
svgColors.applyColorsLottie();
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
applyColorsSVG(isDarkMode = svgColors._getCurrentDarkmode()) {
|
|
66
|
+
const colorsSvg = svgColors.searchColor("svg");
|
|
67
|
+
|
|
68
|
+
if (!pgs(document).querySelector("svgChangeColor")) return;
|
|
69
|
+
|
|
70
|
+
document.querySelectorAll('object[type="image/svg+xml"]').forEach(obj => {
|
|
71
|
+
if (!svgColors.watchedObjects.has(obj)) {
|
|
72
|
+
obj.addEventListener("load", () => svgColors._changeColor(obj.contentDocument, svgColors._getCurrentDarkmode(), svgColors.searchColor("svg")));
|
|
73
|
+
svgColors.watchedObjects.add(obj);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (obj.contentDocument) svgColors._changeColor(obj.contentDocument, isDarkMode, colorsSvg);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
applyColorsLottie(isDarkMode = svgColors._getCurrentDarkmode()) {
|
|
82
|
+
const colorsLottie = svgColors.searchColor("svg");
|
|
83
|
+
|
|
84
|
+
if (!pgs(document).querySelector("lottieChangeColor")) return;
|
|
85
|
+
|
|
86
|
+
document.querySelectorAll("lottie-player").forEach(lottiePlayer => {
|
|
87
|
+
if (!svgColors.watchedLotties.has(lottiePlayer)) {
|
|
88
|
+
lottiePlayer.addEventListener("load", () => svgColors._changeColor(svgColors._getLottieSvg(lottiePlayer), svgColors._getCurrentDarkmode(), svgColors.searchColor("svg")));
|
|
89
|
+
svgColors.watchedLotties.add(lottiePlayer);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (lottiePlayer.shadowRoot) svgColors._changeColor(svgColors._getLottieSvg(lottiePlayer), isDarkMode, colorsLottie);
|
|
93
|
+
});
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
svgColors.init();
|
|
98
|
+
|
|
99
|
+
export const PGS_svg = {
|
|
100
|
+
eventChangeColor: svgColors.eventChangeColor,
|
|
101
|
+
applyColorsSVG: isDarkMode => svgColors.applyColorsSVG(isDarkMode),
|
|
102
|
+
applyColorsLottie: isDarkMode => svgColors.applyColorsLottie(isDarkMode),
|
|
103
|
+
};
|
|
@@ -20,6 +20,7 @@ function PGS_menu_init(root = document) {
|
|
|
20
20
|
li.querySelector("a").insertAdjacentElement("afterend", button);
|
|
21
21
|
|
|
22
22
|
pgs(li).add("dropdown")
|
|
23
|
+
pgs(li).option.setValueBrackets("position", "bottom right")
|
|
23
24
|
pgs(button).add("dropdown-button")
|
|
24
25
|
pgs(button).add("buttonNohover")
|
|
25
26
|
pgs(ul).add("dropdown-content")
|
|
@@ -30,9 +31,6 @@ function PGS_menu_init(root = document) {
|
|
|
30
31
|
API.set(MENU, {
|
|
31
32
|
element: MENU,
|
|
32
33
|
type: "horizontal",
|
|
33
|
-
// items: () => Array.from(MENU.querySelectorAll('nav > ul > li')),
|
|
34
|
-
// submenus: () => Array.from(MENU.querySelectorAll('.menu-item-has-children > ul')),
|
|
35
|
-
// dropdowns: () => Array.from(MENU.querySelectorAll('.menu-item-has-children')).map(PGS_dropdown_api).filter(Boolean),
|
|
36
34
|
refresh: () => {
|
|
37
35
|
PGS_menu_init(MENU.parentNode || document);
|
|
38
36
|
return API.get(MENU);
|