kithkin/resources/views/components/app/pagelink.blade.php

38 lines
714 B
PHP

@props([
'active' => false,
// label text (string)
'label' => null,
// icon name only
'icon' => null,
])
@php
$isActive = (bool) $active;
$classes = trim(collect([
'pagelink',
$isActive ? 'is-active' : null,
])->filter()->implode(' '));
$iconComponent = null;
if ($icon) {
$iconComponent = $isActive
? 'icon-solid.'.$icon
: 'icon-'.$icon;
}
@endphp
<a {{ $attributes->merge(['class' => $classes]) }}>
@if ($iconComponent)
<x-dynamic-component :component="$iconComponent" width="20" />
@endif
@if (!is_null($label))
<span>{{ $label }}</span>
@else
{{ $slot }}
@endif
</a>