Skip to content

Commit

Permalink
adds submenu in navigation bar. (fixes issue alshedivat#159) (alshedi…
Browse files Browse the repository at this point in the history
…vat#334)

* adds submenu in navigation bar. (fixes issue alshedivat#159)

* Updated scss files to change hover animations on dropdown submenus, on both dark mode and light mode
  • Loading branch information
riddhimanadib authored and pecey committed Jan 27, 2023
1 parent c5b322e commit f0c3566
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
20 changes: 20 additions & 0 deletions _includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@
{% assign sorted_pages = site.pages | sort: "title" %}
{% for p in sorted_pages %}
{% if p.nav and p.autogen == nil %}
{% if p.dropdown %}
<li class="nav-item dropdown {% if page.title == p.title %}active{% endif %}">
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ p.title }}
{% if page.title == p.title %}
<span class="sr-only">(current)</span>
{% endif %}
</a>
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
{% for child in p.children %}
{% if child.title == 'divider' %}
<div class="dropdown-divider"></div>
{% else %}
<a class="dropdown-item" href="{{ child.permalink | relative_url }}">{{ child.title }}</a>
{% endif %}
{% endfor %}
</div>
</li>
{% else %}
<li class="nav-item {% if page.title == p.title %}active{% endif %}">
<a class="nav-link" href="{{ p.url | relative_url }}">
{{ p.title }}
Expand All @@ -61,6 +80,7 @@
</a>
</li>
{% endif %}
{% endif %}
{% endfor %}
{% if site.enable_darkmode %}
<div class = "toggle-container">
Expand Down
12 changes: 12 additions & 0 deletions _pages/dropdown.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
layout: page
title: submenus
nav: true
dropdown: true
children:
- title: publications
permalink: /publications/
- title: divider
- title: projects
permalink: /projects/
---
18 changes: 17 additions & 1 deletion _sass/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ a, table.table a {
color: var(--global-theme-color);
text-decoration: underline;
}
&:hover:after {
&:hover:after :not(.nav-item.dropdown) {
width: 100%;
}
}
Expand Down Expand Up @@ -95,6 +95,22 @@ blockquote {
background-color: var(--global-bg-color);
opacity: 0.95;
}
.navbar .dropdown-menu {
background-color: var(--global-bg-color);
a:not(.active) {
color: var(--global-text-color);
}
a:hover {
color: var(--global-hover-color);
}
}
.dropdown-item {
color: var(--global-text-color);
&:hover {
color: var(--global-hover-color);
background-color: var(--global-bg-color);
}
}
.navbar.navbar-light {
a {
&:hover {
Expand Down

0 comments on commit f0c3566

Please sign in to comment.