ks-web-comp-nav 1.3.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/LICENSE +21 -0
- package/README.md +61 -0
- package/bin/cli.js +9 -0
- package/bin/commands/nav.js +75 -0
- package/bin/commands/steps/announce.js +3 -0
- package/bin/commands/steps/checks.js +21 -0
- package/bin/commands/steps/createProject.js +7 -0
- package/bin/commands/steps/getLatestVersion.js +25 -0
- package/bin/commands/steps/locateDestination.js +5 -0
- package/bin/commands/steps/locateSource copy.js +32 -0
- package/bin/commands/steps/locateSource.js +19 -0
- package/bin/commands/steps/resolveFolderName.js +18 -0
- package/bin/commands/template/v1/BuildMenuItem/buildMenuItem.js +31 -0
- package/bin/commands/template/v1/BuildMenuItem/createAnchor.js +29 -0
- package/bin/commands/template/v1/BuildMenuItem/createLi.js +5 -0
- package/bin/commands/template/v1/BuildNav/buildBrand.js +14 -0
- package/bin/commands/template/v1/BuildNav/buildHamburger.js +20 -0
- package/bin/commands/template/v1/BuildNav/buildMenu.js +14 -0
- package/bin/commands/template/v1/BuildNav/buildNav.js +25 -0
- package/bin/commands/template/v1/BuildNav/buildWrapper.js +29 -0
- package/bin/commands/template/v1/WebComponents/v2/menuItem/createAnchor.js +15 -0
- package/bin/commands/template/v1/WebComponents/v2/menuItem/createIcon.js +27 -0
- package/bin/commands/template/v1/WebComponents/v2/menuItem/createLabel.js +9 -0
- package/bin/commands/template/v1/WebComponents/v2/menuItem/createLi.js +5 -0
- package/bin/commands/template/v1/WebComponents/v2/menuItem/icons.js +54 -0
- package/bin/commands/template/v1/WebComponents/v2/menuItem/index.js +64 -0
- package/bin/commands/template/v1/WebComponents/v2/nav/index.js +55 -0
- package/bin/commands/template/v1/WebComponents/v3/menuItem/createAnchor.js +15 -0
- package/bin/commands/template/v1/WebComponents/v3/menuItem/createIcon.js +27 -0
- package/bin/commands/template/v1/WebComponents/v3/menuItem/icons.js +54 -0
- package/bin/commands/template/v1/WebComponents/v3/menuItem/index.js +61 -0
- package/bin/commands/template/v1/WebComponents/v3/nav/index.js +119 -0
- package/bin/commands/template/v1/WebComponents/v4/menuItem/createAnchor.js +15 -0
- package/bin/commands/template/v1/WebComponents/v4/menuItem/createIcon.js +27 -0
- package/bin/commands/template/v1/WebComponents/v4/menuItem/icons.js +54 -0
- package/bin/commands/template/v1/WebComponents/v4/menuItem/index.js +61 -0
- package/bin/commands/template/v1/WebComponents/v4/nav/index.js +154 -0
- package/bin/commands/template/v1/WebComponents/v5/menuItem/createAnchor.js +15 -0
- package/bin/commands/template/v1/WebComponents/v5/menuItem/createIcon.js +27 -0
- package/bin/commands/template/v1/WebComponents/v5/menuItem/icons.js +54 -0
- package/bin/commands/template/v1/WebComponents/v5/menuItem/index.js +61 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/composeNavigationStory.js +55 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/createBrandTitle.js +11 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/createMenuList.js +10 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/createMenuToggleButton.js +14 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/createNavigationBar.js +9 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/createNavigationRow.js +9 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/createNavigationWrapper.js +9 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/index.js +22 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/readAttributeOrDefault.js +9 -0
- package/bin/commands/template/v1/WebComponents/v5/nav/readNavStoryFromElement.js +46 -0
- package/bin/commands/template/v1/WebComponents/v6/menuItem/createAnchor.js +15 -0
- package/bin/commands/template/v1/WebComponents/v6/menuItem/createIcon.js +27 -0
- package/bin/commands/template/v1/WebComponents/v6/menuItem/icons.js +54 -0
- package/bin/commands/template/v1/WebComponents/v6/menuItem/index.js +61 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/composeNavigationStory.js +54 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/createBrandTitle.js +11 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/createMenuList.js +10 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/createMenuToggleButton.js +14 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/createNavigationBar.js +9 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/createNavigationRow.js +9 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/createNavigationWrapper.js +9 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/index.js +31 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/navDefaults.js +15 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/navUsage.js +45 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/readAttributeOrDefault.js +9 -0
- package/bin/commands/template/v1/WebComponents/v6/nav/readNavStoryFromElement.js +42 -0
- package/bin/commands/template/v1/initHeader.js +61 -0
- package/bin/commands/template/v2/composeNavigationStory.js +54 -0
- package/bin/commands/template/v2/createBrandTitle.js +11 -0
- package/bin/commands/template/v2/createMenuList.js +10 -0
- package/bin/commands/template/v2/createMenuToggleButton.js +14 -0
- package/bin/commands/template/v2/createNavigationBar.js +9 -0
- package/bin/commands/template/v2/createNavigationRow.js +9 -0
- package/bin/commands/template/v2/createNavigationWrapper.js +9 -0
- package/bin/commands/template/v2/index.js +31 -0
- package/bin/commands/template/v2/navDefaults.js +15 -0
- package/bin/commands/template/v2/navUsage.js +45 -0
- package/bin/commands/template/v2/readAttributeOrDefault.js +9 -0
- package/bin/commands/template/v2/readNavStoryFromElement.js +42 -0
- package/bin/commands/template/v3/composeNavigationStory.js +54 -0
- package/bin/commands/template/v3/createBrandTitle.js +11 -0
- package/bin/commands/template/v3/createMenuList.js +10 -0
- package/bin/commands/template/v3/createMenuToggleButton.js +14 -0
- package/bin/commands/template/v3/createNavigationBar.js +9 -0
- package/bin/commands/template/v3/createNavigationRow.js +9 -0
- package/bin/commands/template/v3/createNavigationWrapper.js +9 -0
- package/bin/commands/template/v3/index.js +34 -0
- package/bin/commands/template/v3/navDefaults.js +15 -0
- package/bin/commands/template/v3/navUsage.js +45 -0
- package/bin/commands/template/v3/readAttributeOrDefault.js +9 -0
- package/bin/commands/template/v3/readNavStoryFromElement.js +42 -0
- package/bin/core/parseInput.js +8 -0
- package/bin/core/resolveCommand.js +16 -0
- package/bin/core/showUsage.js +46 -0
- package/bin/start.js +20 -0
- package/index.js +16 -0
- package/package.json +43 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
class KSNav extends HTMLElement {
|
|
2
|
+
connectedCallback() {
|
|
3
|
+
if (this.dataset.rendered === "true") return;
|
|
4
|
+
|
|
5
|
+
this.dataset.rendered = "true";
|
|
6
|
+
|
|
7
|
+
const nav = document.createElement("nav");
|
|
8
|
+
nav.className = "bg-gray-800 text-white";
|
|
9
|
+
|
|
10
|
+
const outerDiv = document.createElement("div");
|
|
11
|
+
outerDiv.className = `mx-auto px-3 py-3
|
|
12
|
+
max-w-3xl
|
|
13
|
+
lg:max-w-5xl
|
|
14
|
+
xl:max-w-full xl:px-10`;
|
|
15
|
+
|
|
16
|
+
const innerDiv = document.createElement("div");
|
|
17
|
+
innerDiv.className = "flex flex-wrap items-center justify-between";
|
|
18
|
+
|
|
19
|
+
const brand = document.createElement("div");
|
|
20
|
+
brand.className = "text-xl font-semibold";
|
|
21
|
+
brand.id = this.getAttribute("ks-title-id") || "titlehtmlId";
|
|
22
|
+
brand.innerText = this.getAttribute("ks-title") || "KeshavSoft";
|
|
23
|
+
|
|
24
|
+
const button = document.createElement("button");
|
|
25
|
+
button.className = "text-xl px-4 py-1 md:hidden";
|
|
26
|
+
button.innerText = "☰";
|
|
27
|
+
|
|
28
|
+
const menu = document.createElement("ul");
|
|
29
|
+
menu.id = "menu";
|
|
30
|
+
menu.className = `w-full hidden flex flex-col space-y-2 mt-4
|
|
31
|
+
md:flex md:flex-row md:space-y-0 md:gap-4
|
|
32
|
+
md:mt-0 md:w-auto md:flex-wrap ${this.getAttribute("ks-ul-class") || ""}`;
|
|
33
|
+
|
|
34
|
+
button.addEventListener("click", () => {
|
|
35
|
+
menu.classList.toggle("hidden");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
innerDiv.append(
|
|
39
|
+
brand,
|
|
40
|
+
button,
|
|
41
|
+
menu
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
outerDiv.appendChild(innerDiv);
|
|
45
|
+
nav.appendChild(outerDiv);
|
|
46
|
+
this.appendChild(nav);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
customElements.define(
|
|
51
|
+
"ks-nav",
|
|
52
|
+
KSNav
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
export default {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const createAnchor = ({
|
|
2
|
+
inHtmlId = "", inHref = "#", inClass = "", inTableName = ""
|
|
3
|
+
}) => {
|
|
4
|
+
const a = document.createElement("a");
|
|
5
|
+
|
|
6
|
+
a.id = inHtmlId;
|
|
7
|
+
a.href = inHref;
|
|
8
|
+
a.className = inClass;
|
|
9
|
+
|
|
10
|
+
if (inTableName) {
|
|
11
|
+
a.dataset.tableName = inTableName
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return a;
|
|
15
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import icons from "./icons.js";
|
|
2
|
+
|
|
3
|
+
export const createIcon = ({
|
|
4
|
+
inSvgName, inSvgDivClass = "size-6 flex items-center justify-center -----"
|
|
5
|
+
}) => {
|
|
6
|
+
if (inSvgName in icons) {
|
|
7
|
+
const icon = document
|
|
8
|
+
.createRange()
|
|
9
|
+
.createContextualFragment(icons[inSvgName])
|
|
10
|
+
.firstElementChild;
|
|
11
|
+
|
|
12
|
+
const div = document.createElement("div");
|
|
13
|
+
|
|
14
|
+
// div.className = "size-6 flex items-center justify-center";
|
|
15
|
+
div.className = inSvgDivClass;
|
|
16
|
+
// console.log("inSvgName----- : ", inSvgName, inSvgDivClass);
|
|
17
|
+
|
|
18
|
+
div.appendChild(icon);
|
|
19
|
+
|
|
20
|
+
return div;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return document
|
|
24
|
+
.createRange()
|
|
25
|
+
.createContextualFragment(icons.search)
|
|
26
|
+
.firstElementChild;
|
|
27
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// icons.js
|
|
2
|
+
export default {
|
|
3
|
+
serverStack: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
4
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M5.25 14.25h13.5m-13.5 0a3 3 0 0 1-3-3m3 3a3 3 0 1 0 0 6h13.5a3 3 0 1 0 0-6m-16.5-3a3 3 0 0 1 3-3h13.5a3 3 0 0 1 3 3m-19.5 0a4.5 4.5 0 0 1 .9-2.7L5.737 5.1a3.375 3.375 0 0 1 2.7-1.35h7.126c1.062 0 2.062.5 2.7 1.35l2.587 3.45a4.5 4.5 0 0 1 .9 2.7m0 0a3 3 0 0 1-3 3m0 3h.008v.008h-.008v-.008Zm0-6h.008v.008h-.008v-.008Zm-3 6h.008v.008h-.008v-.008Zm0-6h.008v.008h-.008v-.008Z" />
|
|
5
|
+
</svg>
|
|
6
|
+
`,
|
|
7
|
+
copy: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
8
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25ZM6.75 12h.008v.008H6.75V12Zm0 3h.008v.008H6.75V15Zm0 3h.008v.008H6.75V18Z" />
|
|
9
|
+
</svg>
|
|
10
|
+
`,
|
|
11
|
+
puzzle: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-10">
|
|
12
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.39 48.39 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.422 48.422 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0Z" />
|
|
13
|
+
</svg>
|
|
14
|
+
`,
|
|
15
|
+
folderPlus: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-10">
|
|
16
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 10.5v6m3-3H9m4.06-7.19-2.12-2.12a1.5 1.5 0 0 0-1.061-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.379a1.5 1.5 0 0 1-1.06-.44Z" />
|
|
17
|
+
</svg>
|
|
18
|
+
`,
|
|
19
|
+
download: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
20
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 8.25H7.5a2.25 2.25 0 0 0-2.25 2.25v9a2.25 2.25 0 0 0 2.25 2.25h9a2.25 2.25 0 0 0 2.25-2.25v-9a2.25 2.25 0 0 0-2.25-2.25H15M9 12l3 3m0 0 3-3m-3 3V2.25" />
|
|
21
|
+
</svg>`,
|
|
22
|
+
search: `
|
|
23
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
24
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
|
25
|
+
</svg>
|
|
26
|
+
`,
|
|
27
|
+
home: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
28
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m2.25 12 8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
|
|
29
|
+
</svg>
|
|
30
|
+
`,
|
|
31
|
+
serial: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
32
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M8.242 5.992h12m-12 6.003H20.24m-12 5.999h12M4.117 7.495v-3.75H2.99m1.125 3.75H2.99m1.125 0H5.24m-1.92 2.577a1.125 1.125 0 1 1 1.591 1.59l-1.83 1.83h2.16M2.99 15.745h1.125a1.125 1.125 0 0 1 0 2.25H3.74m0-.002h.375a1.125 1.125 0 0 1 0 2.25H2.99" />
|
|
33
|
+
</svg>
|
|
34
|
+
`,
|
|
35
|
+
currency: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
36
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 8.25H9m6 3H9m3 6-3-3h1.5a3 3 0 1 0 0-6M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
|
|
37
|
+
</svg>
|
|
38
|
+
`,
|
|
39
|
+
wifi: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
40
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M8.288 15.038a5.25 5.25 0 0 1 7.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0M12.53 18.22l-.53.53-.53-.53a.75.75 0 0 1 1.06 0Z" />
|
|
41
|
+
</svg>
|
|
42
|
+
`,
|
|
43
|
+
exclamation: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
44
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" />
|
|
45
|
+
</svg>
|
|
46
|
+
`,
|
|
47
|
+
search1: `
|
|
48
|
+
<div class="w-10 h-10 flex items-center justify-center">
|
|
49
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
50
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
|
51
|
+
</svg>
|
|
52
|
+
</div>
|
|
53
|
+
`,
|
|
54
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createAnchor } from "./createAnchor.js";
|
|
2
|
+
import { createIcon } from "./createIcon.js";
|
|
3
|
+
|
|
4
|
+
class KSMenuItem extends HTMLElement {
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
const a = createAnchor({
|
|
7
|
+
inHtmlId: this.getAttribute("ks-id"),
|
|
8
|
+
inHref: this.getAttribute("ks-href"),
|
|
9
|
+
inTableName: this.getAttribute("ks-table-name"),
|
|
10
|
+
inClass: this.getAttribute("ks-class")
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const text = this.getAttribute("ks-textToShow") || "";
|
|
14
|
+
const className = this.getAttribute("ks-className") || "";
|
|
15
|
+
|
|
16
|
+
const svgName = this.getAttribute("ks-svgName") || "";
|
|
17
|
+
const svgDivClass = this.getAttribute("ks-svgDivClass") || "";
|
|
18
|
+
|
|
19
|
+
const svg = createIcon({
|
|
20
|
+
inSvgName: svgName,
|
|
21
|
+
inSvgDivClass: svgDivClass
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const span =
|
|
25
|
+
document.createElement("span");
|
|
26
|
+
|
|
27
|
+
span.textContent = text;
|
|
28
|
+
|
|
29
|
+
span.className = className;
|
|
30
|
+
|
|
31
|
+
while (this.firstChild) {
|
|
32
|
+
a.appendChild(
|
|
33
|
+
this.firstChild
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
a.append(
|
|
38
|
+
svg,
|
|
39
|
+
span
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
a.addEventListener("click", event => {
|
|
43
|
+
const menu = event.currentTarget
|
|
44
|
+
.closest("nav")
|
|
45
|
+
?.querySelector("#menu");
|
|
46
|
+
|
|
47
|
+
// console.log("menu : ", menu);
|
|
48
|
+
|
|
49
|
+
menu?.classList.add("hidden");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.appendChild(a);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
customElements.define(
|
|
57
|
+
"ks-menu-item",
|
|
58
|
+
KSMenuItem
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export default {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
const createNav = ({ inClassName }) => {
|
|
2
|
+
const nav = document.createElement("nav");
|
|
3
|
+
|
|
4
|
+
nav.className = inClassName;
|
|
5
|
+
|
|
6
|
+
return nav;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const createOuterDiv = ({ inClassName }) => {
|
|
10
|
+
const outerDiv = document.createElement("div");
|
|
11
|
+
|
|
12
|
+
outerDiv.className = inClassName;
|
|
13
|
+
|
|
14
|
+
return outerDiv;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const createInnerDiv = ({ inClassName }) => {
|
|
18
|
+
const innerDiv = document.createElement("div");
|
|
19
|
+
|
|
20
|
+
innerDiv.className = inClassName;
|
|
21
|
+
|
|
22
|
+
return innerDiv;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const createBrand = ({ inTitleId, inTitle }) => {
|
|
26
|
+
const brand = document.createElement("div");
|
|
27
|
+
|
|
28
|
+
brand.className = "text-xl font-semibold";
|
|
29
|
+
brand.id = inTitleId || "titlehtmlId";
|
|
30
|
+
brand.innerText = inTitle || "KeshavSoft";
|
|
31
|
+
|
|
32
|
+
return brand;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const createMenu = ({ inUlClass }) => {
|
|
36
|
+
const menu = document.createElement("ul");
|
|
37
|
+
|
|
38
|
+
menu.id = "menu";
|
|
39
|
+
menu.className = `w-full hidden flex flex-col space-y-2 mt-4
|
|
40
|
+
md:flex md:flex-row md:space-y-0 md:gap-4
|
|
41
|
+
md:mt-0 md:w-auto md:flex-wrap ${inUlClass || ""}`;
|
|
42
|
+
|
|
43
|
+
return menu;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const createHamburger = ({ inMenu }) => {
|
|
47
|
+
const button = document.createElement("button");
|
|
48
|
+
|
|
49
|
+
button.className = "text-xl px-4 py-1 md:hidden";
|
|
50
|
+
button.innerText = "☰";
|
|
51
|
+
|
|
52
|
+
button.addEventListener("click", () => {
|
|
53
|
+
inMenu.classList.toggle("hidden");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return button;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const buildNav = ({ inElement }) => {
|
|
60
|
+
const nav = createNav({
|
|
61
|
+
inClassName: "bg-gray-800 text-white"
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
const outerDiv = createOuterDiv({
|
|
65
|
+
inClassName: `mx-auto px-3 py-3
|
|
66
|
+
max-w-3xl
|
|
67
|
+
lg:max-w-5xl
|
|
68
|
+
xl:max-w-full xl:px-10`
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const innerDiv = createInnerDiv({
|
|
72
|
+
inClassName: "flex flex-wrap items-center justify-between"
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const brand = createBrand({
|
|
76
|
+
inTitleId: inElement.getAttribute("ks-title-id"),
|
|
77
|
+
inTitle: inElement.getAttribute("ks-title")
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const menu = createMenu({
|
|
81
|
+
inUlClass: inElement.getAttribute("ks-ul-class")
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const button = createHamburger({
|
|
85
|
+
inMenu: menu
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
innerDiv.append(
|
|
89
|
+
brand,
|
|
90
|
+
button,
|
|
91
|
+
menu
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
outerDiv.appendChild(innerDiv);
|
|
95
|
+
nav.appendChild(outerDiv);
|
|
96
|
+
|
|
97
|
+
return nav;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
class KSNav extends HTMLElement {
|
|
101
|
+
connectedCallback() {
|
|
102
|
+
if (this.dataset.rendered === "true") return;
|
|
103
|
+
|
|
104
|
+
this.dataset.rendered = "true";
|
|
105
|
+
|
|
106
|
+
this.appendChild(
|
|
107
|
+
buildNav({
|
|
108
|
+
inElement: this
|
|
109
|
+
})
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
customElements.define(
|
|
115
|
+
"ks-nav",
|
|
116
|
+
KSNav
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
export default KSNav;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const createAnchor = ({
|
|
2
|
+
inHtmlId = "", inHref = "#", inClass = "", inTableName = ""
|
|
3
|
+
}) => {
|
|
4
|
+
const a = document.createElement("a");
|
|
5
|
+
|
|
6
|
+
a.id = inHtmlId;
|
|
7
|
+
a.href = inHref;
|
|
8
|
+
a.className = inClass;
|
|
9
|
+
|
|
10
|
+
if (inTableName) {
|
|
11
|
+
a.dataset.tableName = inTableName
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return a;
|
|
15
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import icons from "./icons.js";
|
|
2
|
+
|
|
3
|
+
export const createIcon = ({
|
|
4
|
+
inSvgName, inSvgDivClass = "size-6 flex items-center justify-center -----"
|
|
5
|
+
}) => {
|
|
6
|
+
if (inSvgName in icons) {
|
|
7
|
+
const icon = document
|
|
8
|
+
.createRange()
|
|
9
|
+
.createContextualFragment(icons[inSvgName])
|
|
10
|
+
.firstElementChild;
|
|
11
|
+
|
|
12
|
+
const div = document.createElement("div");
|
|
13
|
+
|
|
14
|
+
// div.className = "size-6 flex items-center justify-center";
|
|
15
|
+
div.className = inSvgDivClass;
|
|
16
|
+
// console.log("inSvgName----- : ", inSvgName, inSvgDivClass);
|
|
17
|
+
|
|
18
|
+
div.appendChild(icon);
|
|
19
|
+
|
|
20
|
+
return div;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return document
|
|
24
|
+
.createRange()
|
|
25
|
+
.createContextualFragment(icons.search)
|
|
26
|
+
.firstElementChild;
|
|
27
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// icons.js
|
|
2
|
+
export default {
|
|
3
|
+
serverStack: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
4
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M5.25 14.25h13.5m-13.5 0a3 3 0 0 1-3-3m3 3a3 3 0 1 0 0 6h13.5a3 3 0 1 0 0-6m-16.5-3a3 3 0 0 1 3-3h13.5a3 3 0 0 1 3 3m-19.5 0a4.5 4.5 0 0 1 .9-2.7L5.737 5.1a3.375 3.375 0 0 1 2.7-1.35h7.126c1.062 0 2.062.5 2.7 1.35l2.587 3.45a4.5 4.5 0 0 1 .9 2.7m0 0a3 3 0 0 1-3 3m0 3h.008v.008h-.008v-.008Zm0-6h.008v.008h-.008v-.008Zm-3 6h.008v.008h-.008v-.008Zm0-6h.008v.008h-.008v-.008Z" />
|
|
5
|
+
</svg>
|
|
6
|
+
`,
|
|
7
|
+
copy: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
8
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 0 0 2.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 0 0-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 0 0 .75-.75 2.25 2.25 0 0 0-.1-.664m-5.8 0A2.251 2.251 0 0 1 13.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25ZM6.75 12h.008v.008H6.75V12Zm0 3h.008v.008H6.75V15Zm0 3h.008v.008H6.75V18Z" />
|
|
9
|
+
</svg>
|
|
10
|
+
`,
|
|
11
|
+
puzzle: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-10">
|
|
12
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 0 1-.657.643 48.39 48.39 0 0 1-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 0 1-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 0 0-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 0 1-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 0 0 .657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 0 1-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 0 0 5.427-.63 48.05 48.05 0 0 0 .582-4.717.532.532 0 0 0-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 0 0 .658-.663 48.422 48.422 0 0 0-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 0 1-.61-.58v0Z" />
|
|
13
|
+
</svg>
|
|
14
|
+
`,
|
|
15
|
+
folderPlus: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-10">
|
|
16
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 10.5v6m3-3H9m4.06-7.19-2.12-2.12a1.5 1.5 0 0 0-1.061-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.379a1.5 1.5 0 0 1-1.06-.44Z" />
|
|
17
|
+
</svg>
|
|
18
|
+
`,
|
|
19
|
+
download: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
20
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 8.25H7.5a2.25 2.25 0 0 0-2.25 2.25v9a2.25 2.25 0 0 0 2.25 2.25h9a2.25 2.25 0 0 0 2.25-2.25v-9a2.25 2.25 0 0 0-2.25-2.25H15M9 12l3 3m0 0 3-3m-3 3V2.25" />
|
|
21
|
+
</svg>`,
|
|
22
|
+
search: `
|
|
23
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
24
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
|
25
|
+
</svg>
|
|
26
|
+
`,
|
|
27
|
+
home: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
28
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m2.25 12 8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25" />
|
|
29
|
+
</svg>
|
|
30
|
+
`,
|
|
31
|
+
serial: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
32
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M8.242 5.992h12m-12 6.003H20.24m-12 5.999h12M4.117 7.495v-3.75H2.99m1.125 3.75H2.99m1.125 0H5.24m-1.92 2.577a1.125 1.125 0 1 1 1.591 1.59l-1.83 1.83h2.16M2.99 15.745h1.125a1.125 1.125 0 0 1 0 2.25H3.74m0-.002h.375a1.125 1.125 0 0 1 0 2.25H2.99" />
|
|
33
|
+
</svg>
|
|
34
|
+
`,
|
|
35
|
+
currency: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
36
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M15 8.25H9m6 3H9m3 6-3-3h1.5a3 3 0 1 0 0-6M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
|
|
37
|
+
</svg>
|
|
38
|
+
`,
|
|
39
|
+
wifi: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
40
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M8.288 15.038a5.25 5.25 0 0 1 7.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0M12.53 18.22l-.53.53-.53-.53a.75.75 0 0 1 1.06 0Z" />
|
|
41
|
+
</svg>
|
|
42
|
+
`,
|
|
43
|
+
exclamation: `<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
44
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217 3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898 0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" />
|
|
45
|
+
</svg>
|
|
46
|
+
`,
|
|
47
|
+
search1: `
|
|
48
|
+
<div class="w-10 h-10 flex items-center justify-center">
|
|
49
|
+
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
50
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="m21 21-5.197-5.197m0 0A7.5 7.5 0 1 0 5.196 5.196a7.5 7.5 0 0 0 10.607 10.607Z" />
|
|
51
|
+
</svg>
|
|
52
|
+
</div>
|
|
53
|
+
`,
|
|
54
|
+
};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createAnchor } from "./createAnchor.js";
|
|
2
|
+
import { createIcon } from "./createIcon.js";
|
|
3
|
+
|
|
4
|
+
class KSMenuItem extends HTMLElement {
|
|
5
|
+
connectedCallback() {
|
|
6
|
+
const a = createAnchor({
|
|
7
|
+
inHtmlId: this.getAttribute("ks-id"),
|
|
8
|
+
inHref: this.getAttribute("ks-href"),
|
|
9
|
+
inTableName: this.getAttribute("ks-table-name"),
|
|
10
|
+
inClass: this.getAttribute("ks-class")
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const text = this.getAttribute("ks-textToShow") || "";
|
|
14
|
+
const className = this.getAttribute("ks-className") || "";
|
|
15
|
+
|
|
16
|
+
const svgName = this.getAttribute("ks-svgName") || "";
|
|
17
|
+
const svgDivClass = this.getAttribute("ks-svgDivClass") || "";
|
|
18
|
+
|
|
19
|
+
const svg = createIcon({
|
|
20
|
+
inSvgName: svgName,
|
|
21
|
+
inSvgDivClass: svgDivClass
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const span =
|
|
25
|
+
document.createElement("span");
|
|
26
|
+
|
|
27
|
+
span.textContent = text;
|
|
28
|
+
|
|
29
|
+
span.className = className;
|
|
30
|
+
|
|
31
|
+
while (this.firstChild) {
|
|
32
|
+
a.appendChild(
|
|
33
|
+
this.firstChild
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
a.append(
|
|
38
|
+
svg,
|
|
39
|
+
span
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
a.addEventListener("click", event => {
|
|
43
|
+
const menu = event.currentTarget
|
|
44
|
+
.closest("nav")
|
|
45
|
+
?.querySelector("#menu");
|
|
46
|
+
|
|
47
|
+
// console.log("menu : ", menu);
|
|
48
|
+
|
|
49
|
+
menu?.classList.add("hidden");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
this.appendChild(a);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
customElements.define(
|
|
57
|
+
"ks-menu-item",
|
|
58
|
+
KSMenuItem
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
export default {};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
const createNav = ({ inClassName }) => {
|
|
2
|
+
const nav = document.createElement("nav");
|
|
3
|
+
|
|
4
|
+
nav.className = inClassName;
|
|
5
|
+
|
|
6
|
+
return nav;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const createOuterDiv = ({ inClassName }) => {
|
|
10
|
+
const outerDiv = document.createElement("div");
|
|
11
|
+
|
|
12
|
+
outerDiv.className = inClassName;
|
|
13
|
+
|
|
14
|
+
return outerDiv;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const createInnerDiv = ({ inClassName }) => {
|
|
18
|
+
const innerDiv = document.createElement("div");
|
|
19
|
+
|
|
20
|
+
innerDiv.className = inClassName;
|
|
21
|
+
|
|
22
|
+
return innerDiv;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const getAttributeValue = ({ inElement, inName, inDefaultValue }) => {
|
|
26
|
+
const value = inElement.getAttribute(inName);
|
|
27
|
+
|
|
28
|
+
if (value === null) return inDefaultValue;
|
|
29
|
+
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const createBrand = ({ inTitleId, inTitle, inClassName }) => {
|
|
34
|
+
const brand = document.createElement("div");
|
|
35
|
+
|
|
36
|
+
brand.className = inClassName;
|
|
37
|
+
brand.id = inTitleId || "titlehtmlId";
|
|
38
|
+
brand.innerText = inTitle || "KeshavSoft";
|
|
39
|
+
|
|
40
|
+
return brand;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const createMenu = ({ inClassName, inUlClass }) => {
|
|
44
|
+
const menu = document.createElement("ul");
|
|
45
|
+
|
|
46
|
+
menu.id = "menu";
|
|
47
|
+
menu.className = `${inClassName} ${inUlClass || ""}`;
|
|
48
|
+
|
|
49
|
+
return menu;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const createHamburger = ({ inMenu, inClassName }) => {
|
|
53
|
+
const button = document.createElement("button");
|
|
54
|
+
|
|
55
|
+
button.className = inClassName;
|
|
56
|
+
button.innerText = "☰";
|
|
57
|
+
|
|
58
|
+
button.addEventListener("click", () => {
|
|
59
|
+
inMenu.classList.toggle("hidden");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
return button;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const buildNav = ({ inElement }) => {
|
|
66
|
+
const nav = createNav({
|
|
67
|
+
inClassName: getAttributeValue({
|
|
68
|
+
inElement,
|
|
69
|
+
inName: "ks-nav-class",
|
|
70
|
+
inDefaultValue: "bg-gray-800 text-white"
|
|
71
|
+
})
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
const outerDiv = createOuterDiv({
|
|
75
|
+
inClassName: getAttributeValue({
|
|
76
|
+
inElement,
|
|
77
|
+
inName: "ks-outer-class",
|
|
78
|
+
inDefaultValue: `mx-auto px-3 py-3
|
|
79
|
+
max-w-3xl
|
|
80
|
+
lg:max-w-5xl
|
|
81
|
+
xl:max-w-full xl:px-10`
|
|
82
|
+
})
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const innerDiv = createInnerDiv({
|
|
86
|
+
inClassName: getAttributeValue({
|
|
87
|
+
inElement,
|
|
88
|
+
inName: "ks-inner-class",
|
|
89
|
+
inDefaultValue: "flex flex-wrap items-center justify-between"
|
|
90
|
+
})
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const brand = createBrand({
|
|
94
|
+
inTitleId: inElement.getAttribute("ks-title-id"),
|
|
95
|
+
inTitle: inElement.getAttribute("ks-title"),
|
|
96
|
+
inClassName: getAttributeValue({
|
|
97
|
+
inElement,
|
|
98
|
+
inName: "ks-brand-class",
|
|
99
|
+
inDefaultValue: "text-xl font-semibold"
|
|
100
|
+
})
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const menu = createMenu({
|
|
104
|
+
inClassName: getAttributeValue({
|
|
105
|
+
inElement,
|
|
106
|
+
inName: "ks-menu-class",
|
|
107
|
+
inDefaultValue: `w-full hidden flex flex-col space-y-2 mt-4
|
|
108
|
+
md:flex md:flex-row md:space-y-0 md:gap-4
|
|
109
|
+
md:mt-0 md:w-auto md:flex-wrap`
|
|
110
|
+
}),
|
|
111
|
+
inUlClass: inElement.getAttribute("ks-ul-class")
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const button = createHamburger({
|
|
115
|
+
inMenu: menu,
|
|
116
|
+
inClassName: getAttributeValue({
|
|
117
|
+
inElement,
|
|
118
|
+
inName: "ks-button-class",
|
|
119
|
+
inDefaultValue: "text-xl px-4 py-1 md:hidden"
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
innerDiv.append(
|
|
124
|
+
brand,
|
|
125
|
+
button,
|
|
126
|
+
menu
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
outerDiv.appendChild(innerDiv);
|
|
130
|
+
nav.appendChild(outerDiv);
|
|
131
|
+
|
|
132
|
+
return nav;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
class KSNav extends HTMLElement {
|
|
136
|
+
connectedCallback() {
|
|
137
|
+
if (this.dataset.rendered === "true") return;
|
|
138
|
+
|
|
139
|
+
this.dataset.rendered = "true";
|
|
140
|
+
|
|
141
|
+
this.appendChild(
|
|
142
|
+
buildNav({
|
|
143
|
+
inElement: this
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
customElements.define(
|
|
150
|
+
"ks-nav",
|
|
151
|
+
KSNav
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
export default KSNav;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export const createAnchor = ({
|
|
2
|
+
inHtmlId = "", inHref = "#", inClass = "", inTableName = ""
|
|
3
|
+
}) => {
|
|
4
|
+
const a = document.createElement("a");
|
|
5
|
+
|
|
6
|
+
a.id = inHtmlId;
|
|
7
|
+
a.href = inHref;
|
|
8
|
+
a.className = inClass;
|
|
9
|
+
|
|
10
|
+
if (inTableName) {
|
|
11
|
+
a.dataset.tableName = inTableName
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return a;
|
|
15
|
+
};
|