From 1370f1c77650b9c0a88826dbce89d5270bfbe8bc Mon Sep 17 00:00:00 2001 From: Ilya Artamonov Date: Thu, 21 Sep 2023 13:38:23 +0300 Subject: [PATCH] Pagination component improvements (#198) * Adds page change event (#189) Adds first and last pagination items Co-authored-by: gassio * feat: Pagination component refactoring --------- Co-authored-by: gassio Co-authored-by: gassio --- docs/components/pagination.md | 126 ++++++++-- .../pagination/examples/PaginationExample.vue | 5 +- .../examples/PaginationNavigationExample.vue | 2 +- .../examples/PaginationSlotsExample.vue | 23 ++ .../examples/PaginationTableExample.vue | 10 +- .../examples/PaginationWithCustomSlice.vue | 2 +- .../PaginationWithCustomTextExample.vue | 2 +- .../examples/PaginationWithIconsExample.vue | 31 ++- src/components/Pagination/Pagination.vue | 235 ++++++++++++------ 9 files changed, 314 insertions(+), 122 deletions(-) create mode 100644 docs/components/pagination/examples/PaginationSlotsExample.vue diff --git a/docs/components/pagination.md b/docs/components/pagination.md index 0e4b50b..68e6f2c 100644 --- a/docs/components/pagination.md +++ b/docs/components/pagination.md @@ -5,10 +5,16 @@ import PaginationTableExample from './pagination/examples/PaginationTableExample import PaginationWithIconsExample from './pagination/examples/PaginationWithIconsExample.vue'; import PaginationWithCustomTextExample from './pagination/examples/PaginationWithCustomTextExample.vue'; import PaginationWithCustomSlice from './pagination/examples/PaginationWithCustomSlice.vue'; +import PaginationSlotsExample from './pagination/examples/PaginationSlotsExample.vue'; # Vue Pagination - Flowbite +#### Use the Tailwind CSS pagination element to indicate a series of content across various pages based on multiple styles and sizes +The pagination component can be used to navigate across a series of content and data sets for various pages such as blog posts, products, and more. You can use multiple variants of this component with or without icons and even for paginating table data entries. ## Default pagination +Use the following list of pagination items based on two sizes powered by Tailwind CSS utility classes to indicate a series of content for your website. + + ```vue ``` - + +## Pagination with icons +The following pagination component example shows how you can use SVG icons instead of text to show the previous and next pages. + + + +```vue + + +``` + + + + + ## Default with custom length You can use your own pages count in the row by passing props: `slice-length` @@ -41,7 +69,7 @@ const currentPage = ref(1) -## Pagination with navigation layout +## Previous and next ```vue ``` @@ -75,34 +103,14 @@ const currentPage = ref(1) ``` -## Pagination with icons - -```vue - - -``` - - - ## Pagination with custom labels ```vue @@ -117,3 +125,69 @@ const currentPage = ref(1) ``` + + +## Slots example + + + +```vue + + +``` + +## API + +### Props +| Name | Values | Default | +|---------------------------|-------------------------------------|--------------| +| modelValue | `number` | `1` | +| totalPages | `number` | `10` | +| perPage | `number` | `10` | +| totalItems | `number` | `10` | +| layout | `pagination`, `table`, `navigation` | `pagination` | +| showIcons | `boolean` | `false` | +| sliceLength | `number` | `2` | +| previousLabel | `string` | `Previous` | +| nextLabel | `string` | `Next` | +| enableFirstAndLastButtons | `boolean` | `false` | +| showLabels | `boolean` | `true` | +| large | `boolean` | `false` | + +### Events +| Name | Description | +|----------------------|----------------------| +| `update:model-value` | Current page changed | +| `page-changed` | Current page changed | + +### Slots +| Name | Description | +|--------------|-------------------------| +| start | content before buttons | +| end | content after buttons | +| first-button | first button content | +| last-button | last button content | +| prev-button | previous button content | +| next-button | next button content | +| prev-icon | previous icon slot | +| next-icon | next icon slot | +| page-button | page button slot | diff --git a/docs/components/pagination/examples/PaginationExample.vue b/docs/components/pagination/examples/PaginationExample.vue index b1322db..a5a4b9d 100644 --- a/docs/components/pagination/examples/PaginationExample.vue +++ b/docs/components/pagination/examples/PaginationExample.vue @@ -1,6 +1,7 @@ diff --git a/docs/components/pagination/examples/PaginationTableExample.vue b/docs/components/pagination/examples/PaginationTableExample.vue index 8a3105a..244de3e 100644 --- a/docs/components/pagination/examples/PaginationTableExample.vue +++ b/docs/components/pagination/examples/PaginationTableExample.vue @@ -1,11 +1,7 @@