-
Notifications
You must be signed in to change notification settings - Fork 624
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pagination): create component + docs
- Loading branch information
1 parent
a6903df
commit 95bd62e
Showing
8 changed files
with
394 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<script setup> | ||
const page = ref(1) | ||
const items = ref(Array(55)) | ||
</script> | ||
|
||
<template> | ||
<UPagination v-model="page" :page-count="5" :total="items.length" /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<script setup> | ||
const page = ref(1) | ||
const items = ref(Array(100)) | ||
</script> | ||
|
||
<template> | ||
<UPagination v-model="page" :page-count="5" :total="items.length" :max="11" /> | ||
</template> |
53 changes: 53 additions & 0 deletions
53
docs/components/content/examples/TableExamplePaginable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<script setup> | ||
const people = [{ | ||
id: 1, | ||
name: 'Lindsay Walton', | ||
title: 'Front-end Developer', | ||
email: '[email protected]', | ||
role: 'Member' | ||
}, { | ||
id: 2, | ||
name: 'Courtney Henry', | ||
title: 'Designer', | ||
email: '[email protected]', | ||
role: 'Admin' | ||
}, { | ||
id: 3, | ||
name: 'Tom Cook', | ||
title: 'Director of Product', | ||
email: '[email protected]', | ||
role: 'Member' | ||
}, { | ||
id: 4, | ||
name: 'Whitney Francis', | ||
title: 'Copywriter', | ||
email: '[email protected]', | ||
role: 'Admin' | ||
}, { | ||
id: 5, | ||
name: 'Leonard Krasner', | ||
title: 'Senior Designer', | ||
email: '[email protected]', | ||
role: 'Owner' | ||
}, { | ||
id: 6, | ||
name: 'Floyd Miles', | ||
title: 'Principal Designer', | ||
email: '[email protected]', | ||
role: 'Member' | ||
}] | ||
const page = ref(1) | ||
const pageCount = 2 | ||
const peoplePage = computed(() => { | ||
return people.slice((page.value - 1) * pageCount, (page.value) * pageCount) | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col gap-y-2 pb-2"> | ||
<UTable :rows="peoplePage" /> | ||
<UPagination v-model="page" :page-count="pageCount" :total="people.length" class="place-self-center" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
github: true | ||
description: Add a pagination to handle pages. | ||
--- | ||
|
||
## Usage | ||
|
||
`Pagination` allows you to navigate through pages given a `total` which represents a number of items per page. | ||
|
||
::component-example | ||
#default | ||
:pagination-example-basic | ||
|
||
#code | ||
```vue | ||
<script setup> | ||
const page = ref(1) | ||
const items = ref([...]) | ||
</script> | ||
<template> | ||
<UPagination v-model="page" :page-count="5" :total="items.length" /> | ||
</template> | ||
``` | ||
:: | ||
|
||
### Max | ||
|
||
Use the `max` prop to set a maximum of displayed pages. Defaults to `7`, being the minimum. | ||
|
||
::component-example | ||
#default | ||
:pagination-example-max | ||
|
||
#code | ||
```vue | ||
<script setup> | ||
const page = ref(1) | ||
const items = ref([...]) | ||
</script> | ||
<template> | ||
<UPagination v-model="page" :page-count="5" :total="items.length" :max="15" /> | ||
</template> | ||
``` | ||
:: | ||
|
||
## Props | ||
|
||
:component-props | ||
|
||
## Preset | ||
|
||
:component-preset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.