Skip to content

Commit 6e94729

Browse files
committedJun 15, 2020
Mobile Nav Menu + Link episode complete
1 parent db7d11d commit 6e94729

File tree

2 files changed

+71
-19
lines changed

2 files changed

+71
-19
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@props(['route'])
2+
3+
@php
4+
$classes = Request::routeIs($route) ? 'bg-blue-500' : '';
5+
@endphp
6+
7+
<a href="{{ route($route) }}" {{ $attributes->merge(['class' => "block p-2 rounded {$classes}"]) }}>
8+
{{ $slot }}
9+
</a>
+62-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,67 @@
1-
<header class="bg-gray-700 text-white px-6 py-4 flex justify-between items-center">
2-
<h1 class="font-bold tracking-widest uppercase">Laracasts</h1>
1+
<header class="bg-gray-700 text-white p-4" x-data="{ open: false }">
2+
<div class="flex justify-between items-center">
3+
<h1 class="font-bold tracking-widest uppercase">
4+
Laracasts
5+
</h1>
36

4-
<nav>
5-
<x-nav-link route="home">Home</x-nav-link>
6-
<x-nav-link route="about">About</x-nav-link>
7-
<x-nav-link route="testimonials">Testimonials</x-nav-link>
8-
<x-nav-link route="contact">Contact</x-nav-link>
9-
</nav>
7+
{{-- Desktop Nav Menu --}}
8+
<nav class="hidden md:flex">
9+
<x-nav-link route="home">Home</x-nav-link>
10+
<x-nav-link route="about">About</x-nav-link>
11+
<x-nav-link route="testimonials">Testimonials</x-nav-link>
12+
<x-nav-link route="contact">Contact</x-nav-link>
13+
</nav>
14+
15+
{{-- Mobile Menu Toggle Buttons --}}
16+
<div class="md:hidden">
17+
<button @click="open = ! open">
18+
{{-- Hamburger Icon --}}
19+
<svg x-show="! open" viewBox="0 0 20 20" width="20">
20+
<g stroke="none"
21+
stroke-width="1"
22+
fill="none"
23+
fill-rule="evenodd"
24+
>
25+
<g fill="white">
26+
<path d="M0,3 L20,3 L20,5 L0,5 L0,3 Z M0,9 L20,9 L20,11 L0,11 L0,9 Z M0,15 L20,15 L20,17 L0,17 L0,15 Z"></path>
27+
</g>
28+
</g>
29+
</svg>
1030

11-
<x-dropdown alignment="right">
12-
<x-slot name="trigger">
13-
<button>
14-
<img src="https://www.placecage.com/30/30"
15-
class="rounded-full border border-white"
16-
alt=""
17-
>
31+
{{-- Close Icon --}}
32+
<svg x-show="open" viewBox="0 0 20 20" width="20">
33+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
34+
<g fill="white">
35+
<polygon id="Combined-Shape" points="10 8.58578644 2.92893219 1.51471863 1.51471863 2.92893219 8.58578644 10 1.51471863 17.0710678 2.92893219 18.4852814 10 11.4142136 17.0710678 18.4852814 18.4852814 17.0710678 11.4142136 10 18.4852814 2.92893219 17.0710678 1.51471863 10 8.58578644"></polygon>
36+
</g>
37+
</g>
38+
</svg>
1839
</button>
19-
</x-slot>
40+
</div>
41+
42+
{{-- User Avatar and Dropdown Menu --}}
43+
<div class="hidden md:block">
44+
<x-dropdown alignment="right">
45+
<x-slot name="trigger">
46+
<button>
47+
<img src="https://www.placecage.com/30/30"
48+
class="rounded-full border border-white"
49+
alt=""
50+
>
51+
</button>
52+
</x-slot>
2053

21-
<x-dropdown-link href="#">Account</x-dropdown-link>
22-
<x-dropdown-link href="#">Support</x-dropdown-link>
23-
</x-dropdown>
54+
<x-dropdown-link href="#">Account</x-dropdown-link>
55+
<x-dropdown-link href="#">Support</x-dropdown-link>
56+
</x-dropdown>
57+
</div>
58+
</div>
59+
60+
<!-- Mobile Nav Menu -->
61+
<nav x-show="open" class="mt-3">
62+
<x-mobile-nav-link route="home">Home</x-mobile-nav-link>
63+
<x-mobile-nav-link route="about">About</x-mobile-nav-link>
64+
<x-mobile-nav-link route="testimonials">Testimonials</x-mobile-nav-link>
65+
<x-mobile-nav-link route="contact">Contact</x-mobile-nav-link>
66+
</nav>
2467
</header>

0 commit comments

Comments
 (0)
Please sign in to comment.