From 141f39597b160adce4be6a3f845f445da8649386 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Tue, 1 Oct 2024 04:35:05 +0100 Subject: [PATCH 1/9] Move LoadingPlaceholderStyling into new method --- .../components/includes/loading.blade.php | 55 ++++++++++--------- .../LoadingPlaceholderConfiguration.php | 27 --------- .../Helpers/LoadingPlaceholderHelpers.php | 16 ------ ...LoadingPlaceholderStylingConfiguration.php | 35 ++++++++++++ .../Styling/HasLoadingPlaceholderStyling.php | 21 +++++++ .../LoadingPlaceholderStylingHelpers.php | 28 ++++++++++ src/Traits/WithLoadingPlaceholder.php | 8 +-- 7 files changed, 116 insertions(+), 74 deletions(-) create mode 100644 src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php create mode 100644 src/Traits/Styling/HasLoadingPlaceholderStyling.php create mode 100644 src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php diff --git a/resources/views/components/includes/loading.blade.php b/resources/views/components/includes/loading.blade.php index f22096321..eac12ef07 100644 --- a/resources/views/components/includes/loading.blade.php +++ b/resources/views/components/includes/loading.blade.php @@ -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 - 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" - > - +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']) +}}> + 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 +
-
merge($customAttributes['loader-icon']) - ->class(['lds-hourglass' => $isTailwind && ($customAttributes['loader-icon']['default'] ?? true)]) - ->class(['lds-hourglass' => $isBootstrap && ($customAttributes['loader-icon']['default'] ?? true)]) +
merge($loaderIcon) + ->class(['lds-hourglass' => $this->isTailwind && ($loaderIcon['default'] ?? true)]) + ->class(['lds-hourglass' => $this->isBootstrap && ($loaderIcon['default'] ?? true)]) ->except(['default','default-styling','default-colors']); - }} - >
-
{{ $this->getLoadingPlaceholderContent() }}
+ }}>
+
{!! $this->getLoadingPlaceholderContent() !!}
- - + @endif + + -@endif diff --git a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php index a88bcccda..7cc96cbe7 100644 --- a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php +++ b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php @@ -32,31 +32,4 @@ public function setLoadingPlaceholderContent(string $content): self return $this; } - 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; - } } diff --git a/src/Traits/Helpers/LoadingPlaceholderHelpers.php b/src/Traits/Helpers/LoadingPlaceholderHelpers.php index 4a5a9e7e7..bf93f3229 100644 --- a/src/Traits/Helpers/LoadingPlaceholderHelpers.php +++ b/src/Traits/Helpers/LoadingPlaceholderHelpers.php @@ -19,22 +19,6 @@ public function getLoadingPlaceholderContent(): string return $this->loadingPlaceholderContent ?? __('livewire-tables:loading'); } - 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 hasLoadingPlaceholderBlade(): bool { return ! is_null($this->getLoadingPlaceHolderBlade()); diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php new file mode 100644 index 000000000..9582a5adb --- /dev/null +++ b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php @@ -0,0 +1,35 @@ +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; + } + +} \ No newline at end of file diff --git a/src/Traits/Styling/HasLoadingPlaceholderStyling.php b/src/Traits/Styling/HasLoadingPlaceholderStyling.php new file mode 100644 index 000000000..e399476dc --- /dev/null +++ b/src/Traits/Styling/HasLoadingPlaceholderStyling.php @@ -0,0 +1,21 @@ + '', 'default' => true]; + +} \ No newline at end of file diff --git a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php new file mode 100644 index 000000000..552e37b21 --- /dev/null +++ b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php @@ -0,0 +1,28 @@ +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]; + } +} \ No newline at end of file diff --git a/src/Traits/WithLoadingPlaceholder.php b/src/Traits/WithLoadingPlaceholder.php index 47c3a3072..c9c01faac 100644 --- a/src/Traits/WithLoadingPlaceholder.php +++ b/src/Traits/WithLoadingPlaceholder.php @@ -4,11 +4,13 @@ use Rappasoft\LaravelLivewireTables\Traits\Configuration\LoadingPlaceholderConfiguration; use Rappasoft\LaravelLivewireTables\Traits\Helpers\LoadingPlaceholderHelpers; +use Rappasoft\LaravelLivewireTables\Traits\Styling\HasLoadingPlaceholderStyling; trait WithLoadingPlaceholder { use LoadingPlaceholderConfiguration, - LoadingPlaceholderHelpers; + LoadingPlaceholderHelpers, + HasLoadingPlaceholderStyling; protected bool $displayLoadingPlaceholder = false; @@ -16,9 +18,5 @@ trait WithLoadingPlaceholder protected ?string $loadingPlaceholderBlade = null; - protected array $loadingPlaceHolderAttributes = []; - protected array $loadingPlaceHolderIconAttributes = []; - - protected array $loadingPlaceHolderWrapperAttributes = []; } From 24eaef927a8adf353340fe20af697cda626a340f Mon Sep 17 00:00:00 2001 From: lrljoe Date: Tue, 1 Oct 2024 03:35:35 +0000 Subject: [PATCH 2/9] Fix styling --- .../LoadingPlaceholderConfiguration.php | 1 - ...LoadingPlaceholderStylingConfiguration.php | 69 +++++++++---------- .../Styling/HasLoadingPlaceholderStyling.php | 41 ++++++----- .../LoadingPlaceholderStylingHelpers.php | 56 +++++++-------- src/Traits/WithLoadingPlaceholder.php | 2 - 5 files changed, 82 insertions(+), 87 deletions(-) diff --git a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php index 7cc96cbe7..a5547bf68 100644 --- a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php +++ b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php @@ -31,5 +31,4 @@ public function setLoadingPlaceholderContent(string $content): self return $this; } - } diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php index 9582a5adb..c07a98f57 100644 --- a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php @@ -1,35 +1,34 @@ -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; - } - -} \ No newline at end of file +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; + } +} diff --git a/src/Traits/Styling/HasLoadingPlaceholderStyling.php b/src/Traits/Styling/HasLoadingPlaceholderStyling.php index e399476dc..2d2dda7dc 100644 --- a/src/Traits/Styling/HasLoadingPlaceholderStyling.php +++ b/src/Traits/Styling/HasLoadingPlaceholderStyling.php @@ -1,21 +1,20 @@ - '', 'default' => true]; - -} \ No newline at end of file + '', 'default' => true]; +} diff --git a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php index 552e37b21..d65e785bb 100644 --- a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php +++ b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php @@ -1,28 +1,28 @@ -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]; - } -} \ No newline at end of file +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]; + } +} diff --git a/src/Traits/WithLoadingPlaceholder.php b/src/Traits/WithLoadingPlaceholder.php index c9c01faac..130b6d51b 100644 --- a/src/Traits/WithLoadingPlaceholder.php +++ b/src/Traits/WithLoadingPlaceholder.php @@ -17,6 +17,4 @@ trait WithLoadingPlaceholder protected string $loadingPlaceholderContent = 'Loading'; protected ?string $loadingPlaceholderBlade = null; - - } From cef3b30192500b79f8a334e2580012202ae2a7b1 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 20 Oct 2024 02:47:56 +0100 Subject: [PATCH 3/9] Add "Loading" default translation --- resources/lang/en.json | 2 ++ src/Traits/Helpers/LoadingPlaceholderHelpers.php | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/lang/en.json b/resources/lang/en.json index dcf30f145..1579cbbe2 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -11,6 +11,7 @@ "livewire-tables::Deselect All": "Deselect All", "livewire-tables::Done Reordering": "Done Reordering", "livewire-tables::Filters": "Filters", + "livewire-tables::loading": "Loading", "livewire-tables::max": "Max", "livewire-tables::min": "Min", "livewire-tables::not_applicable": "N/A", @@ -45,6 +46,7 @@ "Deselect All": "Deselect All", "Done Reordering": "Done Reordering", "Filters": "Filters", + "loading": "Loading", "max": "Max", "min": "Min", "not_applicable": "N/A", diff --git a/src/Traits/Helpers/LoadingPlaceholderHelpers.php b/src/Traits/Helpers/LoadingPlaceholderHelpers.php index bf93f3229..cd43c583f 100644 --- a/src/Traits/Helpers/LoadingPlaceholderHelpers.php +++ b/src/Traits/Helpers/LoadingPlaceholderHelpers.php @@ -16,7 +16,7 @@ public function getDisplayLoadingPlaceholder(): bool public function getLoadingPlaceholderContent(): string { - return $this->loadingPlaceholderContent ?? __('livewire-tables:loading'); + return $this->loadingPlaceholderContent ?? __('livewire-tables::loading'); } public function hasLoadingPlaceholderBlade(): bool From e456ee6d7d0005ebd307db8b013b6f434cf535e2 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Sun, 20 Oct 2024 02:58:28 +0100 Subject: [PATCH 4/9] Move Placeholder Blade Config backwards --- .../LoadingPlaceholderConfiguration.php | 8 ++++++++ .../LoadingPlaceholderStylingConfiguration.php | 12 +++--------- .../Helpers/LoadingPlaceholderStylingHelpers.php | 13 +++++++++---- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php index a5547bf68..31154dba4 100644 --- a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php +++ b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php @@ -31,4 +31,12 @@ public function setLoadingPlaceholderContent(string $content): self return $this; } + + public function setLoadingPlaceholderBlade(string $customBlade): self + { + $this->loadingPlaceholderBlade = $customBlade; + + return $this; + } + } diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php index c07a98f57..4496870d1 100644 --- a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php @@ -6,29 +6,23 @@ trait LoadingPlaceholderStylingConfiguration { public function setLoadingPlaceHolderAttributes(array $attributes): self { - $this->loadingPlaceHolderAttributes = $attributes; + $this->setCustomAttributes('loadingPlaceHolderAttributes', $attributes); return $this; } public function setLoadingPlaceHolderIconAttributes(array $attributes): self { - $this->loadingPlaceHolderIconAttributes = $attributes; + $this->setCustomAttributes('loadingPlaceHolderIconAttributes', $attributes); return $this; } public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self { - $this->loadingPlaceHolderWrapperAttributes = $attributes; + $this->setCustomAttributes('loadingPlaceHolderWrapperAttributes', $attributes); return $this; } - public function setLoadingPlaceholderBlade(string $customBlade): self - { - $this->loadingPlaceholderBlade = $customBlade; - - return $this; - } } diff --git a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php index d65e785bb..c08889f44 100644 --- a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php +++ b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php @@ -8,21 +8,26 @@ trait LoadingPlaceholderStylingHelpers { public function getLoadingPlaceholderAttributes(): array { - return count($this->loadingPlaceHolderAttributes) ? $this->loadingPlaceHolderAttributes : ['default' => true]; + return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: true, classicMode: true); + } public function getLoadingPlaceHolderIconAttributes(): array { - return count($this->loadingPlaceHolderIconAttributes) ? $this->loadingPlaceHolderIconAttributes : ['default' => true]; + return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: true, classicMode: true); + } public function getLoadingPlaceHolderWrapperAttributes(): array { - return count($this->loadingPlaceHolderWrapperAttributes) ? $this->loadingPlaceHolderWrapperAttributes : ['default' => true]; + return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderWrapperAttributes', default: true, classicMode: true); + } public function getLoadingPlaceHolderCellAttributes(): array { - return count($this->loadingPlaceHolderCellAttributes) ? $this->loadingPlaceHolderCellAttributes : ['default' => true]; + return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderCellAttributes', default: true, classicMode: true); + } + } From 0118e06a91124d65af7580c57efa47bf562554ff Mon Sep 17 00:00:00 2001 From: lrljoe Date: Sun, 20 Oct 2024 01:58:55 +0000 Subject: [PATCH 5/9] Fix styling --- src/Traits/Configuration/LoadingPlaceholderConfiguration.php | 1 - .../Configuration/LoadingPlaceholderStylingConfiguration.php | 1 - src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php | 1 - 3 files changed, 3 deletions(-) diff --git a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php index 31154dba4..1c7f7b988 100644 --- a/src/Traits/Configuration/LoadingPlaceholderConfiguration.php +++ b/src/Traits/Configuration/LoadingPlaceholderConfiguration.php @@ -38,5 +38,4 @@ public function setLoadingPlaceholderBlade(string $customBlade): self return $this; } - } diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php index 4496870d1..863ef24cc 100644 --- a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php @@ -24,5 +24,4 @@ public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self return $this; } - } diff --git a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php index c08889f44..0d9c6f3b1 100644 --- a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php +++ b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php @@ -29,5 +29,4 @@ public function getLoadingPlaceHolderCellAttributes(): array return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderCellAttributes', default: true, classicMode: true); } - } From 0cde3bc80296a31f88b25f6b68693b917a4785a4 Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Sun, 20 Oct 2024 03:17:44 +0100 Subject: [PATCH 6/9] Adjustments to Placeholder Attributes --- ...LoadingPlaceholderStylingConfiguration.php | 8 ++-- .../LoadingPlaceholderConfigurationTest.php | 39 ++++++++++++++++--- 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php index 863ef24cc..b9bdbc722 100644 --- a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php @@ -6,21 +6,21 @@ trait LoadingPlaceholderStylingConfiguration { public function setLoadingPlaceHolderAttributes(array $attributes): self { - $this->setCustomAttributes('loadingPlaceHolderAttributes', $attributes); - + $this->setCustomAttributes('loadingPlaceHolderAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: false, classicMode: true), ...$attributes]); + return $this; } public function setLoadingPlaceHolderIconAttributes(array $attributes): self { - $this->setCustomAttributes('loadingPlaceHolderIconAttributes', $attributes); + $this->setCustomAttributes('loadingPlaceHolderIconAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderIconAttributes', default: false, classicMode: true), ...$attributes]); return $this; } public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self { - $this->setCustomAttributes('loadingPlaceHolderWrapperAttributes', $attributes); + $this->setCustomAttributes('loadingPlaceHolderWrapperAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderWrapperAttributes', default: false, classicMode: true), ...$attributes]); return $this; } diff --git a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php index 1206f1608..e37c10b85 100644 --- a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php +++ b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php @@ -48,11 +48,20 @@ public function test_can_set_loading_placeholder_attributes(): void { $this->basicTable->setLoadingPlaceholderEnabled(); - $this->assertSame(['default' => true], $this->basicTable->getLoadingPlaceHolderAttributes()); + $this->assertSame(['default' => true, 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderAttributes()); $this->basicTable->setLoadingPlaceHolderAttributes(['class' => 'test12345']); - $this->assertSame(['class' => 'test12345'], $this->basicTable->getLoadingPlaceHolderAttributes()); + $this->assertSame(['class' => 'test12345', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderAttributes()); + + $this->basicTable->setLoadingPlaceHolderAttributes(['class' => 'test12345', 'default' => true, 'default-colors' => true, 'default-styling' => true]); + + $this->assertSame(['class' => 'test12345', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderAttributes()); + + $this->basicTable->setLoadingPlaceHolderAttributes(['class' => 'test12345', 'default' => false, 'default-colors' => false, 'default-styling' => true]); + + $this->assertSame(['class' => 'test12345', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderAttributes()); + } @@ -60,11 +69,20 @@ public function test_can_set_loading_placeholder_icon_attributes(): void { $this->basicTable->setLoadingPlaceholderEnabled(); - $this->assertSame(['default' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes()); + $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes()); $this->basicTable->setLoadingPlaceHolderIconAttributes(['class' => 'test123']); - $this->assertSame(['class' => 'test123'], $this->basicTable->getLoadingPlaceHolderIconAttributes()); + $this->assertSame(['class' => 'test123', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderIconAttributes()); + + $this->basicTable->setLoadingPlaceHolderIconAttributes(['class' => 'test123', 'default' => true, 'default-colors' => true, 'default-styling' => true]); + + $this->assertSame(['class' => 'test123', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes()); + + $this->basicTable->setLoadingPlaceHolderIconAttributes(['class' => 'test123', 'default' => false, 'default-colors' => false, 'default-styling' => true]); + + $this->assertSame(['class' => 'test123', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes()); + } @@ -72,11 +90,20 @@ public function test_can_set_loading_placeholder_wrapper_attributes(): void { $this->basicTable->setLoadingPlaceholderEnabled(); - $this->assertSame(['default' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); $this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper']); - $this->assertSame(['class' => 'test1234567-wrapper'], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + + $this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true]); + + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + + $this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true]); + + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + } public function test_can_set_loading_placeholder_custom_blade(): void From 10d84a076ba83867ecfa534d72e304c413d79ad9 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Sun, 20 Oct 2024 02:18:11 +0000 Subject: [PATCH 7/9] Fix styling --- .../Configuration/LoadingPlaceholderStylingConfiguration.php | 2 +- .../Configuration/LoadingPlaceholderConfigurationTest.php | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php index b9bdbc722..05787e3c3 100644 --- a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php @@ -7,7 +7,7 @@ trait LoadingPlaceholderStylingConfiguration public function setLoadingPlaceHolderAttributes(array $attributes): self { $this->setCustomAttributes('loadingPlaceHolderAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderAttributes', default: false, classicMode: true), ...$attributes]); - + return $this; } diff --git a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php index e37c10b85..03150e8b8 100644 --- a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php +++ b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php @@ -62,7 +62,6 @@ public function test_can_set_loading_placeholder_attributes(): void $this->assertSame(['class' => 'test12345', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderAttributes()); - } public function test_can_set_loading_placeholder_icon_attributes(): void @@ -83,7 +82,6 @@ public function test_can_set_loading_placeholder_icon_attributes(): void $this->assertSame(['class' => 'test123', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderIconAttributes()); - } public function test_can_set_loading_placeholder_wrapper_attributes(): void From 3d5c96a3d7264fa1ecbe37b5f0d074f2711efd5e Mon Sep 17 00:00:00 2001 From: LRLJoe Date: Sun, 20 Oct 2024 03:48:08 +0100 Subject: [PATCH 8/9] Tweak Row Behaviour --- docs/misc/loading-placeholder.md | 20 ++++++++++++- .../components/includes/loading.blade.php | 8 +++--- ...LoadingPlaceholderStylingConfiguration.php | 10 ++++++- .../Styling/HasLoadingPlaceholderStyling.php | 2 ++ .../LoadingPlaceholderStylingHelpers.php | 6 +++- .../LoadingPlaceholderConfigurationTest.php | 28 +++++++++++++++++++ 6 files changed, 67 insertions(+), 7 deletions(-) diff --git a/docs/misc/loading-placeholder.md b/docs/misc/loading-placeholder.md index 20ca7f9b5..67c4977ac 100644 --- a/docs/misc/loading-placeholder.md +++ b/docs/misc/loading-placeholder.md @@ -47,7 +47,9 @@ You may use this method to set custom text for the placeholder: $this->setLoadingPlaceholderContent('Text To Display'); } ``` -### setLoadingPlaceHolderWrapperAttributes +### setLoadingPlaceHolderWrapperAttributes (Deprecated) + +This is replaced by setLoadingPlaceHolderRowAttributes, but remains functional. This method allows you to customise the attributes for the <tr> element used as a Placeholder when the table is loading. Similar to other setAttribute methods, this accepts a range of attributes, and a boolean "default", which will enable/disable the default attributes. @@ -62,6 +64,22 @@ This method allows you to customise the attributes for the <tr> element us ``` +### setLoadingPlaceHolderRowAttributes + +Replaces setLoadingPlaceHolderWrapperAttributes +This method allows you to customise the attributes for the <tr> element used as a Placeholder when the table is loading. Similar to other setAttribute methods, this accepts a range of attributes, and a boolean "default", which will enable/disable the default attributes. + +```php + public function configure(): void + { + $this->setLoadingPlaceHolderRowAttributes([ + 'class' => 'text-bold', + 'default' => false, + ]); + } + +``` + ### setLoadingPlaceHolderIconAttributes This method allows you to customise the attributes for the <div> element that is used solely for the PlaceholderIcon. Similar to other setAttribute methods, this accepts a range of attributes, and a boolean "default", which will enable/disable the default attributes. diff --git a/resources/views/components/includes/loading.blade.php b/resources/views/components/includes/loading.blade.php index eac12ef07..d439e6c93 100644 --- a/resources/views/components/includes/loading.blade.php +++ b/resources/views/components/includes/loading.blade.php @@ -2,15 +2,15 @@ @props(['colCount' => 1]) @php -$loaderWrapper = $this->getLoadingPlaceHolderWrapperAttributes(); +$loaderRow = $this->getLoadingPlaceHolderRowAttributes(); $loaderCell = $this->getLoadingPlaceHolderCellAttributes(); $loaderIcon = $this->getLoadingPlaceHolderIconAttributes(); @endphp 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)]) + $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']) }}> setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]); + + return $this; + } + public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self { - $this->setCustomAttributes('loadingPlaceHolderWrapperAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderWrapperAttributes', default: false, classicMode: true), ...$attributes]); + $this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]); return $this; } diff --git a/src/Traits/Styling/HasLoadingPlaceholderStyling.php b/src/Traits/Styling/HasLoadingPlaceholderStyling.php index 2d2dda7dc..1dbb2b80d 100644 --- a/src/Traits/Styling/HasLoadingPlaceholderStyling.php +++ b/src/Traits/Styling/HasLoadingPlaceholderStyling.php @@ -16,5 +16,7 @@ trait HasLoadingPlaceholderStyling protected array $loadingPlaceHolderWrapperAttributes = []; + protected array $loadingPlaceHolderRowAttributes = []; + protected array $loadingPlaceHolderCellAttributes = ['class' => '', 'default' => true]; } diff --git a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php index 0d9c6f3b1..ef115641f 100644 --- a/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php +++ b/src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php @@ -20,8 +20,12 @@ public function getLoadingPlaceHolderIconAttributes(): array public function getLoadingPlaceHolderWrapperAttributes(): array { - return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderWrapperAttributes', default: true, classicMode: true); + 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 diff --git a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php index 03150e8b8..850efedb8 100644 --- a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php +++ b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php @@ -89,21 +89,49 @@ public function test_can_set_loading_placeholder_wrapper_attributes(): void $this->basicTable->setLoadingPlaceholderEnabled(); $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes()); $this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper']); $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderRowAttributes()); $this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true]); $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes()); $this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true]); $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes()); } + public function test_can_set_loading_placeholder_row_attributes(): void + { + $this->basicTable->setLoadingPlaceholderEnabled(); + + $this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes()); + + $this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper']); + + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderRowAttributes()); + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + + $this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true]); + + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes()); + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + + $this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true]); + + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes()); + $this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes()); + + } + + public function test_can_set_loading_placeholder_custom_blade(): void { $this->basicTable->setLoadingPlaceholderEnabled(); From 677882e986c40bfa1f94d84556b0c9c6b76fdfe4 Mon Sep 17 00:00:00 2001 From: lrljoe Date: Sun, 20 Oct 2024 02:48:37 +0000 Subject: [PATCH 9/9] Fix styling --- .../Configuration/LoadingPlaceholderStylingConfiguration.php | 1 - .../Traits/Configuration/LoadingPlaceholderConfigurationTest.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php index 2590535d7..c07780bdc 100644 --- a/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php +++ b/src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php @@ -18,7 +18,6 @@ public function setLoadingPlaceHolderIconAttributes(array $attributes): self return $this; } - public function setLoadingPlaceHolderRowAttributes(array $attributes): self { $this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]); diff --git a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php index 850efedb8..28a3b97ad 100644 --- a/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php +++ b/tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php @@ -131,7 +131,6 @@ public function test_can_set_loading_placeholder_row_attributes(): void } - public function test_can_set_loading_placeholder_custom_blade(): void { $this->basicTable->setLoadingPlaceholderEnabled();