您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

enhanced-stat.blade.php 6.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. @php
  2. use Filament\Support\Enums\IconPosition;
  3. use Filament\Support\Facades\FilamentView;
  4. $chartColor = $getChartColor() ?? 'gray';
  5. $descriptionColor = $getDescriptionColor() ?? 'gray';
  6. $descriptionIcon = $getDescriptionIcon();
  7. $descriptionIconPosition = $getDescriptionIconPosition();
  8. $url = $getUrl();
  9. $tag = $url ? 'a' : 'div';
  10. $dataChecksum = $generateDataChecksum();
  11. $descriptionIconClasses = \Illuminate\Support\Arr::toCssClasses([
  12. 'fi-wi-stats-overview-stat-description-icon h-5 w-5',
  13. match ($descriptionColor) {
  14. 'gray' => 'text-gray-400 dark:text-gray-500',
  15. default => 'text-custom-500',
  16. },
  17. ]);
  18. $descriptionIconStyles = \Illuminate\Support\Arr::toCssStyles([
  19. \Filament\Support\get_color_css_variables(
  20. $descriptionColor,
  21. shades: [500],
  22. alias: 'widgets::stats-overview-widget.stat.description.icon',
  23. ) => $descriptionColor !== 'gray',
  24. ]);
  25. $prefixLabel = $getPrefixLabel();
  26. $suffixLabel = $getSuffixLabel();
  27. @endphp
  28. <{!! $tag !!}
  29. @if ($url)
  30. {{ \Filament\Support\generate_href_html($url, $shouldOpenUrlInNewTab()) }}
  31. @endif
  32. {{
  33. $getExtraAttributeBag()
  34. ->class([
  35. 'fi-wi-stats-overview-stat relative rounded-xl bg-white p-6 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10',
  36. ])
  37. }}
  38. >
  39. <div class="grid gap-y-2">
  40. <div class="flex items-center gap-x-2">
  41. @if ($icon = $getIcon())
  42. <x-filament::icon
  43. :icon="$icon"
  44. class="fi-wi-stats-overview-stat-icon h-5 w-5 text-gray-400 dark:text-gray-500"
  45. />
  46. @endif
  47. <span
  48. class="fi-wi-stats-overview-stat-label text-sm font-medium text-gray-500 dark:text-gray-400"
  49. >
  50. {{ $getLabel() }}
  51. </span>
  52. </div>
  53. <div
  54. class="fi-wi-stats-overview-stat-value text-2xl font-semibold tracking-tight text-gray-950 dark:text-white"
  55. >
  56. @if ($prefixLabel)
  57. <span class="prefix-label text-base font-medium text-gray-500 dark:text-gray-400">
  58. {{ $prefixLabel }}
  59. </span>
  60. @endif
  61. {{ $getValue() }}
  62. @if ($suffixLabel)
  63. <span class="suffix-label text-base font-medium text-gray-500 dark:text-gray-400">
  64. {{ $suffixLabel }}
  65. </span>
  66. @endif
  67. </div>
  68. @if ($description = $getDescription())
  69. <div class="flex items-center gap-x-1">
  70. @if ($descriptionIcon && in_array($descriptionIconPosition, [IconPosition::Before, 'before']))
  71. <x-filament::icon
  72. :icon="$descriptionIcon"
  73. :class="$descriptionIconClasses"
  74. :style="$descriptionIconStyles"
  75. />
  76. @endif
  77. <span
  78. @class([
  79. 'fi-wi-stats-overview-stat-description text-sm',
  80. match ($descriptionColor) {
  81. 'gray' => 'text-gray-500 dark:text-gray-400',
  82. default => 'fi-color-custom text-custom-600 dark:text-custom-400',
  83. },
  84. is_string($descriptionColor) ? "fi-color-{$descriptionColor}" : null,
  85. ])
  86. @style([
  87. \Filament\Support\get_color_css_variables(
  88. $descriptionColor,
  89. shades: [400, 600],
  90. alias: 'widgets::stats-overview-widget.stat.description',
  91. ) => $descriptionColor !== 'gray',
  92. ])
  93. >
  94. {{ $description }}
  95. </span>
  96. @if ($descriptionIcon && in_array($descriptionIconPosition, [IconPosition::After, 'after']))
  97. <x-filament::icon
  98. :icon="$descriptionIcon"
  99. :class="$descriptionIconClasses"
  100. :style="$descriptionIconStyles"
  101. />
  102. @endif
  103. </div>
  104. @endif
  105. </div>
  106. @if ($chart = $getChart())
  107. {{-- An empty function to initialize the Alpine component with until it's loaded with `ax-load`. This removes the need for `x-ignore`, allowing the chart to be updated via Livewire polling. --}}
  108. <div x-data="{ statsOverviewStatChart: function () {} }">
  109. <div
  110. @if (FilamentView::hasSpaMode())
  111. ax-load="visible"
  112. @else
  113. ax-load
  114. @endif
  115. ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('stats-overview/stat/chart', 'filament/widgets') }}"
  116. x-data="statsOverviewStatChart({
  117. dataChecksum: @js($dataChecksum),
  118. labels: @js(array_keys($chart)),
  119. values: @js(array_values($chart)),
  120. })"
  121. @class([
  122. 'fi-wi-stats-overview-stat-chart absolute inset-x-0 bottom-0 overflow-hidden rounded-b-xl',
  123. match ($chartColor) {
  124. 'gray' => null,
  125. default => 'fi-color-custom',
  126. },
  127. is_string($chartColor) ? "fi-color-{$chartColor}" : null,
  128. ])
  129. @style([
  130. \Filament\Support\get_color_css_variables(
  131. $chartColor,
  132. shades: [50, 400, 500],
  133. alias: 'widgets::stats-overview-widget.stat.chart',
  134. ) => $chartColor !== 'gray',
  135. ])
  136. >
  137. <canvas x-ref="canvas" class="h-6"></canvas>
  138. <span
  139. x-ref="backgroundColorElement"
  140. @class([
  141. match ($chartColor) {
  142. 'gray' => 'text-gray-100 dark:text-gray-800',
  143. default => 'text-custom-50 dark:text-custom-400/10',
  144. },
  145. ])
  146. ></span>
  147. <span
  148. x-ref="borderColorElement"
  149. @class([
  150. match ($chartColor) {
  151. 'gray' => 'text-gray-400',
  152. default => 'text-custom-500 dark:text-custom-400',
  153. },
  154. ])
  155. ></span>
  156. </div>
  157. </div>
  158. @endif
  159. </{!! $tag !!}>