Skip to content

Commit

Permalink
Merge pull request #3 from oxodesign/support-alignment
Browse files Browse the repository at this point in the history
Support alignment
  • Loading branch information
icetalker authored Aug 28, 2024
2 parents 0eddefb + a83f6ad commit 24f2cb7
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
31 changes: 29 additions & 2 deletions resources/views/table-repeatable-entry.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@php
use Filament\Support\Enums\Alignment;
$isContained = $isContained();
$striped = $getStriped();
$showIndex = $getShowIndex();
Expand Down Expand Up @@ -29,8 +31,33 @@ class="gap-4"
<tr>
@if($showIndex)<th class="filament-table-repeateable-header-cell px-3 py-3.5 sm:first-of-type:ps-6 sm:last-of-type:pe-6"></th>@endif
@foreach($getColumnLabels() as $label)

<th class="it-table-repeateable-header-cell font-semibold text-gray-950 dark:text-white text-start px-3 py-3.5 sm:first-of-type:ps-6 sm:last-of-type:pe-6">{{ $label['name'] }}</th>
@php
$alignment = $label['alignment'];
if (! $alignment instanceof Alignment) {
$alignment = filled($alignment) ? (Alignment::tryFrom($alignment) ?? $alignment) : null;
}
@endphp
<th
@class([
'it-table-repeateable-header-cell font-semibold text-gray-950 dark:text-white text-start py-3.5 sm:first-of-type:ps-3 sm:last-of-type:pe-3',
match ($alignment) {
Alignment::Start => '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'] }}</th>
@endforeach
</tr>
</thead>
Expand Down
1 change: 1 addition & 0 deletions src/Infolists/Components/TableRepeatableEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function setColumnLabels(): void
$this->columnLabels[] = [
'component' => $component->getName(),
'name' => $component->getLabel(),
'alignment' => $component->getAlignment()
];
}
}
Expand Down

0 comments on commit 24f2cb7

Please sign in to comment.