Skip to content

Commit d6da9f8

Browse files
committed
Make community banner mobile-friendly
1 parent e84de3e commit d6da9f8

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed
Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,51 @@
1-
<div class="w-full bg-black text-white text-sm py-2">
2-
<div class="mx-auto max-w-[1440px] px-4 py-2 flex items-center justify-between" style="/* Until we upgrade Tailwind */ max-width: 1440px">
1+
@php
2+
$current = 'phpreleases';
3+
4+
$colors = [
5+
'laravelversions' => 'text-blue-500',
6+
'phpreleases' => 'text-teal-500',
7+
'novapackages' => 'text-indigo-500',
8+
'laraveltricks' => 'text-amber-500',
9+
'forgerecipes' => 'text-primary',
10+
];
11+
@endphp
12+
<div class="w-full bg-black text-white text-sm py-2" id="community-banner">
13+
<div class="relative mx-auto max-w-[1440px] px-4 py-2 flex items-center justify-between">
314
<span>Laravel Community Tools by <a href="https://tighten.com" class="hover:underline">Tighten</a></span>
415

5-
<nav class="flex items-center gap-4">
6-
<a href="https://laravelversions.com" class="hover:underline">Laravel Versions</a>
7-
<a href="https://phpreleases.com" class="text-teal-500 hover:underline">PHP Releases</a>
8-
<a href="https://novapackages.com" class="hover:underline">Nova Packages</a>
9-
<a href="https://laravel-tricks.com" class="hover:underline">Laravel Tricks</a>
10-
<a href="https://forgerecipes.com" class="hover:underline">Forge Recipes</a>
16+
<button class="sm:hidden border-0 bg-black text-white cursor-pointer p-1 leading-none" aria-label="Toggle navigation" aria-expanded="false">
17+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/></svg>
18+
</button>
19+
20+
<nav class="hidden sm:flex flex-col sm:flex-row items-start sm:items-center gap-2 sm:gap-4 absolute sm:static top-full left-0 right-0 bg-black px-6 sm:px-0 pb-3 sm:pb-0 z-200 sm:z-auto">
21+
<a href="https://laravelversions.com" class="{{ $current == 'laravelversions' ? $colors[$current] : '' }} hover:underline">Laravel Versions</a>
22+
<a href="https://phpreleases.com" class="{{ $current == 'phpreleases' ? $colors[$current] : '' }} hover:underline">PHP Releases</a>
23+
<a href="https://novapackages.com" class="{{ $current == 'novapackages' ? $colors[$current] : '' }} hover:underline">Nova Packages</a>
24+
<a href="https://laravel-tricks.com" class="{{ $current == 'laraveltricks' ? $colors[$current] : '' }} hover:underline">Laravel Tricks</a>
25+
<a href="https://forgerecipes.com" class="{{ $current == 'forgerecipes' ? $colors[$current] : '' }} hover:underline">Forge Recipes</a>
1126
</nav>
1227
</div>
28+
29+
<script>
30+
(function () {
31+
var banner = document.getElementById('community-banner');
32+
var toggle = banner.querySelector('button');
33+
var nav = banner.querySelector('nav');
34+
35+
toggle.addEventListener('click', function (e) {
36+
e.stopPropagation();
37+
nav.classList.toggle('hidden');
38+
nav.classList.toggle('flex');
39+
toggle.setAttribute('aria-expanded', nav.classList.contains('flex'));
40+
});
41+
42+
document.addEventListener('click', function (e) {
43+
if (!banner.contains(e.target)) {
44+
nav.classList.add('hidden');
45+
nav.classList.remove('flex');
46+
toggle.setAttribute('aria-expanded', 'false');
47+
}
48+
});
49+
})();
50+
</script>
1351
</div>

0 commit comments

Comments
 (0)