Skip to content

Commit 3d5c96a

Browse files
committed
Tweak Row Behaviour
1 parent 10d84a0 commit 3d5c96a

File tree

6 files changed

+67
-7
lines changed

6 files changed

+67
-7
lines changed

docs/misc/loading-placeholder.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ You may use this method to set custom text for the placeholder:
4747
$this->setLoadingPlaceholderContent('Text To Display');
4848
}
4949
```
50-
### setLoadingPlaceHolderWrapperAttributes
50+
### setLoadingPlaceHolderWrapperAttributes (Deprecated)
51+
52+
This is replaced by setLoadingPlaceHolderRowAttributes, but remains functional.
5153

5254
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.
5355

@@ -62,6 +64,22 @@ This method allows you to customise the attributes for the <tr> element us
6264

6365
```
6466

67+
### setLoadingPlaceHolderRowAttributes
68+
69+
Replaces setLoadingPlaceHolderWrapperAttributes
70+
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.
71+
72+
```php
73+
public function configure(): void
74+
{
75+
$this->setLoadingPlaceHolderRowAttributes([
76+
'class' => 'text-bold',
77+
'default' => false,
78+
]);
79+
}
80+
81+
```
82+
6583
### setLoadingPlaceHolderIconAttributes
6684

6785
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.

resources/views/components/includes/loading.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
@props(['colCount' => 1])
33

44
@php
5-
$loaderWrapper = $this->getLoadingPlaceHolderWrapperAttributes();
5+
$loaderRow = $this->getLoadingPlaceHolderRowAttributes();
66
$loaderCell = $this->getLoadingPlaceHolderCellAttributes();
77
$loaderIcon = $this->getLoadingPlaceHolderIconAttributes();
88
@endphp
99

1010
<tr wire:key="{{ $tableName }}-loader" wire:loading.class.remove="hidden d-none" {{
11-
$attributes->merge($loaderWrapper)
12-
->class(['hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderWrapper['default'] ?? true)])
13-
->class(['d-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderWrapper['default'] ?? true)])
11+
$attributes->merge($loaderRow)
12+
->class(['hidden w-full text-center place-items-center align-middle' => $this->isTailwind && ($loaderRow['default'] ?? true)])
13+
->class(['d-none w-100 text-center align-items-center' => $this->isBootstrap && ($loaderRow['default'] ?? true)])
1414
->except(['default','default-styling','default-colors'])
1515
}}>
1616
<td colspan="{{ $colCount }}" wire:key="{{ $tableName }}-loader-column" {{

src/Traits/Styling/Configuration/LoadingPlaceholderStylingConfiguration.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,17 @@ public function setLoadingPlaceHolderIconAttributes(array $attributes): self
1818
return $this;
1919
}
2020

21+
22+
public function setLoadingPlaceHolderRowAttributes(array $attributes): self
23+
{
24+
$this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]);
25+
26+
return $this;
27+
}
28+
2129
public function setLoadingPlaceHolderWrapperAttributes(array $attributes): self
2230
{
23-
$this->setCustomAttributes('loadingPlaceHolderWrapperAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderWrapperAttributes', default: false, classicMode: true), ...$attributes]);
31+
$this->setCustomAttributes('loadingPlaceHolderRowAttributes', [...$this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: false, classicMode: true), ...$attributes]);
2432

2533
return $this;
2634
}

src/Traits/Styling/HasLoadingPlaceholderStyling.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ trait HasLoadingPlaceholderStyling
1616

1717
protected array $loadingPlaceHolderWrapperAttributes = [];
1818

19+
protected array $loadingPlaceHolderRowAttributes = [];
20+
1921
protected array $loadingPlaceHolderCellAttributes = ['class' => '', 'default' => true];
2022
}

src/Traits/Styling/Helpers/LoadingPlaceholderStylingHelpers.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ public function getLoadingPlaceHolderIconAttributes(): array
2020

2121
public function getLoadingPlaceHolderWrapperAttributes(): array
2222
{
23-
return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderWrapperAttributes', default: true, classicMode: true);
23+
return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true);
24+
}
2425

26+
public function getLoadingPlaceHolderRowAttributes(): array
27+
{
28+
return $this->getCustomAttributes(propertyName: 'loadingPlaceHolderRowAttributes', default: true, classicMode: true);
2529
}
2630

2731
public function getLoadingPlaceHolderCellAttributes(): array

tests/Traits/Configuration/LoadingPlaceholderConfigurationTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,21 +89,49 @@ public function test_can_set_loading_placeholder_wrapper_attributes(): void
8989
$this->basicTable->setLoadingPlaceholderEnabled();
9090

9191
$this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
92+
$this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
9293

9394
$this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper']);
9495

9596
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
97+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderRowAttributes());
9698

9799
$this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true]);
98100

99101
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
102+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
100103

101104
$this->basicTable->setLoadingPlaceHolderWrapperAttributes(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true]);
102105

103106
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
107+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
104108

105109
}
106110

111+
public function test_can_set_loading_placeholder_row_attributes(): void
112+
{
113+
$this->basicTable->setLoadingPlaceholderEnabled();
114+
115+
$this->assertSame(['default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
116+
117+
$this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper']);
118+
119+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderRowAttributes());
120+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => false], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
121+
122+
$this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true]);
123+
124+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
125+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => true, 'default-colors' => true, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
126+
127+
$this->basicTable->setLoadingPlaceHolderRowAttributes(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true]);
128+
129+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderRowAttributes());
130+
$this->assertSame(['class' => 'test1234567-wrapper', 'default' => false, 'default-colors' => false, 'default-styling' => true], $this->basicTable->getLoadingPlaceHolderWrapperAttributes());
131+
132+
}
133+
134+
107135
public function test_can_set_loading_placeholder_custom_blade(): void
108136
{
109137
$this->basicTable->setLoadingPlaceholderEnabled();

0 commit comments

Comments
 (0)