Skip to content
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

[Feature] Handle Panel Domains #15

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions resources/views/panel-switch-menu.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
@php
$getUrlScheme = (string) app()->environment('production') ? 'https://' : 'http://';

$getPanelPath = fn (\Filament\Panel $panel): string => filled($domains = $panel->getDomains())
? str(collect($domains)->first())->prepend($getUrlScheme)->toString()
: str($panel->getPath())->prepend('/')->toString();

$getHref = fn (\Filament\Panel $panel): ?string => $canSwitchPanels && $panel->getId() !== $currentPanel->getId()
? $getPanelPath($panel)
: null;
@endphp

@if ($isSimple)
<x-filament::dropdown teleport placement="bottom-end">
Expand All @@ -23,7 +34,7 @@ class="w-5 h-5 text-white ms-auto shrink-0"
<x-filament::dropdown.list>
@foreach ($panels as $panel)
<x-filament::dropdown.list.item
:href="$canSwitchPanels && $panel->getId() !== $currentPanel->getId() ? '/' . $panel->getPath() : null"
:href="$getHref($panel)"
:badge="str($labels[$panel->getId()] ?? $panel->getId())->substr(0, 2)->upper()"
tag="a"
>
Expand Down Expand Up @@ -66,7 +77,7 @@ class="flex flex-wrap items-center justify-center gap-4 md:gap-6"
>
@foreach ($panels as $panel)
<a
href="{{ $canSwitchPanels && $panel->getId() !== $currentPanel->getId() ? '/' . $panel->getPath() : '#' }}"
href="{{ $getHref($panel) }}"
class="flex flex-col items-center justify-center flex-1 hover:cursor-pointer group panel-switch-card"
>
<div
Expand Down
Loading