Skip to content

Commit 5894494

Browse files
committed
Add navbar menu button on small and medium devices.
1 parent 709b263 commit 5894494

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

templates/components/navbar.html

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1+
{% from 'components/menu_icon.html' import menu_icon %}
2+
13
{% macro navbar() %}
2-
<nav class="container navbar">
4+
<nav class="container navbar"
5+
data-controller="navbar">
36
<div class="navbar-left-group">
47
<a href="/" class="navbar-item">
58
dry-python
69
</a>
710
</div>
8-
<div class="navbar-right-group">
11+
<div class="block lg:hidden">
12+
<button class="navbar-button"
13+
data-action="navbar#toggle">
14+
{{ menu_icon('Menu') }}
15+
</button>
16+
</div>
17+
<div class="navbar-right-group"
18+
data-target="navbar.menuItems">
919
{% for path, label in bag('navbar').items() %}
1020
<a href="{{ path|url }}" class="navbar-item">
1121
{{ label }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Controller } from 'stimulus'
2+
3+
export default class extends Controller {
4+
static targets = ['menuItems']
5+
6+
toggle() {
7+
this.menuItemsTarget.classList.toggle('hidden')
8+
}
9+
}

webpack/app/styles/navbar.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@
1717
.navbar-item:hover {
1818
@apply .text-black .border-black;
1919
}
20+
21+
.navbar-button {
22+
@apply flex items-center px-3 py-2 border rounded text-teal-lighter border-teal-light;
23+
}
24+
25+
.navbar-button:hover {
26+
@apply text-white border-white;
27+
}

0 commit comments

Comments
 (0)