Skip to content

Commit 414cb11

Browse files
committed
Offline indicator
Updated readme
1 parent 7096695 commit 414cb11

File tree

7 files changed

+36
-1
lines changed

7 files changed

+36
-1
lines changed

CHANGELOG.md

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

55
## [Unreleased]
66

7-
## [1.0.0] - 2021-04-15
7+
## [1.0.0] - 2021-04-16
88

99
- Ground up rebuild, see documentation for usage.
1010

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ There are some class level properties you can set:
366366
| $showSorting | true | Show the sorting pills |
367367
| $showFilters | true | Show the filter pills |
368368
| $refresh | false | Whether or not to refresh the table at a certain interval. false = off, int = ms, string = functionCall |
369+
| $offlineIndicator | true | Shows a red banner when there is no internet connection. |
369370

370371
#### Using more than one table on a page
371372

resources/views/bootstrap-4/datatable.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@if (is_numeric($refresh)) wire:poll.{{ $refresh }}ms @elseif(is_string($refresh)) wire:poll="{{ $refresh }}" @endif
33
class="container-fluid"
44
>
5+
@include('livewire-tables::bootstrap-4.includes.offline')
56
@include('livewire-tables::bootstrap-4.includes.sorting-pills')
67
@include('livewire-tables::bootstrap-4.includes.filter-pills')
78

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@if ($offlineIndicator)
2+
<div wire:offline.class="d-flex align-items-center" wire:offline.class.remove="d-none" class="alert alert-danger d-none">
3+
<svg xmlns="http://www.w3.org/2000/svg" style="width:1.3em;height:1.3em;" fill="none" viewBox="0 0 24 24" stroke="currentColor">
4+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
5+
</svg>
6+
7+
<span class="d-inline-block ml-2">@lang('You are not connected to the internet.')</span>
8+
</div>
9+
@endif

resources/views/tailwind/datatable.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@if (is_numeric($refresh)) wire:poll.{{ $refresh }}ms @elseif(is_string($refresh)) wire:poll="{{ $refresh }}" @endif
33
class="flex-col space-y-4"
44
>
5+
@include('livewire-tables::tailwind.includes.offline')
56
@include('livewire-tables::tailwind.includes.sorting-pills')
67
@include('livewire-tables::tailwind.includes.filter-pills')
78

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@if ($offlineIndicator)
2+
<div wire:offline.class="block mb-3" wire:offline.class.remove="hidden">
3+
<div class="flex">
4+
<div class="flex-shrink-0">
5+
<svg class="h-5 w-5 text-red-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
6+
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
7+
</svg>
8+
</div>
9+
<div class="ml-3">
10+
<h3 class="text-sm font-medium text-red-800">
11+
@lang('You are not connected to the internet.')
12+
</h3>
13+
</div>
14+
</div>
15+
</div>
16+
@endif

src/DataTableComponent.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ abstract class DataTableComponent extends Component
7474
*/
7575
public $refresh = false;
7676

77+
/**
78+
* Whether or not to display an offline message when there is no connection.
79+
*
80+
* @var bool
81+
*/
82+
public $offlineIndicator = true;
83+
7784
/**
7885
* Name of the page parameter for pagination
7986
* Good to change the default if you have more than one datatable on a page.

0 commit comments

Comments
 (0)