presseportale/resources/views/livewire/admin/portal-switcher.blade.php
Kevin Adametz 9b47296cea
Some checks are pending
linter / quality (push) Waiting to run
tests / ci (push) Waiting to run
Rebrand Hub+Flux
2026-05-20 15:44:15 +02:00

80 lines
2.9 KiB
PHP

<?php
use App\Enums\Portal;
use Livewire\Volt\Component;
new class extends Component
{
public string $activePortal = '';
public function mount(): void
{
$this->activePortal = session('admin_portal_filter', '');
}
public function switchPortal(string $portal): void
{
if ($portal === '') {
session()->forget('admin_portal_filter');
} else {
$valid = Portal::tryFrom($portal);
if ($valid === null) {
return;
}
session(['admin_portal_filter' => $valid->value]);
}
$this->activePortal = $portal;
$this->redirect($this->redirectTarget(), navigate: false);
}
public function with(): array
{
return [
'portals' => Portal::cases(),
];
}
private function redirectTarget(): string
{
return (string) request()->headers->get('referer', route('dashboard'));
}
}; ?>
<div class="px-1 py-2">
<div class="mb-2 px-2 text-[10.5px] uppercase tracking-[0.6px] font-semibold text-[color:var(--color-ink-3)]">
{{ __('Portal-Filter') }}
</div>
<div class="flex flex-col gap-0.5">
<button
wire:click="switchPortal('')"
@class([
'flex items-center gap-2 rounded-[4px] px-2 py-1.5 text-[12.5px] transition-colors',
'bg-[color:var(--color-bg-elev)] font-semibold text-[color:var(--color-ink)] border border-[color:var(--color-bg-rule)]' => $activePortal === '',
'text-[color:var(--color-ink-2)] hover:bg-[color:var(--color-bg-elev)]/60' => $activePortal !== '',
])
>
<span class="h-2 w-2 rounded-full bg-[color:var(--color-ink-3)]"></span>
{{ __('Alle Portale') }}
</button>
@foreach ($portals as $portal)
@if ($portal !== \App\Enums\Portal::Both)
<button
wire:click="switchPortal('{{ $portal->value }}')"
@class([
'flex items-center gap-2 rounded-[4px] px-2 py-1.5 text-[12.5px] transition-colors',
'bg-[color:var(--color-bg-elev)] font-semibold text-[color:var(--color-ink)] border border-[color:var(--color-bg-rule)]' => $activePortal === $portal->value,
'text-[color:var(--color-ink-2)] hover:bg-[color:var(--color-bg-elev)]/60' => $activePortal !== $portal->value,
])
>
<span @class([
'h-2 w-2 rounded-full',
'bg-[color:var(--color-ok)]' => $portal === \App\Enums\Portal::Presseecho,
'bg-[color:var(--color-err)]' => $portal !== \App\Enums\Portal::Presseecho,
])></span>
{{ $portal->label() }}
</button>
@endif
@endforeach
</div>
</div>