-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add desktop/mobile navigation #74
base: master
Are you sure you want to change the base?
Changes from 3 commits
594492e
3e26388
699a4e3
4993034
762ab40
8c798d6
bc1fe36
dfd53dd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@props(['id', 'children', 'title' => __('Menu'), 'hasParent' => false, 'tag' => 'form', 'parentUrl' => '']) | ||
@slots(['headerbutton']) | ||
|
||
<x-rapidez::slideover.mobile | ||
:title="(string) $title" | ||
:$id | ||
:$hasParent | ||
:$tag | ||
> | ||
<x-slot:headerbutton> | ||
JimmyHoenderdaal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<div class="absolute left-0 top-1/2 -translate-y-1/2 cursor-pointer text-white"> | ||
@include('rapidez-statamic::navigation.header-button') | ||
</div> | ||
</x-slot:headerbutton> | ||
<div class="flex w-full flex-1 flex-col bg-inactive-100"> | ||
<ul class="mt-5 flex flex-col divide-y border-y bg-white"> | ||
@if ($hasParent && $parentUrl) | ||
<li> | ||
<a href="{{ $parentUrl }}" class="normal flex items-center justify-between p-5 font-semibold"> | ||
@lang('Go to :item', ['item' => strtolower($title)]) | ||
</a> | ||
</li> | ||
@endif | ||
@foreach ($children ?: [] as $child) | ||
@php | ||
$url = $child['url']; | ||
if (isset($child['linked_category'])) { | ||
JimmyHoenderdaal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
$url = Str::start($child['linked_category']->value()['url_path'] ?? '', '/'); | ||
} | ||
@endphp | ||
<li class="relative"> | ||
@if ($child['title'] ?? '') | ||
<a href="{{ $url }}" class="flex items-center justify-between p-5 font-semibold"> | ||
{{ $child['title'] }} | ||
@if ($child['children']) | ||
<x-heroicon-o-chevron-right class="size-4" /> | ||
@endif | ||
</a> | ||
@endif | ||
@if ($child['children']) | ||
@php($childId = uniqid(Str::snake("{$child['title']}" ?? ''))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This vs unique helpers provide by Laravel? Don't we have a unique ID already which we can use? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is using uniqid but it adds snake case to the title for whenever there are spaces in the title I want to use the title here since it makes it more clear what id's and for's are linked to each other in your browser. |
||
<label class="absolute inset-0 cursor-pointer" for="{{ $childId }}"></label> | ||
<x-rapidez-statamic::nav-layer | ||
:id="$childId" | ||
:children="$child['children'] ?? []" | ||
:title="$child['title'] ?? ''" | ||
:parent-url="$child['url']" | ||
has-parent | ||
tag="div" | ||
></x-rapidez-statamic::nav-layer> | ||
@endif | ||
</li> | ||
@endforeach | ||
</ul> | ||
{{ $slot }} | ||
</div> | ||
</x-rapidez::slideover.mobile> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{{-- This is shown on the first slideover of the mobile menu, you can leave this empty if you don't want it. By default this is a search button --}} | ||
<x-button.search /> | ||
JimmyHoenderdaal marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<nav class="lg:hidden"> | ||
<x-rapidez-statamic::nav-layer | ||
id="navigation" | ||
is-form | ||
:children="Statamic::tag('nav:main')->fetch()" | ||
/> | ||
</nav> | ||
@php | ||
$baseUrl = \Statamic\Facades\Site::current()->absoluteUrl(); | ||
@endphp | ||
<nav class="relative border-y max-lg:hidden"> | ||
<ul class="flex items-center justify-center gap-8 font-semibold text-neutral [&>:not(:hover)]:hover:text-inactive text-sm"> | ||
@foreach (Statamic::tag('nav:main')->fetch() as $item) | ||
@php | ||
$itemUrl = isset($item['linked_category']) && ($item['linked_category']?->value()['url_path'] ?? false) ? $baseUrl . '/' . $item['linked_category']->value()['url_path'] : $item['url'] ?? ''; | ||
@endphp | ||
<li class="group"> | ||
<a class="relative flex py-4 transition" href="{{ $itemUrl }}"> | ||
{{ $item['title'] }} | ||
@if ($item['children']) | ||
<div class="absolute inset-x-0 bottom-0 z-50 h-0.5 w-full origin-right translate-y-1/2 scale-x-0 bg-primary transition group-hover:origin-left group-hover:scale-x-100"></div> | ||
@endif | ||
</a> | ||
@if ($item['children']) | ||
<div class="pointer-events-none absolute inset-x-0 top-full -translate-y-1 border-t bg-white opacity-0 transition group-hover:pointer-events-auto group-hover:translate-y-0 group-hover:opacity-100"> | ||
<div class="pointer-events-none absolute inset-x-0 top-full h-screen bg-neutral/50"></div> | ||
<div class="container relative flex overflow-hidden"> | ||
<ul class="columns-3 flex-col gap-x-12 py-10 font-bold xl:columns-4 w-full"> | ||
@foreach ($item['children'] as $item) | ||
@php | ||
$itemUrl = isset($item['linked_category']) && ($item['linked_category']?->value()['url_path'] ?? false) ? $baseUrl . '/' . $item['linked_category']->value()['url_path'] : $item['url'] ?? ''; | ||
JimmyHoenderdaal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@endphp | ||
<li class="flex break-inside-avoid flex-col gap-1 pb-5"> | ||
<a href="{{ $itemUrl }}">{{ $item['title'] }}</a> | ||
<ul class="flex flex-col font-medium [&>:not(:hover)]:hover:text-inactive"> | ||
@foreach ($item['children'] as $item) | ||
@php | ||
$itemUrl = isset($item['linked_category']) && ($item['linked_category']?->value()['url_path'] ?? false) ? $baseUrl . '/' . $item['linked_category']->value()['url_path'] : $item['url'] ?? ''; | ||
@endphp | ||
<li class="transition"> | ||
<a href="{{ $itemUrl }}">{{ $item['title'] }}</a> | ||
</li> | ||
@endforeach | ||
</ul> | ||
</li> | ||
@endforeach | ||
</ul> | ||
</div> | ||
</div> | ||
@endif | ||
</li> | ||
@endforeach | ||
</ul> | ||
</nav> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need the casting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
otherwise I get this error