Skip to content

Commit

Permalink
update requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
monzer15 committed Dec 22, 2023
1 parent 0021733 commit fa3dfd6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ TableRepeater::make('social')
->headers(['Platform', 'Handle'])
```

To change the headers text alignment use the `headersTextAlignment('center')` method.
To change the headers alignment use the `alignHeaders('center')` method.

```php
TableRepeater::make('social')
->headersTextAlignment('center')
->alignHeaders('center')
```

### Labels
Expand Down
9 changes: 6 additions & 3 deletions resources/views/components/table-repeater.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
$emptyLabel = $getEmptyLabel();
$headersTextAlignment = $getHeadersTextAlignment();
$hasActions = $reorderAction->isVisible() || $cloneAction->isVisible() || $deleteAction->isVisible() || $moveUpAction->isVisible() || $moveDownAction->isVisible();
@endphp

Expand Down Expand Up @@ -55,9 +53,14 @@
@foreach ($headers as $key => $header)
<th
@class([
"filament-table-repeater-header-column px-3 py-2 font-medium text-{$headersTextAlignment} bg-gray-100 dark:text-gray-300 dark:bg-gray-900/60",
'filament-table-repeater-header-column px-3 py-2 font-medium bg-gray-100 dark:text-gray-300 dark:bg-gray-900/60',
'ltr:rounded-tl-xl rtl:rounded-tr-xl' => $loop->first,
'ltr:rounded-tr-xl rtl:rounded-tl-xl' => $loop->last && ! $hasActions,
match($getHeadersAlignment()) {
'center' => 'text-center',
'right' => 'text-right rtl:text-left',
default => 'text-left rtl:text-right'
}
])
@if ($header['width'])
style="width: {{ $header['width'] }}"
Expand Down
10 changes: 5 additions & 5 deletions src/Components/TableRepeater.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TableRepeater extends Repeater

protected bool|Closure $withoutHeader = false;

protected string|Closure $headersTextAlignment = "left";
protected string|Closure|null $headersAlignment = null;

public function breakPoint(string $breakPoint = 'md'): static
{
Expand All @@ -44,9 +44,9 @@ public function emptyLabel(bool|string|Closure $label = null): static
return $this;
}

public function headersTextAlignment(string|Closure $alignment = 'left'): static
public function alignHeaders(string|Closure $alignment = 'left'): static
{
$this->headersTextAlignment = $alignment;
$this->headersAlignment = $alignment;

return $this;
}
Expand Down Expand Up @@ -86,9 +86,9 @@ public function getEmptyLabel(): bool|string|null
return $this->evaluate($this->emptyLabel);
}

public function getHeadersTextAlignment(): string
public function getHeadersAlignment(): string
{
return $this->evaluate($this->headersTextAlignment);
return $this->evaluate($this->headersAlignment) ?? 'left';
}

public function getHeaders(): array
Expand Down

0 comments on commit fa3dfd6

Please sign in to comment.