Add subnav behavior to SidenavItem module

This commit is contained in:
Andrew Croce
2018-07-23 16:49:36 -04:00
parent 56d6077f48
commit 648aaa23a0
5 changed files with 49 additions and 6 deletions

View File

@@ -6,4 +6,19 @@
<span class="sidenav__link-label">{{label}}</span>
</a>
{% if subnav and active %}
<ul>
{% for item in subnav %}
<li>
<a class="sidenav__link {% if item["active"] %}sidenav__link--active{% end %}" href="{{item["href"]}}" title="{{item["label"]}}">
{% if "icon" in item %}
{% module Icon(item["icon"], classes="sidenav__link-icon") %}
{% end %}
<span class="sidenav__link-label">{{item["label"]}}</span>
</a>
</li>
{% end %}
</ul>
{% end %}
</li>

View File

@@ -1,11 +1,24 @@
<div class="global-navigation sidenav global-navigation__context--{{context}}">
<ul>
{% if dev() %}
{% module SidenavItem("Styleguide", href="/styleguide", icon="visible", active=matchesPath('/styleguide')) %}
{% module SidenavItem("Styleguide",
href="/styleguide",
icon="visible",
active=matchesPath('/styleguide'),
subnav=[
{"label":"Subnav 1", "href":"/styleguide?subnav1", "icon": "plus", "active": matchesPath('/styleguide?subnav1')},
{"label":"Subnav 2", "href":"/styleguide?subnav2", "active": matchesPath('/styleguide?subnav2')},
]) %}
{% end %}
{% module SidenavItem("Requests", href="/requests", icon="document", active=matchesPath('/requests')) %}
{% module SidenavItem("+ New Request", href="/requests/new", icon="", active=matchesPath('/requests/new')) %}
{% module SidenavItem("Requests",
href="/requests",
icon="document",
active=matchesPath('/requests'),
subnav=[
{"label":"New Request", "href":"/requests/new", "icon": "plus", "active": matchesPath('/requests/new')},
]
) %}
{% module SidenavItem("Workspaces", href="/workspaces", icon="cloud", active=matchesPath('/workspaces')) %}
</ul>
</div>