-
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move LoadingPlaceholderStyling into new method
- Loading branch information
Showing
7 changed files
with
116 additions
and
74 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
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(); | ||
$loaderWrapper = $this->getLoadingPlaceHolderWrapperAttributes(); | ||
$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($loaderWrapper) | ||
->class(['hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderWrapper['default'] ?? true)]) | ||
->class(['d-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderWrapper['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
35 changes: 35 additions & 0 deletions
35
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,35 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Configuration; | ||
|
||
trait LoadingPlaceholderStylingConfiguration | ||
{ | ||
public function setLoadingPlaceHolderAttributes(array $attributes): self | ||
{ | ||
$this->loadingPlaceHolderAttributes = $attributes; | ||
|
||
return $this; | ||
} | ||
|
||
public function setLoadingPlaceHolderIconAttributes(array $attributes): self | ||
{ | ||
$this->loadingPlaceHolderIconAttributes = $attributes; | ||
|
||
return $this; | ||
} | ||
|
||
public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self | ||
{ | ||
$this->loadingPlaceHolderWrapperAttributes = $attributes; | ||
|
||
return $this; | ||
} | ||
|
||
public function setLoadingPlaceholderBlade(string $customBlade): self | ||
{ | ||
$this->loadingPlaceholderBlade = $customBlade; | ||
|
||
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,21 @@ | ||
<?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 $loadingPlaceHolderCellAttributes = ['class' => '', 'default' => true]; | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
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,28 @@ | ||
<?php | ||
|
||
namespace Rappasoft\LaravelLivewireTables\Traits\Styling\Helpers; | ||
|
||
use Livewire\Attributes\Computed; | ||
|
||
trait LoadingPlaceholderStylingHelpers | ||
{ | ||
public function getLoadingPlaceholderAttributes(): array | ||
{ | ||
return count($this->loadingPlaceHolderAttributes) ? $this->loadingPlaceHolderAttributes : ['default' => true]; | ||
} | ||
|
||
public function getLoadingPlaceHolderIconAttributes(): array | ||
{ | ||
return count($this->loadingPlaceHolderIconAttributes) ? $this->loadingPlaceHolderIconAttributes : ['default' => true]; | ||
} | ||
|
||
public function getLoadingPlaceHolderWrapperAttributes(): array | ||
{ | ||
return count($this->loadingPlaceHolderWrapperAttributes) ? $this->loadingPlaceHolderWrapperAttributes : ['default' => true]; | ||
} | ||
|
||
public function getLoadingPlaceHolderCellAttributes(): array | ||
{ | ||
return count($this->loadingPlaceHolderCellAttributes) ? $this->loadingPlaceHolderCellAttributes : ['default' => 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