You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

panel-switch-menu.blade.php 5.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. @php
  2. $getUrlScheme = (string) app()->environment('production') ? 'https://' : 'http://';
  3. $getPanelPath = fn (\Filament\Panel $panel): string => filled($domains = $panel->getDomains())
  4. ? str(collect($domains)->first())->prepend($getUrlScheme)->toString()
  5. : str($panel->getPath())->prepend('/')->toString();
  6. $getHref = fn (\Filament\Panel $panel): ?string => $canSwitchPanels && $panel->getId() !== $currentPanel->getId()
  7. ? $getPanelPath($panel)
  8. : null;
  9. @endphp
  10. @if ($isSimple)
  11. <x-filament::dropdown teleport placement="bottom-end">
  12. <x-slot name="trigger">
  13. <div x-data="{ open: false }" @click.outside="open = false">
  14. <button type="button" @click="open = !open" class="flex items-center justify-center gap-x-2 rounded-lg px-3 py-2 text-sm font-semibold outline-none transition duration-75 hover:bg-gray-50 focus-visible:bg-gray-50 dark:hover:bg-white/5 dark:focus-visible:bg-white/5 text-gray-700 dark:text-gray-200">
  15. <span class="ml-4">{{ $labels[$currentPanel->getId()] ?? str($currentPanel->getId())->ucfirst() }}</span>
  16. <x-heroicon-m-chevron-down x-show="!open" class="w-5 h-5 text-gray-400 dark:text-gray-500" />
  17. <x-heroicon-m-chevron-up x-show="open" x-cloak class="w-5 h-5 text-gray-400 dark:text-gray-500" />
  18. </button>
  19. </div>
  20. </x-slot>
  21. <x-filament::dropdown.list>
  22. @foreach ($panels as $panel)
  23. <x-filament::dropdown.list.item
  24. :href="$getHref($panel)"
  25. :icon="$icons[$panel->getId()] ?? 'heroicon-s-square-2-stack'"
  26. tag="a"
  27. >
  28. {{ $labels[$panel->getId()] ?? str($panel->getId())->ucfirst() }}
  29. </x-filament::dropdown.list.item>
  30. @endforeach
  31. </x-filament::dropdown.list>
  32. </x-filament::dropdown>
  33. @else
  34. <style>
  35. .panel-switch-modal .fi-modal-content {
  36. align-items: center !important;
  37. justify-content: center !important;
  38. }
  39. </style>
  40. <x-filament::icon-button
  41. x-data="{}"
  42. icon="heroicon-o-square-3-stack-3d"
  43. icon-alias="panels::panel-switch-modern-icon"
  44. icon-size="lg"
  45. @click="$dispatch('open-modal', { id: 'panel-switch' })"
  46. label="Switch Panels"
  47. class="text-gray-700 dark:text-primary-500"
  48. />
  49. <x-filament::modal
  50. id="panel-switch"
  51. :width="$modalWidth"
  52. alignment="center"
  53. display-classes="block"
  54. :slide-over="$isSlideOver"
  55. :sticky-header="$isSlideOver"
  56. :heading="$heading"
  57. class="panel-switch-modal"
  58. >
  59. <div
  60. class="flex flex-wrap items-center justify-center gap-4 md:gap-6"
  61. >
  62. @foreach ($panels as $panel)
  63. <a
  64. href="{{ $getHref($panel) }}"
  65. class="flex flex-col items-center justify-center flex-1 hover:cursor-pointer group panel-switch-card"
  66. >
  67. <div
  68. @class([
  69. "p-2 bg-white rounded-lg shadow-md dark:bg-gray-800 panel-switch-card-section",
  70. "group-hover:ring-2 group-hover:ring-primary-600" => $panel->getId() !== $currentPanel->getId(),
  71. "ring-2 ring-primary-600" => $panel->getId() === $currentPanel->getId(),
  72. ])
  73. >
  74. @if ($renderIconAsImage)
  75. <img
  76. class="rounded-lg panel-switch-card-image"
  77. style="width: {{ $iconSize * 4 }}px; height: {{ $iconSize * 4 }}px;"
  78. src="{{ $icons[$panel->getId()] ?? 'https://raw.githubusercontent.com/bezhanSalleh/filament-panel-switch/3.x/art/banner.jpg' }}"
  79. alt="Panel Image"
  80. >
  81. @else
  82. @php
  83. $iconName = $icons[$panel->getId()] ?? 'heroicon-s-square-2-stack' ;
  84. @endphp
  85. @svg($iconName, 'text-primary-600 panel-switch-card-icon', ['style' => 'width: ' . ($iconSize * 4) . 'px; height: ' . ($iconSize * 4). 'px;'])
  86. @endif
  87. </div>
  88. <span
  89. @class([
  90. "mt-2 text-sm font-medium text-center text-gray-400 dark:text-gray-200 break-words panel-switch-card-title",
  91. "text-gray-400 dark:text-gray-200 group-hover:text-primary-600 group-hover:dark:text-primary-400" => $panel->getId() !== $currentPanel->getId(),
  92. "text-primary-600 dark:text-primary-400" => $panel->getId() === $currentPanel->getId(),
  93. ])
  94. >
  95. {{ $labels[$panel->getId()] ?? str($panel->getId())->ucfirst()}}
  96. </span>
  97. </a>
  98. @endforeach
  99. </div>
  100. </x-filament::modal>
  101. @endif