From 56ce863ec2a6f0c217244e408ccc87372c3663bf Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 1 Mar 2024 22:40:44 +0000 Subject: [PATCH 1/2] Update Lifecycle Hooks Docs (#1675) --- CHANGELOG.md | 4 ++++ docs/misc/lifecycle-hooks.md | 12 +++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57bc6fcf2..53df42fcc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to `laravel-livewire-tables` will be documented in this file +## UNRELEASED +### Docs +- Amend Lifecycle Hooks document to use "public" rather than "protected" methods + ## [v3.2.2] - 2024-02-29 ### New Features - Add setDefaultPerPage by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1671 diff --git a/docs/misc/lifecycle-hooks.md b/docs/misc/lifecycle-hooks.md index 0ed23f65f..05f490ae8 100644 --- a/docs/misc/lifecycle-hooks.md +++ b/docs/misc/lifecycle-hooks.md @@ -23,20 +23,26 @@ This is called immediately after the Columns are set up This is called immediately after the query is executed, and is passed the result from the executed query. ## Use in Traits -To use these in a trait, append the Lifecycle Hook with your trait name, e.g. +To use these in a trait, allowing you to easily set defaults across multiple tables, you should ensure that you append the Lifecycle Hook with your trait name, e.g. + +You can then add the trait to your tables, allowing you to centralise your defaults, and avoid code duplication. ```php trait StandardTableMethods { - protected function configuringStandardTableMethods() + public function configuringStandardTableMethods() { // Your standard configure() options go here, anything set here will be over-ridden by the configure() method + // For Example + $this->setColumnSelectDisabled(); } - protected function configuredStandardTableMethods() + public function configuredStandardTableMethods() { // Your standard configure() options go here, anything set here will override those set in the configure() method + // For Example + $this->setColumnSelectDisabled(); } } From ac641df93c90fe1dad733bb2c40613a786566949 Mon Sep 17 00:00:00 2001 From: Joe <104938042+lrljoe@users.noreply.github.com> Date: Fri, 1 Mar 2024 23:44:56 +0000 Subject: [PATCH 2/2] setPerPageFieldAttributes - Customise perPage Dropdown Attributes (#1677) * Add capability to customise colors/styling on the Pagination Per-Page Dropdown --------- Co-authored-by: lrljoe --- .gitattributes | 2 +- CHANGELOG.md | 7 +- docs/pagination/available-methods.md | 35 ++++++++ .../items/pagination-dropdown.blade.php | 17 ++-- src/LaravelLivewireTablesServiceProvider.php | 2 +- .../Configuration/PaginationConfiguration.php | 7 ++ src/Traits/Helpers/PaginationHelpers.php | 8 ++ src/Traits/WithPagination.php | 2 + .../Traits/Helpers/PaginationHelpersTest.php | 25 ++++++ .../Traits/Visuals/PaginationVisualsTest.php | 90 +++++++++++++++++++ 10 files changed, 184 insertions(+), 11 deletions(-) diff --git a/.gitattributes b/.gitattributes index 1a9c40ace..5fb810aac 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,7 +6,7 @@ /.phpunit.cache export-ignore /build export-ignore /database/database.sqlite export-ignore -/database/sqlite.database. export-ignore +/database/sqlite.database export-ignore /docs export-ignore /resources/views/tests export-ignore /tests export-ignore diff --git a/CHANGELOG.md b/CHANGELOG.md index 53df42fcc..883695ef2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,10 @@ All notable changes to `laravel-livewire-tables` will be documented in this file -## UNRELEASED +## [v3.2.3] - 2024-03-01 +### New Features +- Add capability to customise colors/styling on the Pagination Per-Page Dropdown by @lrljoe in https://github.com/rappasoft/laravel-livewire-tables/pull/1677 + ### Docs - Amend Lifecycle Hooks document to use "public" rather than "protected" methods @@ -1153,4 +1156,4 @@ Ground Up Rebuild [0.1.4]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.3...v0.1.4 [0.1.3]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.2...v0.1.3 [0.1.2]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.1...v0.1.2 -[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1 \ No newline at end of file +[0.1.1]: https://github.com/rappasoft/laravel-livewire-tables/compare/v0.1.0...v0.1.1 diff --git a/docs/pagination/available-methods.md b/docs/pagination/available-methods.md index 66f758115..d1b60a375 100644 --- a/docs/pagination/available-methods.md +++ b/docs/pagination/available-methods.md @@ -228,3 +228,38 @@ public function configure(): void $this->setDisplayPaginationDetailsDisabled(); } ``` + +## setPerPageFieldAttributes +Allows for customisation of the appearance of the "Per Page" dropdown + +Note that this utilises a refreshed approach for attributes, and allows for appending to, or replacing the styles and colors independently, via the below methods. + +### default-colors +Setting to false will disable the default colors for the Per Page dropdown, the default colors are: +Bootstrap: +None + +Tailwind: +border-gray-300 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-700 dark:text-white dark:border-gray-600 + +### default-styling +Setting to false will disable the default styling for the Per Page dropdown, the default styling is: +Bootstrap 4: +form-control + +Bootstrap 5: +form-select + +Tailwind: +block w-full rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 focus:ring focus:ring-opacity-50 + +```php +public function configure(): void +{ + $this->setPerPageFieldAttributes([ + 'class' => 'border-red-300 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-red-700 dark:text-white dark:border-red-600', // Add these classes to the dropdown + 'default-colors' => false, // Do not output the default colors + 'default-styles' => true, // Output the default styling + ]); +} +``` diff --git a/resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php b/resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php index 879e6eecd..0d114d8a3 100644 --- a/resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php +++ b/resources/views/components/tools/toolbar/items/pagination-dropdown.blade.php @@ -4,14 +4,17 @@ 'ms-0 ms-md-2' => $component->isBootstrap5(), ]) > - merge($component->getPerPageFieldAttributes()) + ->class([ + 'form-control' => $component->isBootstrap4() && $component->getPerPageFieldAttributes()['default-styling'], + 'form-select' => $component->isBootstrap5() && $component->getPerPageFieldAttributes()['default-styling'], + 'block w-full rounded-md shadow-sm transition duration-150 ease-in-out sm:text-sm sm:leading-5 focus:ring focus:ring-opacity-50' => $component->isTailwind() && $component->getPerPageFieldAttributes()['default-styling'], + 'border-gray-300 focus:border-indigo-300 focus:ring-indigo-200 dark:bg-gray-700 dark:text-white dark:border-gray-600' => $component->isTailwind() && $component->getPerPageFieldAttributes()['default-colors'], ]) + ->except(['default','default-styling','default-colors']) + }} > @foreach ($component->getPerPageAccepted() as $item)