From a83f6adb7ebbb37ae80d389ea58451f0af5d0007 Mon Sep 17 00:00:00 2001 From: Flamur Mavraj Date: Wed, 28 Aug 2024 09:54:18 +0200 Subject: [PATCH] Support alignment --- .../views/table-repeatable-entry.blade.php | 31 +++++++++++++++++-- .../Components/TableRepeatableEntry.php | 1 + 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/resources/views/table-repeatable-entry.blade.php b/resources/views/table-repeatable-entry.blade.php index c009a37..3adb0cc 100644 --- a/resources/views/table-repeatable-entry.blade.php +++ b/resources/views/table-repeatable-entry.blade.php @@ -1,4 +1,6 @@ @php + use Filament\Support\Enums\Alignment; + $isContained = $isContained(); $striped = $getStriped(); $showIndex = $getShowIndex(); @@ -29,8 +31,33 @@ class="gap-4" @if($showIndex)@endif @foreach($getColumnLabels() as $label) - - {{ $label['name'] }} + @php + $alignment = $label['alignment']; + if (! $alignment instanceof Alignment) { + $alignment = filled($alignment) ? (Alignment::tryFrom($alignment) ?? $alignment) : null; + } + @endphp + 'text-start', + Alignment::Center => 'text-center', + Alignment::End => 'text-end', + Alignment::Left => 'text-left', + Alignment::Right => 'text-right', + Alignment::Justify, Alignment::Between => 'text-justify', + default => $alignment, + }, + match ($alignment) { + Alignment::Start, Alignment::Left => 'justify-start', + Alignment::Center => 'justify-center', + Alignment::End, Alignment::Right => 'justify-end', + Alignment::Between, Alignment::Justify => 'justify-between', + default => null, + } + ]) + >{{ $label['name'] }} @endforeach diff --git a/src/Infolists/Components/TableRepeatableEntry.php b/src/Infolists/Components/TableRepeatableEntry.php index 73ae189..e89ae8b 100644 --- a/src/Infolists/Components/TableRepeatableEntry.php +++ b/src/Infolists/Components/TableRepeatableEntry.php @@ -29,6 +29,7 @@ public function setColumnLabels(): void $this->columnLabels[] = [ 'component' => $component->getName(), 'name' => $component->getLabel(), + 'alignment' => $component->getAlignment() ]; } }