Skip to content

Commit 9219353

Browse files
committed
Implement mobile navigation
1 parent c70fb8e commit 9219353

File tree

4 files changed

+38
-9
lines changed

4 files changed

+38
-9
lines changed

resources/assets/css/main.css

+4
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
@import './base.css';
1111
@import './fonts.css';
1212
}
13+
14+
@theme {
15+
--color-chamaleon: hsl(120, 40%, 80%);
16+
}

resources/views/components/layout-header.blade.php

+24-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
<header
2-
style="background-color: hsl(120, 40%, 80%)"
3-
class="z-10 flex h-16 flex-col items-center md:h-32 lg:h-40"
2+
class="bg-chamaleon z-10 flex h-16 flex-col items-center md:h-32 lg:h-40"
3+
:class="navigationOpen ? 'fixed top-0 inset-x-0' : ''"
44
>
55
<div class="max-w-content flex w-full overflow-hidden">
6+
<a
7+
class="hover:bg-overlay mr-2 flex h-full cursor-pointer items-center px-3 md:hidden print:hidden"
8+
@click="navigationOpen = !navigationOpen"
9+
>
10+
<s:partial src="icons/menu" class="h-8 fill-current" />
11+
</a>
12+
613
<a
714
href="{{ sroute("home") }}"
815
aria-label="Home"
@@ -23,13 +30,19 @@ class="h-full fill-current text-black"
2330
</div>
2431
</a>
2532
</div>
26-
<nav aria-label="Site navigation" class="bg-overlay w-full">
27-
<div class="max-w-content mx-auto flex h-full justify-between">
28-
<div class="flex">
33+
<nav
34+
aria-label="Site navigation"
35+
class="md:bg-overlay bg-chamaleon fixed top-16 bottom-0 w-full transition-transform duration-300 md:relative md:top-0"
36+
:class="navigationOpen ? 'translate-x-0' : '-translate-x-full md:translate-x-0'"
37+
>
38+
<div
39+
class="md:max-w-content max-h-full overflow-auto md:mx-auto md:flex md:h-full md:justify-between"
40+
>
41+
<div class="md:flex">
2942
<s:nav handle="main">
3043
<a
3144
href="{{ $url }}"
32-
class="group hover:bg-overlay relative flex items-center p-2 font-bold text-black uppercase opacity-50 hover:opacity-100 focus:opacity-100 [&:is([aria-current])]:opacity-100"
45+
class="group hover:bg-overlay relative flex items-center px-4 py-3 font-bold text-black uppercase hover:opacity-100 focus:opacity-100 md:px-2 md:py-2 md:opacity-50 [&:is([aria-current])]:opacity-100"
3346
@if ($is_current)
3447
aria-current="page"
3548
@endif
@@ -43,21 +56,23 @@ class="border-b-2 border-transparent group-hover:border-black [[aria-current]>&]
4356
</a>
4457
</s:nav>
4558
</div>
46-
<div class="flex">
59+
<div class="md:flex">
4760
@foreach ($socials as $account)
4861
<a
4962
href="{{ $account->link }}"
5063
aria-label="{{ $account->name }}"
5164
title="{{ $account->name }}"
5265
target="_blank"
53-
class="hover:bg-overlay flex min-w-10 items-center justify-center px-2 opacity-50 hover:opacity-100 focus:opacity-100"
66+
class="hover:bg-overlay flex min-w-10 items-center justify-start px-4 py-3 hover:opacity-100 focus:opacity-100 md:justify-center md:px-2 md:py-0 md:opacity-50"
5467
{{ $account->represent ? 'rel="me"' : "" }}
5568
>
5669
<s:partial
5770
:src="'icons/' . $account->icon"
5871
:class="($account->classes ?? '') . ' h-6'"
5972
/>
60-
<span class="sr-only">{{ $account->name }}</span>
73+
<span class="ml-2 md:sr-only">
74+
{{ $account->name }}
75+
</span>
6176
</a>
6277
@endforeach
6378
</div>
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<svg
2+
class="{{ class ?? '' }}"
3+
xmlns="http://www.w3.org/2000/svg"
4+
viewBox="0 0 20 20"
5+
>
6+
<path d="M0 3h20v2H0V3zm0 6h20v2H0V9zm0 6h20v2H0v-2z" />
7+
</svg>

resources/views/layout.blade.php

+3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
@vite(['resources/assets/css/main.css', 'resources/assets/js/main.js'])
2222
</head>
2323
<body
24+
x-data="{ navigationOpen: false }"
2425
class="font-ubuntu text-black-light flex min-h-screen flex-col bg-white text-base leading-tight font-normal antialiased print:block"
26+
:class="navigationOpen ? 'overflow-hidden' : ''"
2527
>
2628
<a
2729
href="#main"
@@ -35,6 +37,7 @@ class="border-blue-darkest sr-only z-20 border bg-white focus:not-sr-only focus:
3537
<main
3638
id="main"
3739
class="max-w-content relative mx-auto w-full grow p-4 pt-8 md:px-2"
40+
:class="navigationOpen ? 'mt-16' : ''"
3841
>
3942
@yield('main')
4043
</main>

0 commit comments

Comments
 (0)