Skip to content
This repository has been archived by the owner on Jul 28, 2021. It is now read-only.

Add submenu support, fix #30 #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,37 @@
width: 100%;
}

.menu__items .menu__items__item .submenu__list {
background-color: var(--white);
opacity: 0;
position: absolute;
max-width: 20rem;
transition: all 0.25s ease-in-out;
margin-top: 3px;
border-top: 3px solid var(--primary);
box-shadow: 0 1px 5px var(--divider);
}

.menu__items__item .submenu__list .menu__items__item {
margin: 0.5rem 1.5rem;
}

.menu__items__item .submenu__list .menu__items__item__link {
color: var(--primary-text);
padding: 0.5rem 0.5rem;
position: relative;
}


.menu__items .menu__items__item:hover > .submenu__list,
.menu__items .menu__items__item:focus-within > .submenu__list,
.menu__items .menu__items__item .submenu__list:hover,
.menu__items .menu__items__item .submenu__list:focus {
visibility: visible;
opacity: 1;
display: block;
}

/* HAMBURGER MENU */
.hamburger-menu {
display: none;
Expand Down Expand Up @@ -133,6 +164,14 @@
color: var(--primary-dark);
}

.hamburger__items__item .submenu__list {
margin: 1.00rem;
}

.submenu__list .hamburger__items__item {
margin: 1.00rem;
}

.toggle .hamburger__toggle:checked ~ .hamburger__items {
transform: translate(-70%, 0);
visibility: visible;
Expand Down
12 changes: 11 additions & 1 deletion layouts/partials/hamburger-menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@
<a href="{{ .URL }}" class="hamburger__items__item__link" alt="{{ .Name }}" role="menuitem">
{{ .Name }}
</a>
{{ if .HasChildren }}
<!--input type="checkbox" id="{{ .Name }}"-->
<ul class="hamburger__items__item submenu__list">
{{ range .Children }}
<li class="hamburger__items__item">
<a class="hamburger__items__item__link " href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}
</ul>
</div>
</nav>
</nav>
15 changes: 12 additions & 3 deletions layouts/partials/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@
{{ $current := . }}
{{ range .Site.Menus.main }}
<li class="menu__items__item" aria-label="{{ .Name }}">
<a href="{{ .URL }}" class="menu__items__item__link {{ if $current.IsMenuCurrent "main" . }}active{{ end }}"
<a href="{{ .URL }}" class="menu__items__item__link {{ if or ($current.IsMenuCurrent "main" .) ($current.HasMenuCurrent "main" .) }}active{{ end }}"
alt="{{ .Name }}" role="menuitem">
{{ .Name }}
{{ .Name }}{{ if .HasChildren }}&nbsp;<span class="drop-icon" for="{{ .Name }}">▾</span>{{ end }}
</a>
{{ if .HasChildren }}
<ul class="submenu__list">
{{ range .Children }}
<li class="menu__items__item">
<a class="menu__items__item__link {{ if $current.IsMenuCurrent "main" . }}active{{ end }}" href="{{ .URL }}">{{ .Name }}</a>
</li>
{{ end }}
</ul>
{{ end }}
</li>
{{ end }}
</ul>
</nav>
</nav>