Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move default attributes out of blades #2136

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ phpunit.xml.bak
phpstan.txt
coverage.xml
./tmp/**
tests.txt
19 changes: 8 additions & 11 deletions resources/views/components/table/empty.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@

@php($attributes = $attributes->merge(['wire:key' => 'empty-message-'.$this->getId()]))

@if ($isTailwind)
<tr {{ $attributes }}>
<td colspan="{{ $this->getColspanCount() }}">
<tr {{ $attributes }}>
<td colspan="{{ $this->getColspanCount() }}">
@if ($isTailwind)
<div class="flex justify-center items-center space-x-2 dark:bg-gray-800">
<span class="font-medium py-8 text-gray-400 text-lg dark:text-white">{{ $this->getEmptyMessage() }}</span>
</div>
</td>
</tr>
@elseif ($isBootstrap)
<tr {{ $attributes }}>
<td colspan="{{ $this->getColspanCount() }}">
@else
{{ $this->getEmptyMessage() }}
</td>
</tr>
@endif

@endif
</td>
</tr>
20 changes: 7 additions & 13 deletions resources/views/components/table/td.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
@props(['column', 'colIndex'])

@php
$customAttributes = $this->getTdAttributes($column, $row, $colIndex, $rowIndex)
$customAttributes = $this->getTdAttributesBag($column, $row, $colIndex, $rowIndex)
@endphp

<td wire:key="{{ $tableName . '-table-td-'.$row->{$primaryKey}.'-'.$column->getSlug() }}"
@if ($column->isClickable())
@if($this->getTableRowUrlTarget($row) === 'navigate') wire:navigate href="{{ $this->getTableRowUrl($row) }}"
@else onclick="window.open('{{ $this->getTableRowUrl($row) }}', '{{ $this->getTableRowUrlTarget($row) ?? '_self' }}')"
@endif
@endif
{{
$attributes->merge($customAttributes)
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium dark:text-white' => $isTailwind && ($customAttributes['default'] ?? true)])
<td {{
$customAttributes->merge()
->class(['px-6 py-4 whitespace-nowrap text-sm font-medium' => $isTailwind && ($customAttributes['default-styling'] ?? ($customAttributes['default'] ?? true))])
->class(['dark:text-white' => $isTailwind && ($customAttributes['default-colors'] ?? ($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()])
Expand All @@ -23,7 +18,6 @@
->class(['d-none d-lg-table-cell' => $isBootstrap && $column && $column->shouldCollapseOnTablet()])
->class(['laravel-livewire-tables-cursor' => $isBootstrap && $column && $column->isClickable()])
->except(['default','default-styling','default-colors'])
}}
>
{{ $slot }}
}}>
{{ $slot }}
</td>
28 changes: 10 additions & 18 deletions resources/views/components/table/td/bulk-actions.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,23 @@
@props(['row', 'rowIndex'])

@php
$customAttributes = $this->getBulkActionsTdAttributes();
$bulkActionsTdCheckboxAttributes = $this->getBulkActionsTdCheckboxAttributes();
$theme = $this->getTheme();
$customAttributes = $this->getBulkActionsTdAttributesNew($row->{$primaryKey});
$bulkActionsTdCheckboxAttributes = $this->getBulkActionsTdCheckboxAttributesNew($row->{$primaryKey});
@endphp

@if ($this->bulkActionsAreEnabled() && $this->hasBulkActions())
<x-livewire-tables::table.td.plain wire:key="{{ $tableName }}-tbody-td-bulk-actions-td-{{ $row->{$primaryKey} }}" :displayMinimisedOnReorder="true" :$customAttributes>
<x-livewire-tables::table.td.plain :$customAttributes>
<div @class([
'inline-flex rounded-md shadow-sm' => $theme === 'tailwind',
'form-check' => $theme === 'bootstrap-5',
'inline-flex rounded-md shadow-sm' => $this->isTailwind,
'form-check' => $this->isBootstrap,
])>
<input
x-cloak x-show="!currentlyReorderingStatus"
x-model="selectedItems"
wire:key="{{ $tableName . 'selectedItems-'.$row->{$primaryKey} }}"
wire:loading.attr.delay="disabled"
value="{{ $row->{$primaryKey} }}"
type="checkbox"
{{
<input {{
$attributes->merge($bulkActionsTdCheckboxAttributes)->class([
'rounded border-gray-300 text-indigo-600 shadow-sm transition duration-150 ease-in-out focus:border-indigo-300 focus:ring focus:ring-indigo-200 focus:ring-opacity-50 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600' => ($theme === 'tailwind') && ($bulkActionsTdCheckboxAttributes['default'] ?? true),
'form-check-input' => ($theme === 'bootstrap-5') && ($bulkActionsTdCheckboxAttributes['default'] ?? true),
'rounded shadow-sm transition duration-150 ease-in-out focus:ring focus:ring-opacity-50' => $this->isTailwind && (($bulkActionsTdCheckboxAttributes['default'] ?? true) || ($bulkActionsTdCheckboxAttributes['default-styling'] ?? true)),
'border-gray-300 text-indigo-600 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-900 dark:text-white dark:border-gray-600 dark:hover:bg-gray-600 dark:focus:bg-gray-600' => $this->isTailwind && (($bulkActionsTdCheckboxAttributes['default'] ?? true) || ($bulkActionsTdCheckboxAttributes['default-colors'] ?? true)),
'form-check-input' => $this->isBootstrap && ($bulkActionsTdCheckboxAttributes['default'] ?? true),
])->except(['default','default-styling','default-colors'])
}}
/>
}} />
</div>
</x-livewire-tables::table.td.plain>
@endif
117 changes: 40 additions & 77 deletions resources/views/components/table/td/collapsed-columns.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,81 +2,44 @@
@props(['rowIndex', 'hidden' => false])

@if ($this->collapsingColumnsAreEnabled() && $this->hasCollapsedColumns())
@if ($isTailwind)
<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())])
}}
:class="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
>
@if (! $hidden)
<button
x-cloak x-show="!currentlyReorderingStatus"
x-on:click.prevent="$dispatch('toggle-row-content', {'tableName': '{{ $tableName }}', 'row': {{ $rowIndex }}}); open = !open"
>
<x-heroicon-o-plus-circle x-cloak x-show="!open"
{{
$attributes->merge($this->getCollapsingColumnButtonExpandAttributes)
->class([
'h-6 w-6' => $this->getCollapsingColumnButtonExpandAttributes['default-styling'] ?? true,
'text-green-600' => $this->getCollapsingColumnButtonExpandAttributes['default-colors'] ?? true,
])
->except(['default','default-styling','default-colors'])
}}
/>
<x-heroicon-o-minus-circle x-cloak x-show="open"
{{
$attributes->merge($this->getCollapsingColumnButtonCollapseAttributes)
->class([
'h-6 w-6' => $this->getCollapsingColumnButtonCollapseAttributes['default-styling'] ?? true,
'text-yellow-600' => $this->getCollapsingColumnButtonCollapseAttributes['default-colors'] ?? true,
])
->except(['default','default-styling','default-colors'])
}}
/>
</button>
@endif
</td>
@elseif ($isBootstrap)
<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="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
>
@if (! $hidden)
<button
x-cloak x-show="!currentlyReorderingStatus"
x-on:click.prevent="$dispatch('toggle-row-content', {'tableName': '{{ $tableName }}', 'row': {{ $rowIndex }}});open = !open"
class="border-0 bg-transparent p-0"
>
<x-heroicon-o-plus-circle x-cloak x-show="!open"
{{
$attributes->merge($this->getCollapsingColumnButtonExpandAttributes)
->class([
'laravel-livewire-tables-btn-lg text-success' => $this->getCollapsingColumnButtonExpandAttributes['default-colors'] ?? true,
])
->except(['default','default-styling','default-colors'])
}}
/>
<x-heroicon-o-minus-circle x-cloak x-show="open"
{{
$attributes->merge($this->getCollapsingColumnButtonExpandAttributes)
->class([
'laravel-livewire-tables-btn-lg text-warning' => $this->getCollapsingColumnButtonExpandAttributes['default-colors'] ?? true,
])
->except(['default','default-styling','default-colors'])
}}
/>
</button>
@endif
</td>
@endif
<td x-data="{open:false}" wire:key="{{ $tableName }}-collapsingIcon-{{ $rowIndex }}-{{ md5(now()) }}"
{{
$attributes->merge()
->class(['p-3 table-cell text-center' => $this->isTailwind])
->class(['sm:hidden' => $this->isTailwind && !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
->class(['md:hidden' => $this->isTailwind && !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
->class(['lg:hidden' => $this->isTailwind && !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])
->class(['d-sm-none' => $this->isBootstrap && !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet()])
->class(['d-md-none' => $this->isBootstrap && !$this->shouldCollapseAlways() && !$this->shouldCollapseOnTablet() && $this->shouldCollapseOnMobile()])
->class(['d-lg-none' => $this->isBootstrap && !$this->shouldCollapseAlways() && ($this->shouldCollapseOnTablet() || $this->shouldCollapseOnMobile())])

}}
:class="currentlyReorderingStatus ? 'laravel-livewire-tables-reorderingMinimised' : ''"
>
@if (! $hidden)
<button x-cloak x-show="!currentlyReorderingStatus" x-on:click.prevent="$dispatch('toggle-row-content', {'tableName': '{{ $tableName }}', 'row': {{ $rowIndex }}}); open = !open" @class([
"border-0 bg-transparent p-0" => $this->isBootstrap
])>
<x-heroicon-o-plus-circle x-cloak x-show="!open" {{
$attributes->merge($this->getCollapsingColumnButtonExpandAttributes)
->class([
'h-6 w-6' => $this->isTailwind && ($this->getCollapsingColumnButtonExpandAttributes['default-styling'] ?? true),
'text-green-600' => $this->isTailwind && ($this->getCollapsingColumnButtonExpandAttributes['default-colors'] ?? true),
'laravel-livewire-tables-btn-lg text-success' => $this->isBootstrap && ($this->getCollapsingColumnButtonExpandAttributes['default-colors'] ?? true),
])
->except(['default','default-styling','default-colors'])
}} />
<x-heroicon-o-minus-circle x-cloak x-show="open" {{
$attributes->merge($this->getCollapsingColumnButtonCollapseAttributes)
->class([
'h-6 w-6' => $this->isTailwind && ($this->getCollapsingColumnButtonCollapseAttributes['default-styling'] ?? true),
'text-yellow-600' => $this->isTailwind && ($this->getCollapsingColumnButtonCollapseAttributes['default-colors'] ?? true),
'laravel-livewire-tables-btn-lg text-warning' => $this->isBootstrap && ($this->getCollapsingColumnButtonExpandAttributes['default-colors'] ?? true),

])
->except(['default','default-styling','default-colors'])
}} />
</button>
@endif
</td>
@endif
36 changes: 13 additions & 23 deletions resources/views/components/table/td/plain.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,16 @@
@props(['column' => null, 'customAttributes' => [], 'displayMinimisedOnReorder' => false, 'hideUntilReorder' => false])


@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()])
->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()])
->except(['default','default-styling','default-colors'])
}}>
{{ $slot }}
</td>
@endif
<td x-cloak {{ $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(['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()])
->except(['default','default-styling','default-colors'])
}} @if($hideUntilReorder) x-show="reorderDisplayColumn" @endif >
{{ $slot }}
</td>
Loading
Loading