Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

panel-switch-menu.blade.php 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. <!-- x-on:click="location.href = '{{ $getHref($panel) }}'" -->
  64. <a
  65. href="{{ $getHref($panel) }}"
  66. class="flex flex-col items-center justify-center flex-1 hover:cursor-pointer group panel-switch-card"
  67. >
  68. <div
  69. @class([
  70. "p-2 bg-white rounded-lg shadow-md dark:bg-gray-800 panel-switch-card-section",
  71. "group-hover:ring-2 group-hover:ring-primary-600" => $panel->getId() !== $currentPanel->getId(),
  72. "ring-2 ring-primary-600" => $panel->getId() === $currentPanel->getId(),
  73. ])
  74. >
  75. @if ($renderIconAsImage)
  76. <img
  77. class="rounded-lg panel-switch-card-image"
  78. style="width: {{ $iconSize * 4 }}px; height: {{ $iconSize * 4 }}px;"
  79. src="{{ $icons[$panel->getId()] ?? 'https://raw.githubusercontent.com/bezhanSalleh/filament-panel-switch/3.x/art/banner.jpg' }}"
  80. alt="Panel Image"
  81. >
  82. @else
  83. @php
  84. $iconName = $icons[$panel->getId()] ?? 'heroicon-s-square-2-stack' ;
  85. @endphp
  86. @svg($iconName, 'text-primary-600 panel-switch-card-icon', ['style' => 'width: ' . ($iconSize * 4) . 'px; height: ' . ($iconSize * 4). 'px;'])
  87. @endif
  88. </div>
  89. <span
  90. @class([
  91. "mt-2 text-sm font-medium text-center text-gray-400 dark:text-gray-200 break-words panel-switch-card-title",
  92. "text-gray-400 dark:text-gray-200 group-hover:text-primary-600 group-hover:dark:text-primary-400" => $panel->getId() !== $currentPanel->getId(),
  93. "text-primary-600 dark:text-primary-400" => $panel->getId() === $currentPanel->getId(),
  94. ])
  95. >
  96. {{ $labels[$panel->getId()] ?? str($panel->getId())->ucfirst()}}
  97. </span>
  98. </a>
  99. @endforeach
  100. </div>
  101. </x-filament::modal>
  102. @endif