Skip to content

Commit db7d11d

Browse files
committed
Nav Link Episode Complete
1 parent f0bc51e commit db7d11d

File tree

6 files changed

+58
-13
lines changed

6 files changed

+58
-13
lines changed

resources/views/components/dropdown.blade.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</div>
1414

1515
<div
16-
class="absolute {{ $alignmentClasses[$alignment] }} z-20 bg-white rounded shadow-md py-2 mt-1 w-40"
16+
class="absolute {{ $alignmentClasses[$alignment] }} z-20 bg-white text-black rounded shadow-md py-2 mt-1 w-40"
1717
x-show="open"
1818
x-transition:enter="transition transform duration-300"
1919
x-transition:enter-start="opacity-0 scale-95"

resources/views/components/layout.blade.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
content="width=device-width, initial-scale=1"
88
>
99

10-
<title>Laravel</title>
10+
<title>Blade Component Examples</title>
1111

1212
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
1313
rel="stylesheet"
@@ -17,6 +17,7 @@
1717
</head>
1818

1919
<body>
20+
@include('partials/header')
2021

2122
{{ $slot }}
2223

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@props(['route'])
2+
3+
@php
4+
$classes = Request::routeIs($route) ? 'text-blue-500 underline' : 'hover:text-blue-500';
5+
@endphp
6+
7+
<a href="{{ route($route) }}" {{ $attributes->merge(['class' => "px-6 hover:underline {$classes}"]) }}>
8+
{{ $slot }}
9+
</a>
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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>
3+
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>
10+
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+
>
18+
</button>
19+
</x-slot>
20+
21+
<x-dropdown-link href="#">Account</x-dropdown-link>
22+
<x-dropdown-link href="#">Support</x-dropdown-link>
23+
</x-dropdown>
24+
</header>

resources/views/welcome.blade.php

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
<x-layout>
22
<x-section>
3-
<div>
4-
<x-dropdown>
5-
<x-slot name="trigger">
6-
<button>Click Me</button>
7-
</x-slot>
8-
9-
<x-dropdown-link href="/">One</x-dropdown-link>
10-
<x-dropdown-link href="/">Two</x-dropdown-link>
11-
<x-dropdown-link href="/">Three</x-dropdown-link>
12-
</x-dropdown>
13-
</div>
3+
<p>
4+
Hello World
5+
</p>
146
</x-section>
157
</x-layout>

routes/web.php

+19
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,29 @@
44
use App\Comment;
55

66

7+
// Select Nav Link Setup
8+
79
Route::get('/', function () {
810
return view('welcome');
11+
})->name('home');
12+
13+
Route::get('/about', function () {
14+
return view('welcome');
15+
})->name('about');
16+
17+
Route::get('/testimonials', function () {
18+
return view('welcome');
19+
})->name('testimonials');
20+
21+
Route::get('/contact', function () {
22+
return view('welcome');
23+
})->name('contact');
24+
25+
Route::get('/contact-team', function () {
26+
return view('welcome');
927
});
1028

29+
1130
Route::get('/comments/{comment}/edit', function (Comment $comment) {
1231
return view('comments.edit', ['comment' => $comment]);
1332
});

0 commit comments

Comments
 (0)