@props([ 'folder', 'cards' => null, // 可選:使用者自訂資料夾顏色 map(controller 帶:pluck('color','folder_id')) 'userColors' => [], ]) @php $all = collect($cards ?? [])->values(); $total = $all->count(); $items = $all->take(9); // 只顯示前 9 個 $count = $items->count(); $pages = (int) ceil(max(1, $total) / 9); $showDots = $total > 9; // 顏色:個人偏好 > 資料夾預設 > 柔和藍 $base = $userColors[$folder->id] ?? ($folder->color ?? '#cfe4ff'); $hex = ltrim($base, '#'); if (strlen($hex) !== 6) { $hex = 'cfe4ff'; } [$r, $g, $b] = [hexdec(substr($hex, 0, 2)), hexdec(substr($hex, 2, 2)), hexdec(substr($hex, 4, 2))]; $light = sprintf('#%02x%02x%02x', min(255, $r + 28), min(255, $g + 28), min(255, $b + 28)); $deep = sprintf('#%02x%02x%02x', max(0, $r - 40), max(0, $g - 40), max(0, $b - 40)); @endphp
{{-- 固定 3×3:不足九個以空槽占位,格線位置不跑版 --}} @for ($i = 0; $i < 9; $i++) @if ($i < $count) @php $c = $items[$i]; $emoji = trim((string) data_get($c, 'icon_emoji', '')); $icon = trim((string) data_get($c, 'icon', 'bi bi-grid-3x3-gap')); $name = data_get($c, 'title') ?? (data_get($c, 'name') ?? ''); @endphp
@if ($emoji !== '') {{ $emoji }} @else @endif {{ $name }}
@else @endif @endfor
{{-- 頁點指示:超過 9 才顯示,最多 5 個,多的加「+」 --}} @if ($showDots) @php $dots = min(5, $pages); @endphp @endif
{{-- 資料夾標題(外層置中、非粗體) --}}
{{ $folder->name }}
@once @push('styles') @endpush @endonce