Skip to content

Commit 4754552

Browse files
authored
Tidy up Blade Class Definitions
1 parent fe3abd6 commit 4754552

File tree

15 files changed

+128
-81
lines changed

15 files changed

+128
-81
lines changed

resources/views/components/includes/actions.blade.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<div {{ $attributes
22
->merge($this->getActionWrapperAttributes)
3-
->class(['flex flex-cols py-2 space-x-2' => $this->isTailwind && $this->getActionWrapperAttributes['default-styling'] ?? true])
4-
->class(['' => $this->isTailwind && $this->getActionWrapperAttributes['default-colors'] ?? true])
5-
->class(['d-flex flex-cols py-2 space-x-2' => $this->isBootstrap && $this->getActionWrapperAttributes['default-styling'] ?? true])
6-
->class(['' => $this->isBootstrap && $this->getActionWrapperAttributes['default-colors'] ?? true])
7-
->class(['justify-start' => $this->getActionsPosition === 'left'])
8-
->class(['justify-center' => $this->getActionsPosition === 'center'])
9-
->class(['justify-end' => $this->getActionsPosition === 'right'])
10-
->class(['pl-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'left'])
11-
->class(['pr-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'right'])
3+
->class([
4+
'flex flex-cols py-2 space-x-2' => $this->isTailwind && ($this->getActionWrapperAttributes['default-styling'] ?? true),
5+
'' => $this->isTailwind && ($this->getActionWrapperAttributes['default-colors'] ?? true),
6+
'd-flex flex-cols py-2 space-x-2' => $this->isBootstrap && ($this->getActionWrapperAttributes['default-styling'] ?? true),
7+
'' => $this->isBootstrap && ($this->getActionWrapperAttributes['default-colors'] ?? true),
8+
'justify-start' => $this->getActionsPosition === 'left',
9+
'justify-center' => $this->getActionsPosition === 'center',
10+
'justify-end' => $this->getActionsPosition === 'right',
11+
'pl-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'left',
12+
'pr-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'right',
13+
])
1214
->except(['default','default-styling','default-colors'])
1315
}} >
1416
@foreach($this->getActions as $action)

resources/views/components/includes/loading.blade.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,18 @@
99

1010
<tr wire:key="{{ $tableName }}-loader" wire:loading.class.remove="hidden d-none" {{
1111
$attributes->merge($loaderRow)
12-
->class(['hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderRow['default'] ?? true)])
13-
->class(['d-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderRow['default'] ?? true)])
12+
->class([
13+
'hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderRow['default'] ?? true),
14+
'd-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderRow['default'] ?? true),
15+
])
1416
->except(['default','default-styling','default-colors'])
1517
}}>
1618
<td colspan="{{ $colCount }}" wire:key="{{ $tableName }}-loader-column" {{
1719
$attributes->merge($loaderCell)
18-
->class(['py-4' => $this->isTailwind && ($loaderCell['default'] ?? true)])
19-
->class(['py-4' => $this->isBootstrap && ($loaderCell['default'] ?? true)])
20+
->class([
21+
'py-4' => $this->isTailwind && ($loaderCell['default'] ?? true),
22+
'py-4' => $this->isBootstrap && ($loaderCell['default'] ?? true),
23+
])
2024
->except(['default','default-styling','default-colors', 'colspan','wire:key'])
2125
}}>
2226
@if($this->hasLoadingPlaceholderBlade())
@@ -25,8 +29,10 @@
2529
<div class="h-min self-center align-middle text-center">
2630
<div class="lds-hourglass"{{
2731
$attributes->merge($loaderIcon)
28-
->class(['lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true)])
29-
->class(['lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true)])
32+
->class([
33+
'lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true),
34+
'lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true),
35+
])
3036
->except(['default','default-styling','default-colors'])
3137
}}></div>
3238
<div>{!! $this->getLoadingPlaceholderContent() !!}</div>

resources/views/components/table.blade.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
<div
1414
wire:key="{{ $tableName }}-twrap"
1515
{{ $attributes->merge($customAttributes['wrapper'])
16-
->class(['shadow overflow-y-auto border-b border-gray-200 dark:border-gray-700 sm:rounded-lg' => $customAttributes['wrapper']['default'] ?? true])
16+
->class([
17+
'shadow overflow-y-auto border-b border-gray-200 dark:border-gray-700 sm:rounded-lg' => $customAttributes['wrapper']['default'] ?? true
18+
])
1719
->except(['default','default-styling','default-colors']) }}
1820
>
1921
<table
@@ -25,7 +27,9 @@
2527
>
2628
<thead wire:key="{{ $tableName }}-thead"
2729
{{ $attributes->merge($customAttributes['thead'])
28-
->class(['bg-gray-50 dark:bg-gray-800' => $customAttributes['thead']['default'] ?? true])
30+
->class([
31+
'bg-gray-50 dark:bg-gray-800' => $customAttributes['thead']['default'] ?? true
32+
])
2933
->except(['default','default-styling','default-colors']) }}
3034
>
3135
<tr>
@@ -37,7 +41,9 @@
3741
wire:key="{{ $tableName }}-tbody"
3842
id="{{ $tableName }}-tbody"
3943
{{ $attributes->merge($customAttributes['tbody'])
40-
->class(['bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-none' => $customAttributes['tbody']['default'] ?? true])
44+
->class([
45+
'bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-none' => $customAttributes['tbody']['default'] ?? true
46+
])
4147
->except(['default','default-styling','default-colors']) }}
4248
>
4349
{{ $slot }}

resources/views/components/table/collapsed-columns.blade.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@
3434
wire:loading.class.delay="opacity-50 dark:bg-gray-900 dark:opacity-60"
3535
{{
3636
$attributes->merge($customAttributes)
37-
->class(['hidden bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 === 0)])
38-
->class(['hidden bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0)])
39-
->class(['d-none bg-light rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 === 0 && ($customAttributes['default'] ?? true))])
40-
->class(['d-none bg-white rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true))])
37+
->class([
38+
'hidden bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 === 0),
39+
'hidden bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0),
40+
'd-none bg-light rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 === 0 && ($customAttributes['default'] ?? true)),
41+
'd-none bg-white rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true)),
42+
])
4143
->except(['default','default-styling','default-colors'])
4244
}}
4345

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313
@endif
1414
{{
1515
$attributes->merge($customAttributes)
16-
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true)])
17-
->class(['hidden' => $isTailwind && $column && $column->shouldCollapseAlways()])
18-
->class(['hidden md:table-cell' => $isTailwind && $column && $column->shouldCollapseOnMobile()])
19-
->class(['hidden lg:table-cell' => $isTailwind && $column && $column->shouldCollapseOnTablet()])
20-
->class(['' => $isBootstrap && ($customAttributes['default'] ?? true)])
21-
->class(['d-none' => $isBootstrap && $column && $column->shouldCollapseAlways()])
22-
->class(['d-none d-md-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnMobile()])
23-
->class(['d-none d-lg-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnTablet()])
24-
->class(['laravel-livewire-tables-cursor' => $isBootstrap && $column && $column->isClickable()])
16+
->class([
17+
'px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true),
18+
'hidden' => $isTailwind && $column && $column->shouldCollapseAlways(),
19+
'hidden md:table-cell' => $isTailwind && $column && $column->shouldCollapseOnMobile(),
20+
'hidden lg:table-cell' => $isTailwind && $column && $column->shouldCollapseOnTablet(),
21+
'' => $isBootstrap && ($customAttributes['default'] ?? true),
22+
'd-none' => $isBootstrap && $column && $column->shouldCollapseAlways(),
23+
'd-none d-md-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnMobile(),
24+
'd-none d-lg-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnTablet(),
25+
'laravel-livewire-tables-cursor' => $isBootstrap && $column && $column->isClickable(),
26+
])
2527
->except(['default','default-styling','default-colors'])
2628
}}
2729
>

resources/views/components/table/td/collapsed-columns.blade.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
<td x-data="{open:false}" wire:key="{{ $tableName }}-collapsingIcon-{{ $rowIndex }}-{{ md5(now()) }}"
77
{{
88
$attributes
9-
->merge(['class' => 'p-3 table-cell text-center '])
10-
->class(['sm:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
11-
->class(['md:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
12-
->class(['lg:hidden' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
9+
->merge()
10+
->class([
11+
'p-3 table-cell text-center',
12+
'sm:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet(),
13+
'md:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile(),
14+
'lg:hidden' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile()),
15+
])
1316
}}
1417
:class="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
1518
>
@@ -45,9 +48,11 @@
4548
<td x-data="{open:false}" wire:key="{{ $tableName }}-collapsingIcon-{{ $rowIndex }}-{{ md5(now()) }}"
4649
{{
4750
$attributes
48-
->class(['d-sm-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
49-
->class(['d-md-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
50-
->class(['d-lg-none' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
51+
->class([
52+
'd-sm-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet(),
53+
'd-md-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile(),
54+
'd-lg-none' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile()),
55+
])
5156
}}
5257
:class="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
5358
>

resources/views/components/table/td/plain.blade.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,25 @@
55
@if ($isTailwind)
66
<td x-cloak {{ $attributes
77
->merge($customAttributes)
8-
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $customAttributes['default'] ?? true])
9-
->class(['hidden' => $column && $column->shouldCollapseAlways()])
10-
->class(['hidden md:table-cell' => $column && $column->shouldCollapseOnMobile()])
11-
->class(['hidden lg:table-cell' => $column && $column->shouldCollapseOnTablet()])
8+
->class([
9+
'px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $customAttributes['default'] ?? true,
10+
'hidden' => $column && $column->shouldCollapseAlways(),
11+
'hidden md:table-cell' => $column && $column->shouldCollapseOnMobile(),
12+
'hidden lg:table-cell' => $column && $column->shouldCollapseOnTablet(),
13+
])
1214
->except(['default','default-styling','default-colors'])
1315
}} @if($hideUntilReorder) x-show="reorderDisplayColumn" @endif >
1416
{{ $slot }}
1517
</td>
1618
@elseif ($isBootstrap)
1719
<td {{ $attributes
1820
->merge($customAttributes)
19-
->class(['' => $customAttributes['default'] ?? true])
20-
->class(['d-none' => $column && $column->shouldCollapseAlways()])
21-
->class(['d-none d-md-table-cell' => $column && $column->shouldCollapseOnMobile()])
22-
->class(['d-none d-lg-table-cell' => $column && $column->shouldCollapseOnTablet()])
21+
->class([
22+
'' => $customAttributes['default'] ?? true,
23+
'd-none' => $column && $column->shouldCollapseAlways(),
24+
'd-none d-md-table-cell' => $column && $column->shouldCollapseOnMobile(),
25+
'd-none d-lg-table-cell' => $column && $column->shouldCollapseOnTablet(),
26+
])
2327
->except(['default','default-styling','default-colors'])
2428
}}>
2529
{{ $slot }}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@
4444
@elseif ($this->isBootstrap)
4545
<div wire:click="sortBy('{{ $column->getColumnSortKey() }}')" {{
4646
$attributes->merge($customSortButtonAttributes)
47-
->class(['d-flex align-items-center laravel-livewire-tables-cursor' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
47+
->class([
48+
'd-flex align-items-center laravel-livewire-tables-cursor' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))
49+
])
4850
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
4951
}}>
5052
<x-livewire-tables::table.th.label :$customLabelAttributes :columnTitle="$column->getTitle()" />

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@
2222
loopType="{{ ($rowIndex % 2 === 0) ? 'even' : 'odd' }}"
2323
{{
2424
$attributes->merge($customAttributes)
25-
->class(['bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 === 0)])
26-
->class(['bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0)])
27-
->class(['cursor-pointer' => ($isTailwind && $this->hasTableRowUrl() && ($customAttributes['default'] ?? true))])
28-
->class(['bg-light rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 === 0 && ($customAttributes['default'] ?? true))])
29-
->class(['bg-white rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true))])
25+
->class([
26+
'bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 === 0),
27+
'bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0),
28+
'cursor-pointer' => ($isTailwind && $this->hasTableRowUrl() && ($customAttributes['default'] ?? true)),
29+
'bg-light rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 === 0 && ($customAttributes['default'] ?? true)),
30+
'bg-white rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true)),
31+
])
3032
->except(['default','default-styling','default-colors'])
3133
}}
3234

resources/views/components/table/tr/plain.blade.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
@if ($isTailwind)
55
<tr {{ $attributes
66
->merge($customAttributes)
7-
->class(['bg-white dark:bg-gray-700 dark:text-white' => $customAttributes['default'] ?? true])
8-
->class(['laravel-livewire-tables-reorderingMinimised'])
7+
->class([
8+
'laravel-livewire-tables-reorderingMinimised',
9+
'bg-white dark:bg-gray-700 dark:text-white' => ($customAttributes['default'] ?? true),
10+
])
911
->except(['default','default-styling','default-colors'])
1012
}}
1113
>
@@ -14,8 +16,10 @@
1416
@elseif ($isBootstrap)
1517
<tr {{ $attributes
1618
->merge($customAttributes)
17-
->class(['' => $customAttributes['default'] ?? true])
18-
->class(['laravel-livewire-tables-reorderingMinimised'])
19+
->class([
20+
'laravel-livewire-tables-reorderingMinimised',
21+
'' => $customAttributes['default'] ?? true,
22+
])
1923
->except(['default','default-styling','default-colors'])
2024
}}
2125
>

0 commit comments

Comments
 (0)