@leuffen/themejs1 1.0.0 → 2.0.2

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.
@@ -1,137 +0,0 @@
1
- import {ka_create_element, ka_html, KaTemplate} from "@kasimirjs/embed";
2
- import {DefaultLayout, jodaRenderer, JodaRendererInterface} from "@leuffen/jodastyle";
3
- import {QTemplate} from "@leuffen/jodastyle/src/helper/QTemplate";
4
-
5
-
6
-
7
- // language=HTML
8
- const tpl = ka_html(`
9
- <nav class="as__navbar [[layout.position]]" style="z-index: 999">
10
-
11
- <div id="as__minibar" class="as__minibar top" >
12
- <div class="[[layout.container]]" data-ref="minibar"></div>
13
- </div>
14
-
15
- <div class="as__mainbar navbar navbar-expand-lg w-100">
16
- <div class="[[layout.container]]" data-ref="main">
17
-
18
- <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
19
- <span class="navbar-toggler-icon"></span>
20
- </button>
21
- <div data-ref="navbar" class="collapse navbar-collapse" id="navbarSupportedContent">
22
-
23
-
24
- </div>
25
- </div>
26
- </div>
27
-
28
- </nav>
29
- `);
30
-
31
-
32
- export class NavbarLayout extends DefaultLayout {
33
-
34
- /**
35
- * a additional class name added to the main element
36
- * to allow for custom styling. Defaults to "default" (see as-navbar.scss for details)
37
- */
38
- style_class = "default";
39
-
40
- /**
41
- * default position: Fixed on top
42
- */
43
- position = "fixed";
44
-
45
- /**
46
- * Show fixed navbar if scrolled down more than this distance
47
- */
48
- fixed_scroll_distance = 10;
49
- }
50
-
51
-
52
- @jodaRenderer("navbar", NavbarLayout)
53
- class Navbar implements JodaRendererInterface {
54
-
55
- public render(element: HTMLElement, layout: NavbarLayout) {
56
- console.log(layout);
57
-
58
- let original = element.cloneNode(true) as HTMLElement;
59
-
60
-
61
- let template = new QTemplate(tpl);
62
- element.innerHTML = "";
63
- element.appendChild(template.content);
64
-
65
-
66
- template.parse({layout});
67
-
68
- let result = template.content;
69
- let mainDiv = template.with("main");
70
- let navbar = template.with("navbar");
71
- let minibar = template.with("minibar");
72
-
73
-
74
-
75
- let navbarBrand = original.querySelector(".navbar-brand");
76
- if (navbarBrand === null) {
77
- navbarBrand = ka_create_element("a", {href: "/"}, "No class='navbar-brand' element")
78
- }
79
-
80
- mainDiv.selected.insertBefore(navbarBrand, mainDiv.selected.firstElementChild);
81
-
82
- let mainUl = original.querySelector("ul.mainbar") as HTMLDivElement | null;
83
- if (mainUl === null) {
84
- mainUl = ka_create_element("ul", {}, "Missing ul.mainbar element") as HTMLDivElement
85
- }
86
- mainUl = mainUl.cloneNode(true) as HTMLDivElement;
87
- navbar.append(mainUl);
88
-
89
- let miniUl = original.querySelector("ul.minibar") as HTMLDivElement | null;
90
- if (miniUl.firstElementChild === null) {
91
- miniUl = null;
92
- }
93
- minibar.append(miniUl);
94
-
95
- mainUl.classList.add(..."navbar-nav navbar-nav-scroll ms-auto my-2 my-lg-0".split(" "));
96
-
97
-
98
- if (layout.fixed_scroll_distance !== null)
99
- result.firstElementChild.classList.add("auto-fixed");
100
-
101
- result.firstElementChild.classList.add(layout.style_class);
102
- let scolled = false;
103
- let fixed = false;
104
-
105
- window.setInterval(() => {
106
- if (window.scrollY > 0 && !scolled) {
107
- result.classList.add("scrolled");
108
- scolled = true;
109
- } else if (window.scrollY === 0 && scolled) {
110
- result.classList.remove("scrolled");
111
- scolled = false;
112
- } else {
113
- // nothing
114
- }
115
- if (layout.fixed_scroll_distance === null)
116
- return;
117
- if (window.scrollY > layout.fixed_scroll_distance && !fixed) {
118
- result.classList.add("fixed");
119
- fixed = true;
120
- } else if (window.scrollY <= layout.fixed_scroll_distance && fixed) {
121
- result.classList.remove("fixed");
122
- fixed = false;
123
- }
124
- }, 300)
125
-
126
-
127
- mainUl.querySelectorAll("li").forEach(e => e.classList.add("nav-item"))
128
- mainUl.querySelectorAll("li a").forEach(e => e.classList.add("nav-link"))
129
- mainUl.querySelectorAll("li.dropdown ul").forEach(e => e.classList.add("dropdown-menu"))
130
- mainUl.querySelectorAll("li.dropdown ul li").forEach(e => e.classList.add("dropdown-item"))
131
-
132
-
133
- element.replaceWith(template.content);
134
- return template.content;
135
- }
136
- }
137
-
package/style.scss DELETED
@@ -1,4 +0,0 @@
1
-
2
- @import "src/template/_variables.scss";
3
- @import "src/template/navbar/navbar.scss";
4
- @import "src/template/hero/hero1.scss";
package/style_embed.scss DELETED
@@ -1 +0,0 @@
1
-
package/style_late.scss DELETED
@@ -1,2 +0,0 @@
1
-
2
-