x-nav-link

This commit is contained in:
Dym Sohin 2024-08-07 14:01:03 +02:00
parent f2a3846b87
commit 79d9d8df71
3 changed files with 36 additions and 20 deletions

View File

@ -0,0 +1,26 @@
<?php
namespace App\View\Components;
use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
class nav-link extends Component
{
/**
* Create a new component instance.
*/
public function __construct()
{
//
}
/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.nav-link');
}
}

View File

@ -55,26 +55,11 @@
<nav class="c">
<div class="buttons round">
<a href="{{ str_starts_with(request()->path(), 'graphics') ? '/' : '/graphics/' }}"
class="red {{ str_starts_with(request()->path(), 'graphics') ? 'current' : '' }}"
title="graphics"
><span class="hidden">graphics</span></a>
<a href="{{ str_starts_with(request()->path(), 'photos') ? '/' : '/photos/' }}"
class="yellow {{ str_starts_with(request()->path(), 'photos') ? 'current' : '' }}"
title="photos"
><span class="hidden">photos</span></a>
<a href="{{ str_starts_with(request()->path(), 'comics') ? '/' : '/comics/' }}"
class="green {{ str_starts_with(request()->path(), 'comics') ? 'current' : '' }}"
title="comics"
><span class="hidden">comics</span></a>
<a href="{{ str_starts_with(request()->path(), 'code') ? '/' : '/code/' }}"
class="blue {{ str_starts_with(request()->path(), 'code') ? 'current' : '' }}"
title="code"
><span class="hidden">code</span></a>
<a href="{{ str_starts_with(request()->path(), 'notes') ? '/' : '/notes/' }}"
class="rose {{ str_starts_with(request()->path(), 'notes') ? 'current' : '' }}"
title="notes"
><span class="hidden">notes</span></a>
<x-nav-link class="red">graphics</x-nav-link>
<x-nav-link class="yellow">photos</x-nav-link>
<x-nav-link class="green">comics</x-nav-link>
<x-nav-link class="blue">code</x-nav-link>
<x-nav-link class="rose">notes</x-nav-link>
</div>
</nav>

View File

@ -0,0 +1,5 @@
<a href="{{ str_starts_with(request()->path(), $slot) ? '/' : '/'.$slot.'/' }}"
title="{{ $slot }}"
aria-current="{{ str_starts_with(request()->path(), $slot) ? 'true' : 'false' }}"
{{ $attributes->merge(['class' => str_starts_with(request()->path(), $slot ) ? 'current' : '' ])}}
><span class="hidden">{{ $slot }}</span></a>