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.

custom-section.blade.php 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. @php
  2. use Filament\Support\Enums\Alignment;
  3. use Filament\Support\Enums\IconSize;
  4. @endphp
  5. @props([
  6. 'aside' => false,
  7. 'collapsed' => false,
  8. 'collapsible' => false,
  9. 'compact' => false,
  10. 'contained' => true,
  11. 'contentBefore' => false,
  12. 'description' => null,
  13. 'footerActions' => [],
  14. 'footerActionsAlignment' => Alignment::Start,
  15. 'headerActions' => [],
  16. 'headerEnd' => null,
  17. 'heading' => null,
  18. 'icon' => null,
  19. 'iconColor' => 'gray',
  20. 'iconSize' => IconSize::Large,
  21. 'persistCollapsed' => false,
  22. ])
  23. @php
  24. $hasDescription = filled((string) $description);
  25. $hasHeading = filled($heading);
  26. $hasIcon = filled($icon);
  27. if (is_array($headerActions)) {
  28. $headerActions = array_filter(
  29. $headerActions,
  30. fn ($headerAction): bool => $headerAction->isVisible(),
  31. );
  32. }
  33. if (is_array($footerActions)) {
  34. $footerActions = array_filter(
  35. $footerActions,
  36. fn ($footerAction): bool => $footerAction->isVisible(),
  37. );
  38. }
  39. $hasHeaderActions = $headerActions instanceof \Illuminate\Contracts\Support\Htmlable
  40. ? ! \Filament\Support\is_slot_empty($headerActions)
  41. : filled($headerActions);
  42. $hasFooterActions = $footerActions instanceof \Illuminate\Contracts\Support\Htmlable
  43. ? ! \Filament\Support\is_slot_empty($footerActions)
  44. : filled($footerActions);
  45. $hasHeader = $hasIcon || $hasHeading || $hasDescription || $collapsible || $hasHeaderActions || filled((string) $headerEnd);
  46. @endphp
  47. <section
  48. {{-- TODO: Investigate Livewire bug - https://github.com/filamentphp/filament/pull/8511 --}}
  49. x-data="{
  50. isCollapsed: @if ($persistCollapsed) $persist(@js($collapsed)).as(`section-${$el.id}-isCollapsed`) @else @js($collapsed) @endif,
  51. }"
  52. @if ($collapsible)
  53. x-on:collapse-section.window="if ($event.detail.id == $el.id) isCollapsed = true"
  54. x-on:expand="isCollapsed = false"
  55. x-on:open-section.window="if ($event.detail.id == $el.id) isCollapsed = false"
  56. x-on:toggle-section.window="if ($event.detail.id == $el.id) isCollapsed = ! isCollapsed"
  57. x-bind:class="isCollapsed && 'fi-collapsed'"
  58. @endif
  59. {{
  60. $attributes->class([
  61. 'fi-custom-section',
  62. 'fi-section-not-contained' => ! $contained,
  63. 'fi-section-has-content-before' => $contentBefore,
  64. 'fi-section-has-header' => $hasHeader,
  65. 'fi-aside' => $aside,
  66. 'fi-compact' => $compact,
  67. 'fi-collapsible' => $collapsible,
  68. ])
  69. }}
  70. >
  71. @if ($hasHeader)
  72. <header
  73. @if ($collapsible)
  74. x-on:click="isCollapsed = ! isCollapsed"
  75. @endif
  76. class="fi-section-header"
  77. >
  78. <div class="flex items-center gap-3">
  79. @if ($hasIcon)
  80. <x-filament::icon
  81. :icon="$icon"
  82. @class([
  83. 'fi-section-header-icon',
  84. match ($iconColor) {
  85. 'gray' => null,
  86. default => 'fi-color-custom',
  87. },
  88. is_string($iconColor) ? "fi-color-{$iconColor}" : null,
  89. ($iconSize instanceof IconSize) ? "fi-size-{$iconSize->value}" : (is_string($iconSize) ? $iconSize : null),
  90. ])
  91. @style([
  92. \Filament\Support\get_color_css_variables(
  93. $iconColor,
  94. shades: [400, 500],
  95. alias: 'section.header.icon',
  96. ) => $iconColor !== 'gray',
  97. ])
  98. />
  99. @endif
  100. @if ($hasHeading || $hasDescription)
  101. <div class="fi-section-header-text-ctn">
  102. @if ($hasHeading)
  103. <x-filament::section.heading>
  104. {{ $heading }}
  105. </x-filament::section.heading>
  106. @endif
  107. @if ($hasDescription)
  108. <x-filament::section.description>
  109. {{ $description }}
  110. </x-filament::section.description>
  111. @endif
  112. </div>
  113. @endif
  114. @if ($hasHeaderActions)
  115. <div class="hidden sm:block">
  116. <x-filament::actions
  117. :actions="$headerActions"
  118. :alignment="\Filament\Support\Enums\Alignment::Start"
  119. x-on:click.stop=""
  120. />
  121. </div>
  122. @endif
  123. {{ $headerEnd }}
  124. @if ($collapsible)
  125. <x-filament::icon-button
  126. color="gray"
  127. icon="heroicon-m-chevron-down"
  128. icon-alias="section.collapse-button"
  129. x-on:click.stop="isCollapsed = ! isCollapsed"
  130. x-bind:class="{ 'rotate-180': ! isCollapsed }"
  131. />
  132. @endif
  133. </div>
  134. @if ($hasHeaderActions)
  135. <div class="sm:hidden">
  136. <x-filament::actions
  137. :actions="$headerActions"
  138. :alignment="\Filament\Support\Enums\Alignment::Start"
  139. x-on:click.stop=""
  140. />
  141. </div>
  142. @endif
  143. </header>
  144. @endif
  145. <div
  146. @if ($collapsible)
  147. x-bind:aria-expanded="(! isCollapsed).toString()"
  148. @if ($collapsed || $persistCollapsed)
  149. x-cloak
  150. @endif
  151. @endif
  152. class="fi-section-content-ctn"
  153. >
  154. <div class="fi-section-content">
  155. {{ $slot }}
  156. </div>
  157. @if ($hasFooterActions)
  158. <footer class="fi-section-footer">
  159. <x-filament::actions
  160. :actions="$footerActions"
  161. :alignment="$footerActionsAlignment"
  162. />
  163. </footer>
  164. @endif
  165. </div>
  166. </section>