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,31 @@
|
|
|
1
|
+
import composeNavigationStory from "./composeNavigationStory.js";
|
|
2
|
+
import navDefaults from "./navDefaults.js";
|
|
3
|
+
import navUsage from "./navUsage.js";
|
|
4
|
+
|
|
5
|
+
class KSNav extends HTMLElement {
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
if (this.dataset.rendered === "true") return;
|
|
8
|
+
|
|
9
|
+
this.dataset.rendered = "true";
|
|
10
|
+
|
|
11
|
+
this.appendChild(
|
|
12
|
+
composeNavigationStory({
|
|
13
|
+
inElement: this
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
KSNav.defaults = navDefaults;
|
|
20
|
+
KSNav.usage = navUsage;
|
|
21
|
+
|
|
22
|
+
customElements.define(
|
|
23
|
+
"ks-nav",
|
|
24
|
+
KSNav
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export default KSNav;
|
|
28
|
+
export {
|
|
29
|
+
navDefaults,
|
|
30
|
+
navUsage
|
|
31
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const navDefaults = {
|
|
2
|
+
navClass: "bg-gray-800 text-white",
|
|
3
|
+
outerClass: `mx-auto px-3 py-3
|
|
4
|
+
max-w-3xl
|
|
5
|
+
lg:max-w-5xl
|
|
6
|
+
xl:max-w-full xl:px-10`,
|
|
7
|
+
innerClass: "flex flex-wrap items-center justify-between",
|
|
8
|
+
brandClass: "text-xl font-semibold",
|
|
9
|
+
menuClass: `w-full hidden flex flex-col space-y-2 mt-4
|
|
10
|
+
md:flex md:flex-row md:space-y-0 md:gap-4
|
|
11
|
+
md:mt-0 md:w-auto md:flex-wrap`,
|
|
12
|
+
buttonClass: "text-xl px-4 py-1 md:hidden"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default navDefaults;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import navDefaults from "./navDefaults.js";
|
|
2
|
+
|
|
3
|
+
const navUsage = {
|
|
4
|
+
tagName: "ks-nav",
|
|
5
|
+
attributes: {
|
|
6
|
+
title: {
|
|
7
|
+
name: "ks-title",
|
|
8
|
+
defaultValue: "KeshavSoft"
|
|
9
|
+
},
|
|
10
|
+
titleId: {
|
|
11
|
+
name: "ks-title-id",
|
|
12
|
+
defaultValue: "titlehtmlId"
|
|
13
|
+
},
|
|
14
|
+
navClass: {
|
|
15
|
+
name: "ks-nav-class",
|
|
16
|
+
defaultValue: navDefaults.navClass
|
|
17
|
+
},
|
|
18
|
+
outerClass: {
|
|
19
|
+
name: "ks-outer-class",
|
|
20
|
+
defaultValue: navDefaults.outerClass
|
|
21
|
+
},
|
|
22
|
+
innerClass: {
|
|
23
|
+
name: "ks-inner-class",
|
|
24
|
+
defaultValue: navDefaults.innerClass
|
|
25
|
+
},
|
|
26
|
+
brandClass: {
|
|
27
|
+
name: "ks-brand-class",
|
|
28
|
+
defaultValue: navDefaults.brandClass
|
|
29
|
+
},
|
|
30
|
+
menuClass: {
|
|
31
|
+
name: "ks-menu-class",
|
|
32
|
+
defaultValue: navDefaults.menuClass
|
|
33
|
+
},
|
|
34
|
+
menuExtraClass: {
|
|
35
|
+
name: "ks-ul-class",
|
|
36
|
+
defaultValue: ""
|
|
37
|
+
},
|
|
38
|
+
buttonClass: {
|
|
39
|
+
name: "ks-button-class",
|
|
40
|
+
defaultValue: navDefaults.buttonClass
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default navUsage;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import navDefaults from "./navDefaults.js";
|
|
2
|
+
import readAttributeOrDefault from "./readAttributeOrDefault.js";
|
|
3
|
+
|
|
4
|
+
const readNavStoryFromElement = ({ inElement }) => {
|
|
5
|
+
return {
|
|
6
|
+
navClass: readAttributeOrDefault({
|
|
7
|
+
inElement,
|
|
8
|
+
inName: "ks-nav-class",
|
|
9
|
+
inDefaultValue: navDefaults.navClass
|
|
10
|
+
}),
|
|
11
|
+
outerClass: readAttributeOrDefault({
|
|
12
|
+
inElement,
|
|
13
|
+
inName: "ks-outer-class",
|
|
14
|
+
inDefaultValue: navDefaults.outerClass
|
|
15
|
+
}),
|
|
16
|
+
innerClass: readAttributeOrDefault({
|
|
17
|
+
inElement,
|
|
18
|
+
inName: "ks-inner-class",
|
|
19
|
+
inDefaultValue: navDefaults.innerClass
|
|
20
|
+
}),
|
|
21
|
+
titleId: inElement.getAttribute("ks-title-id"),
|
|
22
|
+
title: inElement.getAttribute("ks-title"),
|
|
23
|
+
brandClass: readAttributeOrDefault({
|
|
24
|
+
inElement,
|
|
25
|
+
inName: "ks-brand-class",
|
|
26
|
+
inDefaultValue: navDefaults.brandClass
|
|
27
|
+
}),
|
|
28
|
+
menuClass: readAttributeOrDefault({
|
|
29
|
+
inElement,
|
|
30
|
+
inName: "ks-menu-class",
|
|
31
|
+
inDefaultValue: navDefaults.menuClass
|
|
32
|
+
}),
|
|
33
|
+
menuExtraClass: inElement.getAttribute("ks-ul-class"),
|
|
34
|
+
buttonClass: readAttributeOrDefault({
|
|
35
|
+
inElement,
|
|
36
|
+
inName: "ks-button-class",
|
|
37
|
+
inDefaultValue: navDefaults.buttonClass
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default readNavStoryFromElement;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import "./WebComponents/v6/menuItem/index.js";
|
|
2
|
+
import "./WebComponents/v6/nav/index.js";
|
|
3
|
+
|
|
4
|
+
import { buildMenuItem } from "./BuildMenuItem/buildMenuItem.js";
|
|
5
|
+
import { buildNav } from "./BuildNav/buildNav.js";
|
|
6
|
+
|
|
7
|
+
const initHeader = (config = {}) => {
|
|
8
|
+
|
|
9
|
+
const header = document.getElementById("header");
|
|
10
|
+
|
|
11
|
+
if (!header) return;
|
|
12
|
+
|
|
13
|
+
header.appendChild(
|
|
14
|
+
buildNav({
|
|
15
|
+
inTitle: config.title,
|
|
16
|
+
inUiClasses: config.uiClasses
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const menu = document.getElementById("menu");
|
|
21
|
+
|
|
22
|
+
(config.items || []).forEach(item => {
|
|
23
|
+
|
|
24
|
+
const classes = {
|
|
25
|
+
liClass: "md:text-center",
|
|
26
|
+
|
|
27
|
+
aClass: `${item?.uiClasses?.aClass} flex justify-between items-center
|
|
28
|
+
bg-gray-700 px-4 py-2 rounded-md
|
|
29
|
+
hover:bg-gray-600
|
|
30
|
+
active:bg-gray-500 active:scale-95
|
|
31
|
+
transition-all duration-150
|
|
32
|
+
md:flex-col md:justify-center md:items-center
|
|
33
|
+
lg:bg-transparent lg:px-2 lg:py-1`,
|
|
34
|
+
|
|
35
|
+
spanClass: `ml-3 text-right w-full text-base
|
|
36
|
+
md:w-auto md:text-center md:ml-0 lg:text-lg`,
|
|
37
|
+
|
|
38
|
+
svgClass: item?.uiClasses?.svgDivClass || "text-gray-300 w-6 h-6 lg:w-7 lg:h-7"
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const li = buildMenuItem({
|
|
42
|
+
inTextToShow: item.text,
|
|
43
|
+
inHtmlId: item.id,
|
|
44
|
+
inIconPaths: item.icon,
|
|
45
|
+
inHref: item.href,
|
|
46
|
+
onClick: item.onClick,
|
|
47
|
+
inTableName: item.tableName,
|
|
48
|
+
inClasses: classes,
|
|
49
|
+
inSvgName: item.svgName,
|
|
50
|
+
inConfigUiClasses: config.uiClasses
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
menu.appendChild(li);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
window.KSHeader = initHeader;
|
|
58
|
+
|
|
59
|
+
console.log("KSHeader v8 loaded to DOM");
|
|
60
|
+
|
|
61
|
+
export default initHeader;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import createBrandTitle from "./createBrandTitle.js";
|
|
2
|
+
import createMenuList from "./createMenuList.js";
|
|
3
|
+
import createMenuToggleButton from "./createMenuToggleButton.js";
|
|
4
|
+
import createNavigationBar from "./createNavigationBar.js";
|
|
5
|
+
import createNavigationRow from "./createNavigationRow.js";
|
|
6
|
+
import createNavigationWrapper from "./createNavigationWrapper.js";
|
|
7
|
+
import readNavStoryFromElement from "./readNavStoryFromElement.js";
|
|
8
|
+
|
|
9
|
+
const composeNavigationStory = ({ inElement }) => {
|
|
10
|
+
const story = readNavStoryFromElement({
|
|
11
|
+
inElement
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const nav = createNavigationBar({
|
|
15
|
+
inClassName: story.navClass
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const wrapper = createNavigationWrapper({
|
|
19
|
+
inClassName: story.outerClass
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const row = createNavigationRow({
|
|
23
|
+
inClassName: story.innerClass
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const brand = createBrandTitle({
|
|
27
|
+
inTitleId: story.titleId,
|
|
28
|
+
inTitle: story.title,
|
|
29
|
+
inClassName: story.brandClass
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const menu = createMenuList({
|
|
33
|
+
inClassName: story.menuClass,
|
|
34
|
+
inExtraClass: story.menuExtraClass
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const toggleButton = createMenuToggleButton({
|
|
38
|
+
inMenu: menu,
|
|
39
|
+
inClassName: story.buttonClass
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
row.append(
|
|
43
|
+
brand,
|
|
44
|
+
toggleButton,
|
|
45
|
+
menu
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
wrapper.appendChild(row);
|
|
49
|
+
nav.appendChild(wrapper);
|
|
50
|
+
|
|
51
|
+
return nav;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default composeNavigationStory;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const createBrandTitle = ({ inTitleId, inTitle, inClassName }) => {
|
|
2
|
+
const brand = document.createElement("div");
|
|
3
|
+
|
|
4
|
+
brand.className = inClassName;
|
|
5
|
+
brand.id = inTitleId || "titlehtmlId";
|
|
6
|
+
brand.innerText = inTitle || "KeshavSoft";
|
|
7
|
+
|
|
8
|
+
return brand;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default createBrandTitle;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const createMenuToggleButton = ({ inMenu, inClassName }) => {
|
|
2
|
+
const button = document.createElement("button");
|
|
3
|
+
|
|
4
|
+
button.className = inClassName;
|
|
5
|
+
button.innerText = "☰";
|
|
6
|
+
|
|
7
|
+
button.addEventListener("click", () => {
|
|
8
|
+
inMenu.classList.toggle("hidden");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return button;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default createMenuToggleButton;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import composeNavigationStory from "./composeNavigationStory.js";
|
|
2
|
+
import navDefaults from "./navDefaults.js";
|
|
3
|
+
import navUsage from "./navUsage.js";
|
|
4
|
+
|
|
5
|
+
class KSNav extends HTMLElement {
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
if (this.dataset.rendered === "true") return;
|
|
8
|
+
|
|
9
|
+
this.dataset.rendered = "true";
|
|
10
|
+
|
|
11
|
+
this.appendChild(
|
|
12
|
+
composeNavigationStory({
|
|
13
|
+
inElement: this
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
KSNav.defaults = navDefaults;
|
|
20
|
+
KSNav.usage = navUsage;
|
|
21
|
+
|
|
22
|
+
customElements.define(
|
|
23
|
+
"ks-nav",
|
|
24
|
+
KSNav
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export default KSNav;
|
|
28
|
+
export {
|
|
29
|
+
navDefaults,
|
|
30
|
+
navUsage
|
|
31
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const navDefaults = {
|
|
2
|
+
navClass: "bg-gray-800 text-white",
|
|
3
|
+
outerClass: `mx-auto px-3 py-3
|
|
4
|
+
max-w-3xl
|
|
5
|
+
lg:max-w-5xl
|
|
6
|
+
xl:max-w-full xl:px-10`,
|
|
7
|
+
innerClass: "flex flex-wrap items-center justify-between",
|
|
8
|
+
brandClass: "text-xl font-semibold",
|
|
9
|
+
menuClass: `w-full hidden flex flex-col space-y-2 mt-4
|
|
10
|
+
md:flex md:flex-row md:space-y-0 md:gap-4
|
|
11
|
+
md:mt-0 md:w-auto md:flex-wrap`,
|
|
12
|
+
buttonClass: "text-xl px-4 py-1 md:hidden"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default navDefaults;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import navDefaults from "./navDefaults.js";
|
|
2
|
+
|
|
3
|
+
const navUsage = {
|
|
4
|
+
tagName: "ks-nav",
|
|
5
|
+
attributes: {
|
|
6
|
+
title: {
|
|
7
|
+
name: "ks-title",
|
|
8
|
+
defaultValue: "KeshavSoft"
|
|
9
|
+
},
|
|
10
|
+
titleId: {
|
|
11
|
+
name: "ks-title-id",
|
|
12
|
+
defaultValue: "titlehtmlId"
|
|
13
|
+
},
|
|
14
|
+
navClass: {
|
|
15
|
+
name: "ks-nav-class",
|
|
16
|
+
defaultValue: navDefaults.navClass
|
|
17
|
+
},
|
|
18
|
+
outerClass: {
|
|
19
|
+
name: "ks-outer-class",
|
|
20
|
+
defaultValue: navDefaults.outerClass
|
|
21
|
+
},
|
|
22
|
+
innerClass: {
|
|
23
|
+
name: "ks-inner-class",
|
|
24
|
+
defaultValue: navDefaults.innerClass
|
|
25
|
+
},
|
|
26
|
+
brandClass: {
|
|
27
|
+
name: "ks-brand-class",
|
|
28
|
+
defaultValue: navDefaults.brandClass
|
|
29
|
+
},
|
|
30
|
+
menuClass: {
|
|
31
|
+
name: "ks-menu-class",
|
|
32
|
+
defaultValue: navDefaults.menuClass
|
|
33
|
+
},
|
|
34
|
+
menuExtraClass: {
|
|
35
|
+
name: "ks-ul-class",
|
|
36
|
+
defaultValue: ""
|
|
37
|
+
},
|
|
38
|
+
buttonClass: {
|
|
39
|
+
name: "ks-button-class",
|
|
40
|
+
defaultValue: navDefaults.buttonClass
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default navUsage;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import navDefaults from "./navDefaults.js";
|
|
2
|
+
import readAttributeOrDefault from "./readAttributeOrDefault.js";
|
|
3
|
+
|
|
4
|
+
const readNavStoryFromElement = ({ inElement }) => {
|
|
5
|
+
return {
|
|
6
|
+
navClass: readAttributeOrDefault({
|
|
7
|
+
inElement,
|
|
8
|
+
inName: "ks-nav-class",
|
|
9
|
+
inDefaultValue: navDefaults.navClass
|
|
10
|
+
}),
|
|
11
|
+
outerClass: readAttributeOrDefault({
|
|
12
|
+
inElement,
|
|
13
|
+
inName: "ks-outer-class",
|
|
14
|
+
inDefaultValue: navDefaults.outerClass
|
|
15
|
+
}),
|
|
16
|
+
innerClass: readAttributeOrDefault({
|
|
17
|
+
inElement,
|
|
18
|
+
inName: "ks-inner-class",
|
|
19
|
+
inDefaultValue: navDefaults.innerClass
|
|
20
|
+
}),
|
|
21
|
+
titleId: inElement.getAttribute("ks-title-id"),
|
|
22
|
+
title: inElement.getAttribute("ks-title"),
|
|
23
|
+
brandClass: readAttributeOrDefault({
|
|
24
|
+
inElement,
|
|
25
|
+
inName: "ks-brand-class",
|
|
26
|
+
inDefaultValue: navDefaults.brandClass
|
|
27
|
+
}),
|
|
28
|
+
menuClass: readAttributeOrDefault({
|
|
29
|
+
inElement,
|
|
30
|
+
inName: "ks-menu-class",
|
|
31
|
+
inDefaultValue: navDefaults.menuClass
|
|
32
|
+
}),
|
|
33
|
+
menuExtraClass: inElement.getAttribute("ks-ul-class"),
|
|
34
|
+
buttonClass: readAttributeOrDefault({
|
|
35
|
+
inElement,
|
|
36
|
+
inName: "ks-button-class",
|
|
37
|
+
inDefaultValue: navDefaults.buttonClass
|
|
38
|
+
})
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default readNavStoryFromElement;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import createBrandTitle from "./createBrandTitle.js";
|
|
2
|
+
import createMenuList from "./createMenuList.js";
|
|
3
|
+
import createMenuToggleButton from "./createMenuToggleButton.js";
|
|
4
|
+
import createNavigationBar from "./createNavigationBar.js";
|
|
5
|
+
import createNavigationRow from "./createNavigationRow.js";
|
|
6
|
+
import createNavigationWrapper from "./createNavigationWrapper.js";
|
|
7
|
+
import readNavStoryFromElement from "./readNavStoryFromElement.js";
|
|
8
|
+
|
|
9
|
+
const composeNavigationStory = ({ inElement }) => {
|
|
10
|
+
const story = readNavStoryFromElement({
|
|
11
|
+
inElement
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const nav = createNavigationBar({
|
|
15
|
+
inClassName: story.navClass
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const wrapper = createNavigationWrapper({
|
|
19
|
+
inClassName: story.outerClass
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const row = createNavigationRow({
|
|
23
|
+
inClassName: story.innerClass
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const brand = createBrandTitle({
|
|
27
|
+
inTitleId: story.titleId,
|
|
28
|
+
inTitle: story.title,
|
|
29
|
+
inClassName: story.brandClass
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const menu = createMenuList({
|
|
33
|
+
inClassName: story.menuClass,
|
|
34
|
+
inExtraClass: story.menuExtraClass
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const toggleButton = createMenuToggleButton({
|
|
38
|
+
inMenu: menu,
|
|
39
|
+
inClassName: story.buttonClass
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
row.append(
|
|
43
|
+
brand,
|
|
44
|
+
toggleButton,
|
|
45
|
+
menu
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
wrapper.appendChild(row);
|
|
49
|
+
nav.appendChild(wrapper);
|
|
50
|
+
|
|
51
|
+
return nav;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default composeNavigationStory;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const createBrandTitle = ({ inTitleId, inTitle, inClassName }) => {
|
|
2
|
+
const brand = document.createElement("div");
|
|
3
|
+
|
|
4
|
+
brand.className = inClassName;
|
|
5
|
+
brand.id = inTitleId || "titlehtmlId";
|
|
6
|
+
brand.innerText = inTitle || "KeshavSoft";
|
|
7
|
+
|
|
8
|
+
return brand;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default createBrandTitle;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const createMenuToggleButton = ({ inMenu, inClassName }) => {
|
|
2
|
+
const button = document.createElement("button");
|
|
3
|
+
|
|
4
|
+
button.className = inClassName;
|
|
5
|
+
button.innerText = "☰";
|
|
6
|
+
|
|
7
|
+
button.addEventListener("click", () => {
|
|
8
|
+
inMenu.classList.toggle("hidden");
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
return button;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default createMenuToggleButton;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import composeNavigationStory from "./composeNavigationStory.js";
|
|
2
|
+
// import navDefaults from "./navDefaults.js";
|
|
3
|
+
// import navUsage from "./navUsage.js";
|
|
4
|
+
|
|
5
|
+
class KSNav extends HTMLElement {
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
if (this.dataset.rendered === "true") return;
|
|
8
|
+
|
|
9
|
+
this.dataset.rendered = "true";
|
|
10
|
+
|
|
11
|
+
this.appendChild(
|
|
12
|
+
composeNavigationStory({
|
|
13
|
+
inElement: this
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// KSNav.defaults = navDefaults;
|
|
20
|
+
// KSNav.usage = navUsage;
|
|
21
|
+
|
|
22
|
+
customElements.define(
|
|
23
|
+
"ks-nav",
|
|
24
|
+
KSNav
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
// export default KSNav;
|
|
28
|
+
// export {
|
|
29
|
+
// navDefaults,
|
|
30
|
+
// navUsage
|
|
31
|
+
// };
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export default {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const navDefaults = {
|
|
2
|
+
navClass: "bg-gray-800 text-white",
|
|
3
|
+
outerClass: `mx-auto px-3 py-3
|
|
4
|
+
max-w-3xl
|
|
5
|
+
lg:max-w-5xl
|
|
6
|
+
xl:max-w-full xl:px-10`,
|
|
7
|
+
innerClass: "flex flex-wrap items-center justify-between",
|
|
8
|
+
brandClass: "text-xl font-semibold",
|
|
9
|
+
menuClass: `w-full hidden flex flex-col space-y-2 mt-4
|
|
10
|
+
md:flex md:flex-row md:space-y-0 md:gap-4
|
|
11
|
+
md:mt-0 md:w-auto md:flex-wrap`,
|
|
12
|
+
buttonClass: "text-xl px-4 py-1 md:hidden"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export default navDefaults;
|