Skip to content

Commit 98de49f

Browse files
authored
Further tweaks & tidying
1 parent 7becf76 commit 98de49f

File tree

5 files changed

+38
-57
lines changed

5 files changed

+38
-57
lines changed

resources/views/components/table/th.blade.php

Lines changed: 36 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,66 +7,52 @@
77
$customLabelAttributes = $allThAttributes['labelAttributes'];
88
$customIconAttributes = $this->getThSortIconAttributes($column);
99
$direction = $column->hasField() ? $this->getSort($column->getColumnSelectName()) : $this->getSort($column->getSlug()) ?? null;
10-
1110
@endphp
1211

13-
@if ($this->isTailwind)
14-
<th scope="col" {{
15-
$attributes->merge($customThAttributes)
16-
->class(['text-gray-500 dark:bg-gray-800 dark:text-gray-400' => (($customThAttributes['default-colors'] ?? true) || ($customThAttributes['default'] ?? true))])
17-
->class(['px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => (($customThAttributes['default-styling'] ?? true) || ($customThAttributes['default'] ?? true))])
18-
->class(['hidden' => $column->shouldCollapseAlways()])
19-
->class(['hidden md:table-cell' => $column->shouldCollapseOnMobile()])
20-
->class(['hidden lg:table-cell' => $column->shouldCollapseOnTablet()])
21-
->except(['default', 'default-colors', 'default-styling'])
22-
}}
23-
>
24-
@if($column->getColumnLabelStatus())
25-
@unless ($this->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
26-
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
27-
@else
28-
<button wire:click="sortBy('{{ $column->getColumnSortKey() }}')"
29-
{{
12+
<th {{
13+
$attributes->merge($customThAttributes)
14+
->class([
15+
'text-gray-500 dark:bg-gray-800 dark:text-gray-400' => $this->isTailwind && (($customThAttributes['default-colors'] ?? true) || ($customThAttributes['default'] ?? true)),
16+
'px-6 py-3 text-left text-xs font-medium whitespace-nowrap uppercase tracking-wider' => $this->isTailwind && (($customThAttributes['default-styling'] ?? true) || ($customThAttributes['default'] ?? true)),
17+
'hidden' => $this->isTailwind && $column->shouldCollapseAlways(),
18+
'hidden md:table-cell' => $this->isTailwind && $column->shouldCollapseOnMobile(),
19+
'hidden lg:table-cell' => $this->isTailwind && $column->shouldCollapseOnTablet(),
20+
'' => $this->isBootstrap && ($customThAttributes['default'] ?? true),
21+
'd-none' => $this->isBootstrap && $column->shouldCollapseAlways(),
22+
'd-none d-md-table-cell' => $this->isBootstrap && $column->shouldCollapseOnMobile(),
23+
'd-none d-lg-table-cell' => $this->isBootstrap && $column->shouldCollapseOnTablet(),
24+
])
25+
->except(['default', 'default-colors', 'default-styling'])
26+
}}>
27+
@if($column->getColumnLabelStatus())
28+
@unless ($this->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
29+
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
30+
@else
31+
@if ($this->isTailwind)
32+
33+
<button wire:click="sortBy('{{ $column->getColumnSortKey() }}')" {{
3034
$attributes->merge($customSortButtonAttributes)
31-
->class(['text-gray-500 dark:text-gray-400' => (($customSortButtonAttributes['default-colors'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
32-
->class(['flex items-center space-x-1 text-left text-xs leading-4 font-medium uppercase tracking-wider group focus:outline-none' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
35+
->class([
36+
'text-gray-500 dark:text-gray-400' => (($customSortButtonAttributes['default-colors'] ?? true) || ($customSortButtonAttributes['default'] ?? true)),
37+
'flex items-center space-x-1 text-left text-xs leading-4 font-medium uppercase tracking-wider group focus:outline-none' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true)),
38+
])
3339
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
34-
}}
35-
>
40+
}}>
3641
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
3742
<x-livewire-tables::table.th.sort-icons :$direction :$customIconAttributes />
3843
</button>
39-
@endunless
40-
@endif
41-
</th>
42-
@elseif ($this->isBootstrap)
43-
<th scope="col" {{
44-
$attributes->merge($customThAttributes)
45-
->class(['' => $customThAttributes['default'] ?? true])
46-
->class(['d-none' => $column->shouldCollapseAlways()])
47-
->class(['d-none d-md-table-cell' => $column->shouldCollapseOnMobile()])
48-
->class(['d-none d-lg-table-cell' => $column->shouldCollapseOnTablet()])
49-
->except(['default','default-styling','default-colors'])
50-
}}
51-
>
52-
@if($column->getColumnLabelStatus())
53-
@unless ($this->sortingIsEnabled() && ($column->isSortable() || $column->getSortCallback()))
54-
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
55-
@else
56-
<div
57-
class="d-flex align-items-center laravel-livewire-tables-cursor"
58-
wire:click="sortBy('{{ $column->getColumnSortKey() }}')"
59-
{{
44+
@elseif ($this->isBootstrap)
45+
<div wire:click="sortBy('{{ $column->getColumnSortKey() }}')" {{
6046
$attributes->merge($customSortButtonAttributes)
61-
->class(['' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
47+
->class(['d-flex align-items-center laravel-livewire-tables-cursor' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
6248
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
63-
}}
64-
>
49+
}}>
6550
<span {{ $customLabelAttributes->except(['default', 'default-colors', 'default-styling']) }}>{{ $column->getTitle() }}</span>
6651
<x-livewire-tables::table.th.sort-icons :$direction :$customIconAttributes />
6752

6853
</div>
69-
@endunless
70-
@endif
71-
</th>
72-
@endif
54+
@endif
55+
56+
@endunless
57+
@endif
58+
</th>

resources/views/components/table/th/sort-icons.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
@case('asc')
5959
<x-heroicon-o-chevron-up {{ $attributes->merge($customIconAttributes)
6060
->class([
61-
'laravel-livewire-tables-btn-smaller ms-1 ' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
61+
'laravel-livewire-tables-btn-smaller ms-1' => $customIconAttributes['default-styling'] ?? ($customIconAttributes['default'] ?? true),
6262
])
6363
->except(['default', 'default-colors', 'default-styling', 'wire:key']) }} />
6464
@break

src/Traits/Helpers/TableAttributeHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function getThAttributes(Column $column): array
4747
{
4848

4949
if (isset($this->thAttributesCallback)) {
50-
return array_merge(['default' => false, 'default-colors' => false, 'default-styling' => false], call_user_func($this->thAttributesCallback, $column));
50+
return array_merge(['scope' => 'col', 'default' => false, 'default-colors' => false, 'default-styling' => false], call_user_func($this->thAttributesCallback, $column));
5151
}
5252

5353
return ['default' => true, 'default-colors' => true, 'default-styling' => true];

src/Traits/WithReordering.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,10 @@ public function enablePaginatedReordering(): void {}
5151

5252
public function enableReordering(): void
5353
{
54-
// $this->enablePaginatedReordering();
55-
5654
$this->setReorderingSession();
5755
$this->setReorderingBackup();
5856
$this->resetReorderFields();
5957
$this->reorderStatus = $this->currentlyReorderingStatus = $this->reorderDisplayColumn = true;
60-
6158
}
6259

6360
public function disableReordering(): void

src/Views/Traits/Filters/HasCustomPosition.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,13 @@ public function hasFilterSlidedownColspan(): bool
6767

6868
public function setFilterSlidedownRow(string $filterSlidedownRow): self
6969
{
70-
// $this->filterSlidedownRow = (is_int($filterSlidedownRow) ? $filterSlidedownRow : intval($filterSlidedownRow));
7170
$this->filterSlidedownRow = intval($filterSlidedownRow);
7271

7372
return $this;
7473
}
7574

7675
public function setFilterSlidedownColspan(string $filterSlidedownColspan): self
7776
{
78-
// $this->filterSlidedownColspan = (is_int($filterSlidedownColspan) ? $filterSlidedownColspan : intval($filterSlidedownColspan));
7977
$this->filterSlidedownColspan = intval($filterSlidedownColspan);
8078

8179
return $this;

0 commit comments

Comments
 (0)