@@ -40,6 +40,7 @@ function createComponent(html) {
4040 const menuItems = dropdownMenu . querySelectorAll ( "a" ) ;
4141 const documentationMenuItem = menuItems [ menuItems . length - 2 ] ;
4242 const supportMenuItem = menuItems [ menuItems . length - 1 ] ;
43+
4344 // Search
4445 const searchForm = shadow . getElementById ( "search-form" ) ;
4546 const searchInput = shadow . getElementById ( "search-input" ) ;
@@ -70,6 +71,59 @@ function createComponent(html) {
7071 }
7172 } ) ;
7273
74+ // Dropdown sections for small screens
75+ const dropdownSections = [
76+ "learn-section" ,
77+ "innovate-section" ,
78+ "engage-section" ,
79+ "support-section" ,
80+ ] ;
81+ for ( let section of dropdownSections ) {
82+ const sectionDiv = shadow . querySelector ( "." + section ) ;
83+ const subheader = sectionDiv . querySelector ( ".subheader" ) ;
84+ const dropdownArrow = subheader . querySelector ( ".icon-right" ) ;
85+ const sectionContent = sectionDiv . querySelectorAll ( "a" ) ;
86+
87+ subheader . addEventListener ( "click" , ( ) => {
88+ if (
89+ dropdownArrow . style . transform == "rotate(0deg)" ||
90+ dropdownArrow . style . transform == ""
91+ ) {
92+ toggleSectionDropdown (
93+ dropdownArrow ,
94+ "rotate(90deg)" ,
95+ sectionContent ,
96+ "block"
97+ ) ;
98+ } else {
99+ toggleSectionDropdown (
100+ dropdownArrow ,
101+ "rotate(0deg)" ,
102+ sectionContent ,
103+ "none"
104+ ) ;
105+ }
106+ } ) ;
107+
108+ window . addEventListener ( "resize" , ( ) => {
109+ if ( window . innerWidth > 768 ) {
110+ toggleSectionDropdown (
111+ dropdownArrow ,
112+ "rotate(0deg)" ,
113+ sectionContent ,
114+ "block"
115+ ) ;
116+ } else {
117+ toggleSectionDropdown (
118+ dropdownArrow ,
119+ "rotate(0deg)" ,
120+ sectionContent ,
121+ "none"
122+ ) ;
123+ }
124+ } ) ;
125+ }
126+
73127 // Event listeners for all menus
74128 // --------------------------------------------------------------------------------------------------
75129 // Hide dropdowns when user clicks outside of search results or nav menu
@@ -82,7 +136,6 @@ function createComponent(html) {
82136
83137 // Event listeners for search
84138 // --------------------------------------------------------------------------------------------------
85-
86139 // Toggle open search bar (small screens)
87140 searchIcon . addEventListener ( "click" , ( ) => {
88141 if ( window . innerWidth <= 1023 ) {
@@ -161,6 +214,14 @@ function createComponent(html) {
161214
162215 // Helper functions
163216 // --------------------------------------------------------------------------------------------------
217+ // Toggle dropdown sections for small screens in dropdown nav menu
218+ function toggleSectionDropdown ( arrow , deg , section , displayState ) {
219+ arrow . style . transform = deg ;
220+ for ( let contentItem of section ) {
221+ contentItem . style . display = displayState ;
222+ }
223+ }
224+
164225 // Toggle dropdown navigation menu
165226 function toggleMenu ( ) {
166227 dropdownMenu . classList . toggle ( "show-menu" ) ;
@@ -205,7 +266,7 @@ function createComponent(html) {
205266 desc . classList . toggle ( "search_content_drop" ) ;
206267 }
207268
208- // Open search bar
269+ // Open search bar (small screens)
209270 function openSearchBar ( ) {
210271 siteHeader . style . display = "none" ;
211272 searchInput . style . display = "block" ;
@@ -214,6 +275,7 @@ function createComponent(html) {
214275 searchBar . classList . add ( "search-bar-open" ) ;
215276 }
216277
278+ // Close search bar (small screens)
217279 function closeSearchBar ( headerState , inputState ) {
218280 siteHeader . style . display = headerState ;
219281 searchInput . style . display = inputState ;
0 commit comments