Skip to content

Commit 31cb65c

Browse files
authored
Add initial commit for setPaginationWrapperAttributes
1 parent fd13aa9 commit 31cb65c

File tree

6 files changed

+52
-9
lines changed

6 files changed

+52
-9
lines changed

docs/pagination/available-methods.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,3 +296,14 @@ public function configure(): void
296296
$this->setShouldRetrieveTotalItemCountDisabled();
297297
}
298298
```
299+
300+
## setPaginationWrapperAttributes
301+
302+
Used to set attributes for the "div" that wraps the pagination section
303+
304+
```php
305+
public function configure(): void
306+
{
307+
$this->setPaginationWrapperAttributes(['class' => 'text-lg']);
308+
}
309+
```

resources/views/components/pagination.blade.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
@aware(['component','isTailwind','isBootstrap','isBootstrap4','isBootstrap5'])
22

3-
@if ($this->hasConfigurableAreaFor('before-pagination'))
4-
@include($this->getConfigurableAreaFor('before-pagination'), $this->getParametersForConfigurableArea('before-pagination'))
5-
@endif
3+
@includeWhen(
4+
$this->hasConfigurableAreaFor('before-pagination'),
5+
$this->getConfigurableAreaFor('before-pagination'),
6+
$this->getParametersForConfigurableArea('before-pagination')
7+
)
68

79
@if ($this->isTailwind)
8-
<div>
10+
<div {{ $this->getPaginationWrapperAttributes }}>
911
@if ($this->paginationVisibilityIsEnabled())
1012
<div class="mt-4 px-4 md:p-0 sm:flex justify-between items-center space-y-4 sm:space-y-0">
1113
<div>
@@ -47,7 +49,7 @@
4749
@endif
4850
</div>
4951
@elseif ($this->isBootstrap4)
50-
<div >
52+
<div {{ $this->getPaginationWrapperAttributes }}>
5153
@if ($this->paginationVisibilityIsEnabled())
5254
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
5355
<div class="row mt-3">
@@ -100,7 +102,7 @@
100102
@endif
101103
</div>
102104
@elseif ($this->isBootstrap5)
103-
<div >
105+
<div {{ $this->getPaginationWrapperAttributes }} >
104106
@if ($this->paginationVisibilityIsEnabled())
105107
@if ($this->paginationIsEnabled() && $this->isPaginationMethod('standard') && $this->getRows->lastPage() > 1)
106108
<div class="row mt-3">
@@ -152,6 +154,8 @@
152154
</div>
153155
@endif
154156

155-
@if ($this->hasConfigurableAreaFor('after-pagination'))
156-
@include($this->getConfigurableAreaFor('after-pagination'), $this->getParametersForConfigurableArea('after-pagination'))
157-
@endif
157+
@includeWhen(
158+
$this->hasConfigurableAreaFor('after-pagination'),
159+
$this->getConfigurableAreaFor('after-pagination'),
160+
$this->getParametersForConfigurableArea('after-pagination')
161+
)

src/Traits/Configuration/PaginationConfiguration.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,4 +177,12 @@ public function setShouldRetrieveTotalItemCountDisabled(): self
177177

178178
return $this;
179179
}
180+
181+
public function setPaginationWrapperAttributes(array $paginationWrapperAttributes): self
182+
{
183+
$this->paginationWrapperAttributes = array_merge(['class' => ''], $paginationWrapperAttributes);
184+
185+
return $this;
186+
}
187+
180188
}

src/Traits/Helpers/PaginationHelpers.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,10 @@ public function getShouldRetrieveTotalItemCount(): bool
155155
{
156156
return $this->shouldRetrieveTotalItemCount;
157157
}
158+
159+
#[Computed]
160+
public function getPaginationWrapperAttributes(): array
161+
{
162+
return $this->paginationWrapperAttributes;
163+
}
158164
}

src/Traits/WithPagination.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ trait WithPagination
5252

5353
protected bool $shouldRetrieveTotalItemCount = true;
5454

55+
// Used In Frontend
56+
protected array $paginationWrapperAttributes = ['class' => ''];
57+
58+
5559
public function mountWithPagination(): void
5660
{
5761
$sessionPerPage = session()->get($this->getPerPagePaginationSessionKey(), $this->getPerPageAccepted()[0] ?? 10);

tests/Traits/Helpers/PaginationHelpersTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,14 @@ public function test_can_toggle_total_item_count_retrieval_via_status(): void
173173
$this->assertTrue($this->basicTable->getShouldRetrieveTotalItemCount());
174174

175175
}
176+
177+
public function test_can_get_pagination_wrapper_attributes(): void
178+
{
179+
180+
$this->assertSame(['class' => ''], $this->basicTable->getPaginationWrapperAttributes());
181+
182+
$this->basicTable->setPaginationWrapperAttributes(['class' => 'text-lg']);
183+
184+
$this->assertSame(['class' => 'text-lg'], $this->basicTable->getPaginationWrapperAttributes());
185+
}
176186
}

0 commit comments

Comments
 (0)