-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading Placeholder Adjustments (#1987)
* Move LoadingPlaceholderStyling into new method * Add "Loading" default translation * Move Placeholder Blade Config backwards * Adjustments to Placeholder Attributes * Tweak Row Behaviour --------- Co-authored-by: lrljoe <[email protected]>
- Loading branch information
Showing
10 changed files
with
204 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,38 @@ | ||
@aware(['isTailwind', 'isBootstrap', 'tableName', 'component']) | ||
@aware(['tableName']) | ||
@props(['colCount' => 1]) | ||
|
||
@php | ||
$customAttributes['loader-wrapper'] = $this->getLoadingPlaceHolderWrapperAttributes(); | ||
$customAttributes['loader-icon'] = $this->getLoadingPlaceHolderIconAttributes(); | ||
$loaderRow = $this->getLoadingPlaceHolderRowAttributes(); | ||
$loaderCell = $this->getLoadingPlaceHolderCellAttributes(); | ||
$loaderIcon = $this->getLoadingPlaceHolderIconAttributes(); | ||
@endphp | ||
@if($this->hasLoadingPlaceholderBlade()) | ||
@include($this->getLoadingPlaceHolderBlade(), ['colCount' => $colCount]) | ||
@else | ||
|
||
<tr wire:key="{{ $tableName }}-loader" | ||
{{ | ||
$attributes->merge($customAttributes['loader-wrapper']) | ||
->class(['hidden w-full text-center h-screen place-items-center align-middle' => $isTailwind && ($customAttributes['loader-wrapper']['default'] ?? true)]) | ||
->class(['d-none w-100 text-center h-100 align-items-center' => $isBootstrap && ($customAttributes['loader-wrapper']['default'] ?? true)]); | ||
}} | ||
wire:loading.class.remove="hidden d-none" | ||
> | ||
<td colspan="{{ $colCount }}" wire:key="{{ $tableName }}-loader-column" > | ||
<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)]) | ||
->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)]) | ||
->except(['default','default-styling','default-colors', 'colspan','wire:key']) | ||
}}> | ||
@if($this->hasLoadingPlaceholderBlade()) | ||
@include($this->getLoadingPlaceHolderBlade(), ['colCount' => $colCount]) | ||
@else | ||
|
||
<div class="h-min self-center align-middle text-center"> | ||
<div class="lds-hourglass" | ||
{{ | ||
$attributes->merge($customAttributes['loader-icon']) | ||
->class(['lds-hourglass' => $isTailwind && ($customAttributes['loader-icon']['default'] ?? true)]) | ||
->class(['lds-hourglass' => $isBootstrap && ($customAttributes['loader-icon']['default'] ?? true)]) | ||
<div class="lds-hourglass"{{ | ||
$attributes->merge($loaderIcon) | ||
->class(['lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true)]) | ||
->class(['lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true)]) | ||
->except(['default','default-styling','default-colors']); | ||
}} | ||
></div> | ||
<div>{{ $this->getLoadingPlaceholderContent() }}</div> | ||
}}></div> | ||
<div>{!! $this->getLoadingPlaceholderContent() !!}</div> | ||
</div> | ||
</td> | ||
</tr> | ||
@endif | ||
</td> | ||
</tr> | ||
|
||
@endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration; | ||
|
||
trait LoadingPlaceholderStylingConfiguration | ||
{ | ||
public function setLoadingPlaceHolderAttributes(array $attributes): self | ||
{ | ||
$this->setCustomAttributes('loadingPlaceHolderAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: false, classicMode: true), ...$attributes]); | ||
|
||
return $this; | ||
} | ||
|
||
public function setLoadingPlaceHolderIconAttributes(array $attributes): self | ||
{ | ||
$this->setCustomAttributes('loadingPlaceHolderIconAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: false, classicMode: true), ...$attributes]); | ||
|
||
return $this; | ||
} | ||
|
||
public function setLoadingPlaceHolderRowAttributes(array $attributes): self | ||
{ | ||
$this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]); | ||
|
||
return $this; | ||
} | ||
|
||
public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self | ||
{ | ||
$this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling; | ||
|
||
use Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration\LoadingPlaceholderStylingConfiguration; | ||
use Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers\LoadingPlaceholderStylingHelpers; | ||
|
||
trait HasLoadingPlaceholderStyling | ||
{ | ||
use LoadingPlaceholderStylingConfiguration, | ||
LoadingPlaceholderStylingHelpers; | ||
|
||
protected array $loadingPlaceHolderAttributes = []; | ||
|
||
protected array $loadingPlaceHolderIconAttributes = []; | ||
|
||
protected array $loadingPlaceHolderWrapperAttributes = []; | ||
|
||
protected array $loadingPlaceHolderRowAttributes = []; | ||
|
||
protected array $loadingPlaceHolderCellAttributes = ['class' => '', 'default' => true]; | ||
} |
36 changes: 36 additions & 0 deletions
36
src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; | ||
|
||
use Livewire\Attributes\Computed; | ||
|
||
trait LoadingPlaceholderStylingHelpers | ||
{ | ||
public function getLoadingPlaceholderAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: true, classicMode: true); | ||
|
||
} | ||
|
||
public function getLoadingPlaceHolderIconAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: true, classicMode: true); | ||
|
||
} | ||
|
||
public function getLoadingPlaceHolderWrapperAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true); | ||
} | ||
|
||
public function getLoadingPlaceHolderRowAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true); | ||
} | ||
|
||
public function getLoadingPlaceHolderCellAttributes(): array | ||
{ | ||
return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderCellAttributes', default: true, classicMode: true); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters