-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for nested groups in side bar navigation (#180)
* Add nested groups support in side nav * Update README.md to reference the new option. * minor change to fix case on configuration property to match the reference in the readme * Minor update to the nested menu css to bring it closer to the standard non-nested list. * Implemented suggested changes * Added a test for MenuViewModel.SoftwareSystemsNodes * Fix some whitespace issues and reformat table in readme file. * Fix some additional whitespace issues
- Loading branch information
Showing
10 changed files
with
218 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/main/kotlin/nl/avisi/structurizr/site/generatr/site/model/MenuNodeViewModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package nl.avisi.structurizr.site.generatr.site.model | ||
|
||
data class MenuNodeViewModel(val name: String, val children: List<MenuNodeViewModel>) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.listree-submenu-heading { | ||
cursor: pointer; | ||
padding: .5em .75em; | ||
} | ||
|
||
ul.listree { | ||
list-style: none | ||
} | ||
|
||
ul.listree-submenu-items { | ||
list-style: none; | ||
white-space: nowrap; | ||
padding-left: 10px | ||
} | ||
|
||
div.listree-submenu-heading.collapsed:before { | ||
content: "\25B6"; | ||
margin-right: 4px | ||
} | ||
|
||
div.listree-submenu-heading.expanded:before { | ||
content: "\25BC"; | ||
margin-right: 4px | ||
} | ||
|
||
.scrollable-menu { | ||
height: auto; | ||
max-width: 800px; | ||
overflow-y: hidden | ||
} | ||
|
||
.menu-list li ul { | ||
border-left: 0; | ||
margin: .25em; | ||
padding-left: .75em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
function listree() { | ||
|
||
const subMenuHeadingClass = "listree-submenu-heading"; | ||
const expandedClass = "expanded"; | ||
const collapsedClass = "collapsed"; | ||
const activeClass = "is-active"; | ||
const subMenuHeadings = document.getElementsByClassName(subMenuHeadingClass); | ||
|
||
Array | ||
.from(subMenuHeadings) | ||
.forEach(function(subMenuHeading) { | ||
// Collapse all the subMenuHeadings while searching for is-active class | ||
let foundActive = false; | ||
subMenuHeading.classList.add(collapsedClass); | ||
subMenuHeading.nextElementSibling.style.display = "none"; | ||
|
||
// Check if this sub-menu heading is active | ||
const liElements = subMenuHeading.nextElementSibling.children; | ||
for (let i = 0; i < liElements.length; i++) { | ||
if (liElements[i].hasChildNodes()) { | ||
if (liElements[i].children[0].tagName === "A") { | ||
if (liElements[i].children[0].classList.contains(activeClass)) { | ||
foundActive = true; | ||
break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
// Expand all parent sub-menus until root menu is reached | ||
if (foundActive) { | ||
subMenuHeading.classList.remove(collapsedClass); | ||
subMenuHeading.classList.add(expandedClass); | ||
subMenuHeading.nextElementSibling.style.display = "block"; | ||
|
||
let currentSubMenu = subMenuHeading.parentElement; | ||
while (currentSubMenu !== null && !currentSubMenu.classList.contains("listree")) { | ||
if(currentSubMenu.tagName === "UL"){ | ||
if(currentSubMenu.previousElementSibling != null) { | ||
currentSubMenu.previousElementSibling.classList.remove(collapsedClass); | ||
currentSubMenu.previousElementSibling.classList.add(expandedClass); | ||
currentSubMenu.style.display = "block"; | ||
} | ||
} | ||
currentSubMenu = currentSubMenu.parentElement | ||
} | ||
} | ||
|
||
// Add the eventlistener to all subMenuHeadings | ||
subMenuHeading.addEventListener("click", function(event) { | ||
event.preventDefault(); | ||
const subMenuList = event.target.nextElementSibling; | ||
if (subMenuList.style.display === "none") { | ||
subMenuHeading.classList.remove(collapsedClass); | ||
subMenuHeading.classList.add(expandedClass); | ||
subMenuHeading.nextElementSibling.style.display = "block"; | ||
} else { | ||
subMenuHeading.classList.remove(expandedClass); | ||
subMenuHeading.classList.add(collapsedClass); | ||
subMenuHeading.nextElementSibling.style.display = "none"; | ||
} | ||
event.stopPropagation(); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters