Skip to content

Commit

Permalink
Tidy up Blade Class Definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
lrljoe authored Jan 4, 2025
1 parent fe3abd6 commit 4754552
Show file tree
Hide file tree
Showing 15 changed files with 128 additions and 81 deletions.
20 changes: 11 additions & 9 deletions resources/views/components/includes/actions.blade.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<div {{ $attributes
->merge($this->getActionWrapperAttributes)
->class(['flex flex-cols py-2 space-x-2' => $this->isTailwind && $this->getActionWrapperAttributes['default-styling'] ?? true])
->class(['' => $this->isTailwind && $this->getActionWrapperAttributes['default-colors'] ?? true])
->class(['d-flex flex-cols py-2 space-x-2' => $this->isBootstrap && $this->getActionWrapperAttributes['default-styling'] ?? true])
->class(['' => $this->isBootstrap && $this->getActionWrapperAttributes['default-colors'] ?? true])
->class(['justify-start' => $this->getActionsPosition === 'left'])
->class(['justify-center' => $this->getActionsPosition === 'center'])
->class(['justify-end' => $this->getActionsPosition === 'right'])
->class(['pl-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'left'])
->class(['pr-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'right'])
->class([
'flex flex-cols py-2 space-x-2' => $this->isTailwind && ($this->getActionWrapperAttributes['default-styling'] ?? true),
'' => $this->isTailwind && ($this->getActionWrapperAttributes['default-colors'] ?? true),
'd-flex flex-cols py-2 space-x-2' => $this->isBootstrap && ($this->getActionWrapperAttributes['default-styling'] ?? true),
'' => $this->isBootstrap && ($this->getActionWrapperAttributes['default-colors'] ?? true),
'justify-start' => $this->getActionsPosition === 'left',
'justify-center' => $this->getActionsPosition === 'center',
'justify-end' => $this->getActionsPosition === 'right',
'pl-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'left',
'pr-2' => $this->showActionsInToolbar && $this->getActionsPosition === 'right',
])
->except(['default','default-styling','default-colors'])
}} >
@foreach($this->getActions as $action)
Expand Down
18 changes: 12 additions & 6 deletions resources/views/components/includes/loading.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@

<tr wire:key="{{ $tableName }}-loader" wire:loading.class.remove="hidden d-none" {{
$attributes->merge($loaderRow)
->class(['hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderRow['default'] ?? true)])
->class(['d-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderRow['default'] ?? true)])
->class([
'hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderRow['default'] ?? true),
'd-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderRow['default'] ?? true),
])
->except(['default','default-styling','default-colors'])
}}>
<td colspan="{{ $colCount }}" wire:key="{{ $tableName }}-loader-column" {{
$attributes->merge($loaderCell)
->class(['py-4' => $this->isTailwind && ($loaderCell['default'] ?? true)])
->class(['py-4' => $this->isBootstrap && ($loaderCell['default'] ?? true)])
->class([
'py-4' => $this->isTailwind && ($loaderCell['default'] ?? true),
'py-4' => $this->isBootstrap && ($loaderCell['default'] ?? true),
])
->except(['default','default-styling','default-colors', 'colspan','wire:key'])
}}>
@if($this->hasLoadingPlaceholderBlade())
Expand All @@ -25,8 +29,10 @@
<div class="h-min self-center align-middle text-center">
<div class="lds-hourglass"{{
$attributes->merge($loaderIcon)
->class(['lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true)])
->class(['lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true)])
->class([
'lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true),
'lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true),
])
->except(['default','default-styling','default-colors'])
}}></div>
<div>{!! $this->getLoadingPlaceholderContent() !!}</div>
Expand Down
12 changes: 9 additions & 3 deletions resources/views/components/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
<div
wire:key="{{ $tableName }}-twrap"
{{ $attributes->merge($customAttributes['wrapper'])
->class(['shadow overflow-y-auto border-b border-gray-200 dark:border-gray-700 sm:rounded-lg' => $customAttributes['wrapper']['default'] ?? true])
->class([
'shadow overflow-y-auto border-b border-gray-200 dark:border-gray-700 sm:rounded-lg' => $customAttributes['wrapper']['default'] ?? true
])
->except(['default','default-styling','default-colors']) }}
>
<table
Expand All @@ -25,7 +27,9 @@
>
<thead wire:key="{{ $tableName }}-thead"
{{ $attributes->merge($customAttributes['thead'])
->class(['bg-gray-50 dark:bg-gray-800' => $customAttributes['thead']['default'] ?? true])
->class([
'bg-gray-50 dark:bg-gray-800' => $customAttributes['thead']['default'] ?? true
])
->except(['default','default-styling','default-colors']) }}
>
<tr>
Expand All @@ -37,7 +41,9 @@
wire:key="{{ $tableName }}-tbody"
id="{{ $tableName }}-tbody"
{{ $attributes->merge($customAttributes['tbody'])
->class(['bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-none' => $customAttributes['tbody']['default'] ?? true])
->class([
'bg-white divide-y divide-gray-200 dark:bg-gray-800 dark:divide-none' => $customAttributes['tbody']['default'] ?? true
])
->except(['default','default-styling','default-colors']) }}
>
{{ $slot }}
Expand Down
10 changes: 6 additions & 4 deletions resources/views/components/table/collapsed-columns.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
wire:loading.class.delay="opacity-50 dark:bg-gray-900 dark:opacity-60"
{{
$attributes->merge($customAttributes)
->class(['hidden bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 === 0)])
->class(['hidden bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0)])
->class(['d-none bg-light rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 === 0 && ($customAttributes['default'] ?? true))])
->class(['d-none bg-white rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true))])
->class([
'hidden bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 === 0),
'hidden bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0),
'd-none bg-light rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 === 0 && ($customAttributes['default'] ?? true)),
'd-none bg-white rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true)),
])
->except(['default','default-styling','default-colors'])
}}

Expand Down
20 changes: 11 additions & 9 deletions resources/views/components/table/td.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
@endif
{{
$attributes->merge($customAttributes)
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true)])
->class(['hidden' => $isTailwind && $column && $column->shouldCollapseAlways()])
->class(['hidden md:table-cell' => $isTailwind && $column && $column->shouldCollapseOnMobile()])
->class(['hidden lg:table-cell' => $isTailwind && $column && $column->shouldCollapseOnTablet()])
->class(['' => $isBootstrap && ($customAttributes['default'] ?? true)])
->class(['d-none' => $isBootstrap && $column && $column->shouldCollapseAlways()])
->class(['d-none d-md-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnMobile()])
->class(['d-none d-lg-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnTablet()])
->class(['laravel-livewire-tables-cursor' => $isBootstrap && $column && $column->isClickable()])
->class([
'px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true),
'hidden' => $isTailwind && $column && $column->shouldCollapseAlways(),
'hidden md:table-cell' => $isTailwind && $column && $column->shouldCollapseOnMobile(),
'hidden lg:table-cell' => $isTailwind && $column && $column->shouldCollapseOnTablet(),
'' => $isBootstrap && ($customAttributes['default'] ?? true),
'd-none' => $isBootstrap && $column && $column->shouldCollapseAlways(),
'd-none d-md-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnMobile(),
'd-none d-lg-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnTablet(),
'laravel-livewire-tables-cursor' => $isBootstrap && $column && $column->isClickable(),
])
->except(['default','default-styling','default-colors'])
}}
>
Expand Down
19 changes: 12 additions & 7 deletions resources/views/components/table/td/collapsed-columns.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
<td x-data="{open:false}" wire:key="{{ $tableName }}-collapsingIcon-{{ $rowIndex }}-{{ md5(now()) }}"
{{
$attributes
->merge(['class' => 'p-3 table-cell text-center '])
->class(['sm:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
->class(['md:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
->class(['lg:hidden' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
->merge()
->class([
'p-3 table-cell text-center',
'sm:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet(),
'md:hidden' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile(),
'lg:hidden' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile()),
])
}}
:class="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
>
Expand Down Expand Up @@ -45,9 +48,11 @@
<td x-data="{open:false}" wire:key="{{ $tableName }}-collapsingIcon-{{ $rowIndex }}-{{ md5(now()) }}"
{{
$attributes
->class(['d-sm-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
->class(['d-md-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
->class(['d-lg-none' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
->class([
'd-sm-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet(),
'd-md-none' => !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile(),
'd-lg-none' => !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile()),
])
}}
:class="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
>
Expand Down
20 changes: 12 additions & 8 deletions resources/views/components/table/td/plain.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,25 @@
@if ($isTailwind)
<td x-cloak {{ $attributes
->merge($customAttributes)
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $customAttributes['default'] ?? true])
->class(['hidden' => $column && $column->shouldCollapseAlways()])
->class(['hidden md:table-cell' => $column && $column->shouldCollapseOnMobile()])
->class(['hidden lg:table-cell' => $column && $column->shouldCollapseOnTablet()])
->class([
'px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $customAttributes['default'] ?? true,
'hidden' => $column && $column->shouldCollapseAlways(),
'hidden md:table-cell' => $column && $column->shouldCollapseOnMobile(),
'hidden lg:table-cell' => $column && $column->shouldCollapseOnTablet(),
])
->except(['default','default-styling','default-colors'])
}} @if($hideUntilReorder) x-show="reorderDisplayColumn" @endif >
{{ $slot }}
</td>
@elseif ($isBootstrap)
<td {{ $attributes
->merge($customAttributes)
->class(['' => $customAttributes['default'] ?? true])
->class(['d-none' => $column && $column->shouldCollapseAlways()])
->class(['d-none d-md-table-cell' => $column && $column->shouldCollapseOnMobile()])
->class(['d-none d-lg-table-cell' => $column && $column->shouldCollapseOnTablet()])
->class([
'' => $customAttributes['default'] ?? true,
'd-none' => $column && $column->shouldCollapseAlways(),
'd-none d-md-table-cell' => $column && $column->shouldCollapseOnMobile(),
'd-none d-lg-table-cell' => $column && $column->shouldCollapseOnTablet(),
])
->except(['default','default-styling','default-colors'])
}}>
{{ $slot }}
Expand Down
4 changes: 3 additions & 1 deletion resources/views/components/table/th.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
@elseif ($this->isBootstrap)
<div wire:click="sortBy('{{ $column->getColumnSortKey() }}')" {{
$attributes->merge($customSortButtonAttributes)
->class(['d-flex align-items-center laravel-livewire-tables-cursor' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))])
->class([
'd-flex align-items-center laravel-livewire-tables-cursor' => (($customSortButtonAttributes['default-styling'] ?? true) || ($customSortButtonAttributes['default'] ?? true))
])
->except(['default', 'default-colors', 'default-styling', 'wire:key'])
}}>
<x-livewire-tables::table.th.label :$customLabelAttributes :columnTitle="$column->getTitle()" />
Expand Down
12 changes: 7 additions & 5 deletions resources/views/components/table/tr.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@
loopType="{{ ($rowIndex % 2 === 0) ? 'even' : 'odd' }}"
{{
$attributes->merge($customAttributes)
->class(['bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 === 0)])
->class(['bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0)])
->class(['cursor-pointer' => ($isTailwind && $this->hasTableRowUrl() && ($customAttributes['default'] ?? true))])
->class(['bg-light rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 === 0 && ($customAttributes['default'] ?? true))])
->class(['bg-white rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true))])
->class([
'bg-white dark:bg-gray-700 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 === 0),
'bg-gray-50 dark:bg-gray-800 dark:text-white rappasoft-striped-row' => ($isTailwind && ($customAttributes['default'] ?? true) && $rowIndex % 2 !== 0),
'cursor-pointer' => ($isTailwind && $this->hasTableRowUrl() && ($customAttributes['default'] ?? true)),
'bg-light rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 === 0 && ($customAttributes['default'] ?? true)),
'bg-white rappasoft-striped-row' => ($isBootstrap && $rowIndex % 2 !== 0 && ($customAttributes['default'] ?? true)),
])
->except(['default','default-styling','default-colors'])
}}

Expand Down
12 changes: 8 additions & 4 deletions resources/views/components/table/tr/plain.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
@if ($isTailwind)
<tr {{ $attributes
->merge($customAttributes)
->class(['bg-white dark:bg-gray-700 dark:text-white' => $customAttributes['default'] ?? true])
->class(['laravel-livewire-tables-reorderingMinimised'])
->class([
'laravel-livewire-tables-reorderingMinimised',
'bg-white dark:bg-gray-700 dark:text-white' => ($customAttributes['default'] ?? true),
])
->except(['default','default-styling','default-colors'])
}}
>
Expand All @@ -14,8 +16,10 @@
@elseif ($isBootstrap)
<tr {{ $attributes
->merge($customAttributes)
->class(['' => $customAttributes['default'] ?? true])
->class(['laravel-livewire-tables-reorderingMinimised'])
->class([
'laravel-livewire-tables-reorderingMinimised',
'' => $customAttributes['default'] ?? true,
])
->except(['default','default-styling','default-colors'])
}}
>
Expand Down
6 changes: 4 additions & 2 deletions resources/views/components/tools.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

<div {{
$toolsAttributes->merge()
->class(['flex-col' => $isTailwind && ($toolsAttributes['default-styling'] ?? true)])
->class(['d-flex flex-column' => $isBootstrap && ($toolsAttributes['default-styling'] ?? true)])
->class([
'flex-col' => $isTailwind && ($toolsAttributes['default-styling'] ?? true),
'd-flex flex-column' => $isBootstrap && ($toolsAttributes['default-styling'] ?? true)
])
->except(['default','default-styling','default-colors'])
}}
>
Expand Down
8 changes: 5 additions & 3 deletions resources/views/components/tools/filter-label.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@

{{
$attributes->merge($customLabelAttributes)->merge($filterLabelAttributes)
->class(['block text-sm font-medium leading-5 text-gray-700 dark:text-white' => $isTailwind && ($filterLabelAttributes['default'] ?? true)])
->class(['d-block' => $isBootstrap && $filterLayout === 'slide-down' && ($filterLabelAttributes['default'] ?? true)])
->class(['mb-2' => $isBootstrap && $filterLayout === 'popover' && ($filterLabelAttributes['default'] ?? true)])
->class([
'block text-sm font-medium leading-5 text-gray-700 dark:text-white' => $isTailwind && ($filterLabelAttributes['default'] ?? true),
'd-block' => $isBootstrap && $filterLayout === 'slide-down' && ($filterLabelAttributes['default'] ?? true),
'mb-2' => $isBootstrap && $filterLayout === 'popover' && ($filterLabelAttributes['default'] ?? true),
])
->except(['default', 'default-colors', 'default-styling'])
}}

Expand Down
Loading

0 comments on commit 4754552

Please sign in to comment.