Skip to content

Commit fc4b80b

Browse files
committed
function dropdown and hide
1 parent d341c30 commit fc4b80b

3 files changed

Lines changed: 73 additions & 27 deletions

File tree

web-components/nav-header/nav-header.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,11 @@ input {
214214

215215
.icon-right {
216216
display: none !important;
217+
transform: rotate(0deg);
217218
}
218219

219-
.icon-down {
220-
display: none !important;
220+
.icon-right:hover {
221+
color: #71a3e9;
221222
}
222223

223224
/* 768px and below screen sizes */

web-components/nav-header/nav-header.html

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,8 @@ <h4>IBM <b>IMS Central</b></h4>
6464

6565
<section class="dropdown-menu">
6666
<div class="menu">
67-
<div class="learn">
67+
<div class="learn-section">
6868
<span class="subheader">
69-
<i
70-
class="fa fa-angle-down icon-down"
71-
tabindex="0"
72-
style="font-size: 24px"
73-
></i>
7469
<i
7570
class="fa fa-angle-right icon-right"
7671
tabindex="0"
@@ -116,8 +111,15 @@ <h5>
116111
<p>Learn about the latest IMS features and offerings.</p>
117112
</a>
118113
</div>
119-
<div class="innovate">
120-
<h3>Innovate</h3>
114+
<div class="innovate-section">
115+
<span class="subheader">
116+
<i
117+
class="fa fa-angle-right icon-right"
118+
tabindex="0"
119+
style="font-size: 24px"
120+
></i>
121+
<h3>Innovate</h3>
122+
</span>
121123
<a href="ims-apis.html" tabindex="-1">
122124
<h5>APIs</h5>
123125
<p>
@@ -145,8 +147,15 @@ <h5>IMS Transaction Manager</h5>
145147
<p>IMS Transaction Manager: fast, secure, connected.</p>
146148
</a>
147149
</div>
148-
<div class="engage">
149-
<h3>Engage</h3>
150+
<div class="engage-section">
151+
<span class="subheader">
152+
<i
153+
class="fa fa-angle-right icon-right"
154+
tabindex="0"
155+
style="font-size: 24px"
156+
></i>
157+
<h3>Engage</h3>
158+
</span>
150159
<a href="ims-gold.html" tabindex="-1">
151160
<h5>IMS Gold</h5>
152161
<p>
@@ -204,8 +213,15 @@ <h5>
204213
<p>A place to connect with other IMS developers.</p>
205214
</a>
206215
</div>
207-
<div class="support">
208-
<h3>Documentation & support</h3>
216+
<div class="support-section">
217+
<span class="subheader">
218+
<i
219+
class="fa fa-angle-right icon-right"
220+
tabindex="0"
221+
style="font-size: 24px"
222+
></i>
223+
<h3>Documentation & support</h3>
224+
</span>
209225
<a href="ims-docs.html" tabindex="-1">
210226
<h5>Documentation</h5>
211227
<p>Find information on IMS, tools, and other IBM products.</p>

web-components/nav-header/nav-header.js

Lines changed: 42 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function createComponent(html) {
3838
const menuItems = dropdownMenu.querySelectorAll("a");
3939
const documentationMenuItem = menuItems[menuItems.length - 2];
4040
const supportMenuItem = menuItems[menuItems.length - 1];
41-
const subheaders = shadow.querySelectorAll(".subheader");
41+
4242
// Search
4343
const searchForm = shadow.getElementById("search-form");
4444
const searchInput = shadow.getElementById("search-input");
@@ -68,19 +68,48 @@ function createComponent(html) {
6868
}
6969
});
7070

71-
const learnSubheader = subheaders[0];
72-
learnSubheader.addEventListener("click", () => {
73-
const icon = learnSubheader.querySelector("i");
74-
icon.style.display = "none";
75-
});
71+
// Dropdown sections for small screens
72+
const dropdownSections = [
73+
"learn-section",
74+
"innovate-section",
75+
"engage-section",
76+
"support-section",
77+
];
78+
for (let section of dropdownSections) {
79+
const sectionDiv = shadow.querySelector("." + section);
80+
const subheader = sectionDiv.querySelector(".subheader");
81+
const dropdownArrow = subheader.querySelector(".icon-right");
82+
const sectionContent = sectionDiv.querySelectorAll("a");
83+
84+
subheader.addEventListener("click", () => {
85+
console.log(dropdownArrow.style.transform);
86+
if (
87+
dropdownArrow.style.transform == "rotate(0deg)" ||
88+
dropdownArrow.style.transform == ""
89+
) {
90+
dropdownArrow.style.transform = "rotate(90deg)";
91+
for (let contentItem of sectionContent) {
92+
contentItem.style.display = "block";
93+
}
94+
} else {
95+
dropdownArrow.style.transform = "rotate(0deg)";
96+
for (let contentItem of sectionContent) {
97+
contentItem.style.display = "none";
98+
}
99+
}
100+
});
101+
}
76102

77-
// Toggle show section for small screens
78-
// for (let subheader in subheaders) {
79-
// subheader.addEventListener("click", () => {
80-
// arrow.classList.remove("fa-angle-right");
81-
// arrow.classList.add("fa-angle-down");
82-
// });
83-
// }
103+
// const learnSection = shadow.querySelector(".learn-section");
104+
// const learnSubheader = learnSection.querySelector(".subheader");
105+
// const dropdownArrow = learnSubheader.querySelector(".icon-right");
106+
// const learnContent = learnSection.querySelectorAll("a");
107+
// learnSubheader.addEventListener("click", () => {
108+
// dropdownArrow.style.transform = "rotate(90deg)";
109+
// for (let contentItem of learnContent) {
110+
// contentItem.style.display = "block";
111+
// }
112+
// });
84113

85114
// Event listeners for all menus
86115
// --------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)