Skip to content

Commit

Permalink
feat(nav): close on link click
Browse files Browse the repository at this point in the history
  • Loading branch information
rpeterman-gp committed Nov 22, 2024
1 parent 34371e9 commit a129ec0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
7 changes: 5 additions & 2 deletions _includes/app/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
<script defer type="text/javascript" src="assets/js/donation-modal.js"></script>

<!-- Audio -->
<script defer type="text/javascript" src="assets/js/audio.js?cb={{ site.time }}"></script>
<script defer type="text/javascript" src="assets/js/show-audio.js?cb={{ site.time }}"></script>
<script defer type="text/javascript" src="assets/js/audio.js"></script>
<script defer type="text/javascript" src="assets/js/show-audio.js"></script>

<!-- Menu -->
<script defer type="text/javascript" src="assets/js/menu.js?cb={{ site.time }}"></script>
17 changes: 10 additions & 7 deletions _includes/components/menu-item.html
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
<li class="menu-item">
{%- if include.icon -%}
<a
<a
href="{{ include.href }}"
class="menu-link icon {{ include.color }}"
class="menu-link icon {{ include.color }}"
{%- if include.target -%}
target="{{ include-target }}"
{%- endif -%}
{%- if include.campaign-id -%}
{%- if include.campaign-id -%}
data-donate-campaign-id="{{ include.campaign-id }}"
{%- endif -%}
>
{%- endif -%}
>
<span class="material-icons" aria-label="{{ include.aria-label }}">{{ include.icon }}</span>
<span>{{ include.label }}</span>
</a>
{%- else -%}
<a href="{{ include.href }}" class="menu-link {{ include.color }}" >{{ include.label }}</a>
{%- else -%}
<a
href="{{ include.href }}"
class="menu-link {{ include.color }}"
>{{ include.label }}</a>
{%- endif -%}
</li>
9 changes: 9 additions & 0 deletions assets/js/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
((doc) => {
const drawer = doc.getElementById('navDrawerPopover');

drawer.addEventListener('click', (evt) => {
const anchor = evt.target.closest('a');

if (anchor) drawer.hidePopover();
});
})(document);

0 comments on commit a129ec0

Please sign in to comment.