Skip to content

Commit f500d34

Browse files
authored
Merge pull request #203 from rappasoft/develop
Bootstrap Fixes
2 parents 3236a62 + 09f22c5 commit f500d34

File tree

10 files changed

+157
-90
lines changed

10 files changed

+157
-90
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
44

55
## [Unreleased]
66

7+
## [1.0.1] - 2021-04-17
8+
9+
### Changed
10+
11+
- Fixed missing bootstrap components aliased to bs4.table.*
12+
- Updated readme
13+
- Added missing row click on bootstrap
14+
715
## [1.0.0] - 2021-04-16
816

917
- Ground up rebuild, see documentation for usage.
@@ -155,7 +163,8 @@ All notable changes to `laravel-livewire-tables` will be documented in this file
155163

156164
- Initial release
157165

158-
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.0...development
166+
[Unreleased]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.1...development
167+
[1.0.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v1.0.0...v1.0.1
159168
[1.0.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.4.0...v1.0.0
160169
[0.4.0]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.3.3...v0.4.0
161170
[0.3.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.3.2...v0.3.3

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public function rowView(): string
120120
```
121121

122122
```html
123-
<x-livewire-tables::table.cell>
123+
<x-livewire-tables::table.cell> // Note: Tailwind Specific, see below.
124124
{{ ucfirst($row->type) }}
125125
</x-livewire-tables::table.cell>
126126

@@ -170,6 +170,12 @@ To create cells, you should use the `<x-livewire-tables::table.cell>` table cell
170170
</td>
171171
```
172172

173+
**Note:** The default `x-livewire-tables::table.row` and `x-livewire-tables::table.cell` default to Tailwind, for Bootstrap specific versions use `x-livewire-tables::bs4.table.row` and `x-livewire-tables::bs4.table.cell`.
174+
175+
There is also a Tailwind alias of `x-livewire-tables::tw.table.row` and `x-livewire-tables::tw.table.cell` if you want to be specific.
176+
177+
The helpers are generally more for Tailwind users, as Bootstrap does not have any default added classes to their rows or cells.
178+
173179
You are free to publish and change these views as needed.
174180

175181
### Creating Columns
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<td {{ $attributes }}>
2+
{{ $slot }}
3+
</td>

resources/views/bootstrap-4/includes/heading.blade.php renamed to resources/views/bootstrap-4/components/table/heading.blade.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1-
@unless ($column->isSortable())
2-
<th class="{{ $column->class() ?? '' }}">
3-
{{ $column->text() ?? '' }}
1+
@props([
2+
'column',
3+
'sortable' => null,
4+
'direction' => null,
5+
'text' => null,
6+
])
7+
8+
@unless ($sortable)
9+
<th {{ $attributes->only('class') }}>
10+
{{ $text ?? $slot }}
411
</th>
512
@else
613
<th
7-
wire:click="sortBy('{{ $column->column() }}', '{{ $column->text() ?? $column->column() }}')"
8-
class="{{ $column->class() ?? '' }}"
14+
wire:click="sortBy('{{ $column }}', '{{ $text ?? $column }}')"
15+
{{ $attributes->only('class') }}
916
style="cursor:pointer;"
1017
>
1118
<div class="d-flex align-items-center">
12-
<span>{{ $column->text() }}</span>
13-
14-
@php
15-
$direction = $column->column() ? $sorts[$column->column()] ?? null : null;
16-
@endphp
19+
<span>{{ $text }}</span>
1720

1821
<span class="relative d-flex align-items-center">
1922
@if ($direction === 'asc')
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@foreach($columns as $column)
2+
<td>
3+
@if ($column->asHtml)
4+
{{ new \Illuminate\Support\HtmlString($column->formatted($row)) }}
5+
@else
6+
{{ $column->formatted($row) }}
7+
@endif
8+
</td>
9+
@endforeach
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@props(['url' => null])
2+
3+
<tr
4+
{{ $attributes }}
5+
6+
@if ($url)
7+
onclick="window.location='{{ $url }}';"
8+
style="cursor:pointer"
9+
@endif
10+
>
11+
{{ $slot }}
12+
</tr>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<div class="table-responsive">
2+
<table class="table table-striped">
3+
<thead>
4+
<tr>
5+
{{ $head }}
6+
</tr>
7+
</thead>
8+
9+
<tbody>
10+
{{ $body }}
11+
</tbody>
12+
</table>
13+
</div>

resources/views/bootstrap-4/includes/header.blade.php

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 80 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,86 @@
1-
<div class="table-responsive">
2-
<table class="table table-striped">
3-
@include('livewire-tables::bootstrap-4.includes.header')
1+
<x-livewire-tables::bs4.table>
2+
<x-slot name="head">
3+
@if (count($bulkActions))
4+
<x-livewire-tables::bs4.table.heading>
5+
<input
6+
wire:model="selectPage"
7+
type="checkbox"
8+
/>
9+
</x-livewire-tables::bs4.table.heading>
10+
@endif
411

5-
<tbody>
6-
@if (count($bulkActions) && $selectPage && $rows->total() > $rows->count())
7-
<tr wire:key="row-message">
8-
<td colspan="{{ count($bulkActions) ? count($columns) + 1 : count($columns) }}">
9-
@unless ($selectAll)
10-
<div>
11-
<span>{!! __('You have selected <strong>:count</strong> users, do you want to select all <strong>:total</strong>?', ['count' => $rows->count(), 'total' => number_format($rows->total())]) !!}</span>
12+
@foreach($columns as $column)
13+
@if ($column->isBlank())
14+
<x-livewire-tables::bs4.table.heading />
15+
@else
16+
<x-livewire-tables::bs4.table.heading
17+
:sortable="$column->isSortable()"
18+
:column="$column->column()"
19+
:direction="$column->column() ? $sorts[$column->column()] ?? null : null"
20+
:text="$column->text() ?? ''"
21+
:class="$column->class() ?? ''"
22+
/>
23+
@endif
24+
@endforeach
25+
</x-slot>
1226

13-
<button
14-
wire:click="selectAll"
15-
type="button"
16-
class="btn btn-primary btn-sm"
17-
>
18-
@lang('Select All')
19-
</button>
20-
</div>
21-
@else
22-
<div>
23-
<span>{!! __('You are currently selecting all <strong>:total</strong> users.', ['total' => number_format($rows->total())]) !!}</span>
27+
<x-slot name="body">
28+
@if (count($bulkActions) && $selectPage && $rows->total() > $rows->count())
29+
<x-livewire-tables::bs4.table.row wire:key="row-message">
30+
<x-livewire-tables::bs4.table.cell colspan="{{ count($bulkActions) ? count($columns) + 1 : count($columns) }}">
31+
@unless ($selectAll)
32+
<div>
33+
<span>{!! __('You have selected <strong>:count</strong> users, do you want to select all <strong>:total</strong>?', ['count' => $rows->count(), 'total' => number_format($rows->total())]) !!}</span>
2434

25-
<button
26-
wire:click="resetBulk"
27-
type="button"
28-
class="btn btn-primary btn-sm"
29-
>
30-
@lang('Unselect All')
31-
</button>
32-
</div>
33-
@endif
34-
</td>
35-
</tr>
36-
@endif
35+
<button
36+
wire:click="selectAll"
37+
type="button"
38+
class="btn btn-primary btn-sm"
39+
>
40+
@lang('Select All')
41+
</button>
42+
</div>
43+
@else
44+
<div>
45+
<span>{!! __('You are currently selecting all <strong>:total</strong> users.', ['total' => number_format($rows->total())]) !!}</span>
3746

38-
@forelse ($rows as $index => $row)
39-
<tr
40-
wire:loading.class.delay="text-muted"
41-
wire:key="table-row-{{ $row->getKey() }}"
42-
>
43-
@if (count($bulkActions))
44-
<td>
45-
<input
46-
wire:model="selected"
47-
value="{{ $row->getKey() }}"
48-
type="checkbox"
49-
/>
50-
</td>
47+
<button
48+
wire:click="resetBulk"
49+
type="button"
50+
class="btn btn-primary btn-sm"
51+
>
52+
@lang('Unselect All')
53+
</button>
54+
</div>
5155
@endif
56+
</x-livewire-tables::bs4.table.cell>
57+
</x-livewire-tables::bs4.table.row>
58+
@endif
59+
60+
@forelse ($rows as $index => $row)
61+
<x-livewire-tables::bs4.table.row
62+
wire:loading.class.delay="text-muted"
63+
wire:key="table-row-{{ $row->getKey() }}"
64+
:url="method_exists($this, 'getTableRowUrl') ? $this->getTableRowUrl($row) : null"
65+
>
66+
@if (count($bulkActions))
67+
<x-livewire-tables::bs4.table.cell>
68+
<input
69+
wire:model="selected"
70+
value="{{ $row->getKey() }}"
71+
type="checkbox"
72+
/>
73+
</x-livewire-tables::bs4.table.cell>
74+
@endif
5275

53-
@include($rowView, ['row' => $row])
54-
</tr>
55-
@empty
56-
<tr>
57-
<td colspan="{{ count($bulkActions) ? count($columns) + 1 : count($columns) }}">
58-
@lang('No items found. Try narrowing your search.')
59-
</td>
60-
</tr>
61-
@endforelse
62-
</tbody>
63-
</table>
64-
</div>
76+
@include($rowView, ['row' => $row])
77+
</x-livewire-tables::bs4.table.row>
78+
@empty
79+
<x-livewire-tables::bs4.table.row>
80+
<x-livewire-tables::bs4.table.cell colspan="{{ count($bulkActions) ? count($columns) + 1 : count($columns) }}">
81+
@lang('No items found. Try narrowing your search.')
82+
</x-livewire-tables::bs4.table.cell>
83+
</x-livewire-tables::bs4.table.row>
84+
@endforelse
85+
</x-slot>
86+
</x-livewire-tables::bs4.table>

src/LaravelLivewireTablesServiceProvider.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ public function bootingPackage(): void
1717
Blade::component('livewire-tables::tailwind.components.table.heading', 'livewire-tables::table.heading');
1818
Blade::component('livewire-tables::tailwind.components.table.row', 'livewire-tables::table.row');
1919
Blade::component('livewire-tables::tailwind.components.table.cell', 'livewire-tables::table.cell');
20+
21+
Blade::component('livewire-tables::tailwind.components.table.table', 'livewire-tables::tw.table');
22+
Blade::component('livewire-tables::tailwind.components.table.heading', 'livewire-tables::tw.table.heading');
23+
Blade::component('livewire-tables::tailwind.components.table.row', 'livewire-tables::tw.table.row');
24+
Blade::component('livewire-tables::tailwind.components.table.cell', 'livewire-tables::tw.table.cell');
25+
26+
Blade::component('livewire-tables::bootstrap-4.components.table.table', 'livewire-tables::bs4.table');
27+
Blade::component('livewire-tables::bootstrap-4.components.table.heading', 'livewire-tables::bs4.table.heading');
28+
Blade::component('livewire-tables::bootstrap-4.components.table.row', 'livewire-tables::bs4.table.row');
29+
Blade::component('livewire-tables::bootstrap-4.components.table.cell', 'livewire-tables::bs4.table.cell');
2030
}
2131

2232
/**

0 commit comments

Comments
 (0)