Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

custom-section.blade.php 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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-section',
  62. 'fi-aside grid grid-cols-1 items-start gap-x-6 gap-y-4 md:grid-cols-3' => $aside && $contained,
  63. 'fi-aside grid grid-cols-1 items-start gap-x-6 gap-y-4 md:grid-cols-3 pt-4' => $aside && ! $contained,
  64. 'rounded-xl bg-white shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10' => $contained && ! $aside,
  65. ])
  66. }}
  67. >
  68. @if ($hasHeader)
  69. <header
  70. @if ($collapsible)
  71. x-on:click="isCollapsed = ! isCollapsed"
  72. @endif
  73. @class([
  74. 'fi-section-header flex flex-col gap-3',
  75. 'cursor-pointer' => $collapsible,
  76. 'px-6 py-4' => $contained && ! $aside,
  77. 'px-4 py-2.5' => $compact && ! $aside,
  78. 'py-4' => ! $compact && ! $aside,
  79. ])
  80. >
  81. <div class="flex items-center gap-3">
  82. @if ($hasIcon)
  83. <x-filament::icon
  84. :icon="$icon"
  85. @class([
  86. 'fi-section-header-icon self-start',
  87. match ($iconColor) {
  88. 'gray' => 'text-gray-400 dark:text-gray-500',
  89. default => 'fi-color-custom text-custom-500 dark:text-custom-400',
  90. },
  91. is_string($iconColor) ? "fi-color-{$iconColor}" : null,
  92. match ($iconSize) {
  93. IconSize::Small, 'sm' => 'h-4 w-4 mt-1',
  94. IconSize::Medium, 'md' => 'h-5 w-5 mt-0.5',
  95. IconSize::Large, 'lg' => 'h-6 w-6',
  96. default => $iconSize,
  97. },
  98. ])
  99. @style([
  100. \Filament\Support\get_color_css_variables(
  101. $iconColor,
  102. shades: [400, 500],
  103. alias: 'section.header.icon',
  104. ) => $iconColor !== 'gray',
  105. ])
  106. />
  107. @endif
  108. @if ($hasHeading || $hasDescription)
  109. <div class="grid flex-1 gap-y-1">
  110. @if ($hasHeading)
  111. <x-filament::section.heading>
  112. {{ $heading }}
  113. </x-filament::section.heading>
  114. @endif
  115. @if ($hasDescription)
  116. <x-filament::section.description>
  117. {{ $description }}
  118. </x-filament::section.description>
  119. @endif
  120. </div>
  121. @endif
  122. @if ($hasHeaderActions)
  123. <div class="hidden sm:block">
  124. <x-filament::actions
  125. :actions="$headerActions"
  126. :alignment="\Filament\Support\Enums\Alignment::Start"
  127. x-on:click.stop=""
  128. />
  129. </div>
  130. @endif
  131. {{ $headerEnd }}
  132. @if ($collapsible)
  133. <x-filament::icon-button
  134. color="gray"
  135. icon="heroicon-m-chevron-down"
  136. icon-alias="section.collapse-button"
  137. x-on:click.stop="isCollapsed = ! isCollapsed"
  138. x-bind:class="{ 'rotate-180': ! isCollapsed }"
  139. />
  140. @endif
  141. </div>
  142. @if ($hasHeaderActions)
  143. <div class="sm:hidden">
  144. <x-filament::actions
  145. :actions="$headerActions"
  146. :alignment="\Filament\Support\Enums\Alignment::Start"
  147. x-on:click.stop=""
  148. />
  149. </div>
  150. @endif
  151. </header>
  152. @endif
  153. <div
  154. @if ($collapsible)
  155. x-bind:aria-expanded="(! isCollapsed).toString()"
  156. @if ($collapsed || $persistCollapsed)
  157. x-cloak
  158. @endif
  159. x-bind:class="{ 'invisible h-0 overflow-y-hidden border-none': isCollapsed }"
  160. @endif
  161. @class([
  162. 'fi-section-content-ctn',
  163. 'border-t border-gray-200 dark:border-white/10' => $hasHeader && ! $aside && $contained,
  164. 'rounded-xl bg-white shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10 md:col-span-2' => $aside && $contained,
  165. 'md:col-span-2' => $aside && ! $contained,
  166. 'md:order-first' => $contentBefore,
  167. ])
  168. >
  169. <div
  170. @class([
  171. 'fi-section-content',
  172. 'pt-4' => ! $contained && ! $aside,
  173. 'p-4' => $compact && $contained,
  174. 'p-6' => ! $compact && $contained,
  175. ])
  176. >
  177. {{ $slot }}
  178. </div>
  179. @if ($hasFooterActions)
  180. <footer
  181. @class([
  182. 'fi-section-footer',
  183. 'border-t border-gray-200 dark:border-white/10' => $contained,
  184. 'mt-6' => ! $contained,
  185. 'px-6 py-4' => ! $compact && $contained,
  186. 'px-4 py-2.5' => $compact && $contained,
  187. ])
  188. >
  189. <x-filament::actions
  190. :actions="$footerActions"
  191. :alignment="$footerActionsAlignment"
  192. />
  193. </footer>
  194. @endif
  195. </div>
  196. </section>