Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Pagination): new component #257

Merged
merged 7 commits into from
Jun 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/components/content/ComponentCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const meta = await fetchComponentMeta(name)
// eslint-disable-next-line vue/no-dupe-keys
const ui = computed(() => ({ ...appConfig.ui[camelName], ...props.ui }))

const fullProps = computed(() => ({ ...props.baseProps, ...componentProps }))
const fullProps = computed(() => ({ ...baseProps, ...componentProps }))
const vModel = computed({
get: () => baseProps.modelValue,
set: (value) => {
Expand Down
8 changes: 8 additions & 0 deletions docs/components/content/examples/PaginationExampleBasic.vue
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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script setup>
const page = ref(1)
const items = ref(Array(55))
</script>

<template>
<UPagination v-model="page" :total="items.length" :ui="{ rounded: 'first-of-type:rounded-l-md last-of-type:rounded-r-md' }">
<template #prev="{ onClick }">
<UTooltip text="Previous page">
<UButton icon="i-heroicons-arrow-small-left-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="mr-2" @click="onClick" />
</UTooltip>
</template>

<template #next="{ onClick }">
<UTooltip text="Next page">
<UButton icon="i-heroicons-arrow-small-right-20-solid" color="primary" :ui="{ rounded: 'rounded-full' }" class="ml-2" @click="onClick" />
</UTooltip>
</template>
</UPagination>
</template>
98 changes: 98 additions & 0 deletions docs/components/content/examples/TableExamplePaginable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
<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'
}, {
id: 7,
name: 'Emily Selman',
title: 'VP, User Experience',
email: '',
role: 'Admin'
}, {
id: 8,
name: 'Kristin Watson',
title: 'VP, Human Resources',
email: '',
role: 'Member'
}, {
id: 9,
name: 'Emma Watson',
title: 'Front-end Developer',
email: '',
role: 'Member'
}, {
id: 10,
name: 'John Doe',
title: 'Designer',
email: '',
role: 'Admin'
}, {
id: 11,
name: 'Jane Doe',
title: 'Director of Product',
email: '',
role: 'Member'
}, {
id: 12,
name: 'John Smith',
title: 'Copywriter',
email: '',
role: 'Admin'
}, {
id: 13,
name: 'Jane Smith',
title: 'Senior Designer',
email: '',
role: 'Owner'
}]

const page = ref(1)
const pageCount = 5

const rows = computed(() => {
return people.slice((page.value - 1) * pageCount, (page.value) * pageCount)
})
</script>

<template>
<div>
<UTable :rows="rows" />

<div class="flex justify-end px-3 py-3.5 border-t border-gray-200 dark:border-gray-700">
<UPagination v-model="page" :page-count="pageCount" :total="people.length" />
</div>
</div>
</template>
21 changes: 21 additions & 0 deletions docs/components/content/themes/PaginationThemeRounded.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup>
const page = ref(1)
const items = ref(Array(55))
</script>

<template>
<UPagination
v-model="page"
:total="items.length"
:ui="{
wrapper: 'flex items-center gap-1',
rounded: 'rounded-full min-w-[32px] justify-center'
}"
:prev-button="null"
:next-button="{
icon: 'i-heroicons-arrow-small-right-20-solid',
color: 'primary',
variant: 'outline'
}"
/>
</template>
35 changes: 35 additions & 0 deletions docs/content/4.data/1.table.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,41 @@ const filteredRows = computed(() => {
```
::

### Paginable

You can easily use the [Pagination](/navigation/pagination) component to paginate the rows.

::component-example
---
padding: false
---

#default
:table-example-paginable{class="w-full"}

#code
```vue
<script setup>
const people = [...]

const page = ref(1)
const pageCount = 5

const rows = computed(() => {
return people.slice((page.value - 1) * pageCount, (page.value) * pageCount)
})
</script>

<template>
<div>
<UTable :rows="rows" />

<UPagination v-model="page" :page-count="pageCount" :total="people.length" />
</div>
</template>
```
::

### Empty

Use the `empty-state` prop to display a message when there are no results.
Expand Down
6 changes: 2 additions & 4 deletions docs/content/5.navigation/1.vertical-navigation.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,9 @@ const links = [{
```
::

## Themes
## Theme

Our theming system provides a lot of flexibility to customize the component. Here is some examples of what you can do.

### Tailwind
Our theming system provides a lot of flexibility to customize the component. Here is an example of what you can do.

::component-example
#default
Expand Down
Loading