Skip to content

Commit

Permalink
docs(BPagination): Update Component refs & clean up documentation (bo…
Browse files Browse the repository at this point in the history
  • Loading branch information
dwgray authored Aug 30, 2024
1 parent a351fb6 commit fea1afb
Show file tree
Hide file tree
Showing 10 changed files with 260 additions and 396 deletions.
146 changes: 43 additions & 103 deletions apps/docs/src/data/components/pagination.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@ import type {BvnComponentProps} from 'bootstrap-vue-next'
import type {ComponentReference, PropertyReference} from '../../types'
import {buildCommonProps, pick} from '../../utils'

const sharedScope = [
{
prop: 'disabled',
type: 'Boolean',
description: 'Will be `true` if this button is disabled (non-clickable)',
},
{
prop: 'index',
type: 'Number',
description: 'Page number (indexed from `0` to `numberOfPages - 1`)',
},
{
prop: 'page',
type: 'Number',
description: 'Page number (from `1` to `numberOfPages`)',
},
]

export default {
load: (): ComponentReference[] => [
{
Expand All @@ -26,17 +44,17 @@ export default {
firstClass: {
type: 'ClassValue',
default: undefined,
description: "Class(es) to apply to the 'Go to first page' button",
description: 'Class(es) to apply to the go to first page button',
},
firstNumber: {
type: 'boolean',
default: false,
description: 'Display first page number instead of Goto First button',
description: 'Display first page number instead of go to first page button',
},
firstText: {
type: 'string',
default: '\u00AB',
description: 'Content to place in the goto first page button',
description: 'Content to place in the go to first page button',
},
hideEllipsis: {
type: 'boolean',
Expand All @@ -46,52 +64,52 @@ export default {
hideGotoEndButtons: {
type: 'boolean',
default: false,
description: 'Hides the goto first and goto last page buttons',
description: 'Hides the go to first and go to last page buttons',
},
labelFirstPage: {
type: 'string',
default: 'Go to first page',
description:
"Value to place in the 'aria-label' attribute of the goto first page button",
"Value to place in the 'aria-label' attribute of the go to first page button",
},
labelLastPage: {
type: 'string',
default: 'Go to last page',
description:
"Value to place in the 'aria-label' attribute of the goto last page button",
"Value to place in the 'aria-label' attribute of the go to last page button",
},
labelNextPage: {
type: 'string',
default: 'Go to next page',
description:
"Value to place in the 'aria-label' attribute of the goto next page button",
"Value to place in the 'aria-label' attribute of the go to next page button",
},
labelPage: {
type: 'string',
default: 'Go to page',
description:
"Value to place in the 'aria-label' attribute of the goto page button. Page number will be prepended automatically",
"Value to place in the 'aria-label' attribute of the go to page button. Page number will be appended automatically",
},
labelPrevPage: {
type: 'string',
default: 'Go to previous page',
description:
"Value to place in the 'aria-label' attribute of the goto previous page button",
"Value to place in the 'aria-label' attribute of the go to previous page button",
},
lastClass: {
type: 'ClassValue',
default: undefined,
description: "Class(es) to apply to the 'Go to last page' button",
description: 'Class(es) to apply to the go to last page button',
},
lastNumber: {
type: 'boolean',
default: false,
description: 'Display last page number instead of Goto Last button',
description: 'Display last page number instead of go to Last button',
},
lastText: {
type: 'string',
default: '\u00BB',
description: 'Content to place in the goto last page button',
description: 'Content to place in the go to last page button',
},
limit: {
type: 'Numberish',
Expand All @@ -107,17 +125,17 @@ export default {
nextClass: {
type: 'ClassValue',
default: undefined,
description: "Class(es) to apply to the 'Go to next page' button",
description: 'Class(es) to apply to the go to next page button',
},
nextText: {
type: 'string',
default: '\u203A',
description: 'Content to place in the goto next page button',
description: 'Content to place in the go to next page button',
},
pageClass: {
type: 'ClassValue',
default: undefined,
description: "Class(es) to apply to the 'Go to page #' buttons",
description: 'Class(es) to apply to the go to page # buttons',
},
perPage: {
type: 'Numberish',
Expand All @@ -137,7 +155,7 @@ export default {
prevText: {
type: 'string',
default: '\u2039',
description: 'Content to place in the goto previous page button',
description: 'Content to place in the go to previous page button',
},
totalRows: {
type: 'Numberish',
Expand Down Expand Up @@ -195,71 +213,24 @@ export default {
},
{
name: 'first-text',
description: "The 'Go to first page' button content",
scope: [
{
prop: 'disabled',
type: 'Boolean',
description: 'Will be `true` if this button is disabled (non-clickable)',
},
{
prop: 'index',
type: 'Number',
description: 'Page number (indexed from `0` to `numberOfPages - 1`)',
},
{
prop: 'page',
type: 'Number',
description: 'Page number (from `1` to `numberOfPages`)',
},
],
description: 'The go to first page button content',
scope: sharedScope,
},
{
name: 'last-text',
description: "The 'Go to last page' button content",
scope: [
{
prop: 'disabled',
type: 'Boolean',
description: 'Will be `true` if this button is disabled (non-clickable)',
},
{
prop: 'index',
type: 'Number',
description: 'Page number (indexed from `0` to `numberOfPages - 1`)',
},
{
prop: 'page',
type: 'Number',
description: 'Page number (from `1` to `numberOfPages`)',
},
],
description: 'The go to last page button content',
scope: sharedScope,
},
{
name: 'next-text',
description: "The 'Go to next page' button content",
scope: [
{
prop: 'disabled',
type: 'Boolean',
description: 'Will be `true` if this button is disabled (non-clickable)',
},
{
prop: 'index',
type: 'Number',
description: 'Page number (indexed from `0` to `numberOfPages - 1`)',
},
{
prop: 'page',
type: 'Number',
description: 'Page number (from `1` to `numberOfPages`)',
},
],
description: 'The go to next page button content',
scope: sharedScope,
},
{
name: 'page',
description: 'Page number button content',
scope: [
...sharedScope,
{
prop: 'active',
type: 'Boolean',
Expand All @@ -270,43 +241,12 @@ export default {
type: 'String',
description: 'Default button content',
},
{
prop: 'disabled',
type: 'Boolean',
description: 'Will be `true` if this button is disabled (non-clickable)',
},
{
prop: 'index',
type: 'Number',
description: 'Page number (indexed from `0` to `numberOfPages - 1`)',
},
{
prop: 'page',
type: 'Number',
description: 'Page number (from `1` to `numberOfPages`)',
},
],
},
{
name: 'prev-text',
description: "The 'Go to previous page' button content",
scope: [
{
prop: 'disabled',
type: 'Boolean',
description: 'Will be `true` if this button is disabled (non-clickable)',
},
{
prop: 'index',
type: 'Number',
description: 'Page number (indexed from `0` to `numberOfPages - 1`)',
},
{
prop: 'page',
type: 'Number',
description: 'Page number (from `1` to `numberOfPages`)',
},
],
description: 'The go to previous page button content',
scope: sharedScope,
},
],
},
Expand Down
24 changes: 24 additions & 0 deletions apps/docs/src/docs/components/demo/PaginationAlignment.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<div>
<h6>Left alignment (default)</h6>
<BPagination v-model="currentPage" :total-rows="rows" />
</div>
<div class="mt-3">
<h6 class="text-center">Center alignment</h6>
<BPagination v-model="currentPage" :total-rows="rows" align="center" />
</div>
<div class="mt-3">
<h6 class="text-end">Right (end) alignment</h6>
<BPagination v-model="currentPage" :total-rows="rows" align="end" />
</div>
<div class="mt-3">
<h6 class="text-center">Fill alignment</h6>
<BPagination v-model="currentPage" :total-rows="rows" align="fill" />
</div>
</template>
<script setup lang="ts">
import {ref} from 'vue'
const currentPage = ref(1)
const rows = ref(100)
</script>
50 changes: 50 additions & 0 deletions apps/docs/src/docs/components/demo/PaginationButtonContent.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<template>
<!-- Use text in props -->
<BPagination
v-model="currentPage"
:total-rows="rows"
:per-page="perPage"
first-text="First"
prev-text="Prev"
next-text="Next"
last-text="Last"
/>

<!-- Use emojis in props -->
<BPagination
v-model="currentPage"
:total-rows="rows"
:per-page="perPage"
first-text=""
prev-text=""
next-text=""
last-text=""
class="mt-4"
/>

<!-- Use HTML and sub-components in slots -->
<BPagination v-model="currentPage" :total-rows="rows" :per-page="perPage" class="mt-4">
<template #first-text><span class="text-success">First</span></template>
<template #prev-text><span class="text-danger">Prev</span></template>
<template #next-text><span class="text-warning">Next</span></template>
<template #last-text><span class="text-info">Last</span></template>
<template #ellipsis-text>
<BSpinner small type="grow" />
<BSpinner small type="grow" />
<BSpinner small type="grow" />
</template>
<template #page="{page, active}">
<b v-if="active">{{ page }}</b>
<i v-else>{{ page }}</i>
</template>
</BPagination>
Current page : {{ currentPage }}
</template>

<script setup lang="ts">
import {ref} from 'vue'
const currentPage = ref(1)
const perPage = ref(10)
const rows = ref(100)
</script>
17 changes: 17 additions & 0 deletions apps/docs/src/docs/components/demo/PaginationButtonSize.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<template>
<h6>Small</h6>
<BPagination v-model="currentPage" :total-rows="rows" size="sm" />

<h6>Default</h6>
<BPagination v-model="currentPage" :total-rows="rows" />

<h6>Large</h6>
<BPagination v-model="currentPage" :total-rows="rows" size="lg" />
</template>

<script setup lang="ts">
import {ref} from 'vue'
const currentPage = ref(1)
const rows = ref(100)
</script>
24 changes: 24 additions & 0 deletions apps/docs/src/docs/components/demo/PaginationFirstLast.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<template>
<h6>Goto first button number</h6>
<BPagination v-model="currentPage" :total-rows="rows" :per-page="perPage" first-number />

<h6>Goto last button number</h6>
<BPagination v-model="currentPage" :total-rows="rows" :per-page="perPage" last-number />

<h6>Goto first and last button number</h6>
<BPagination
v-model="currentPage"
:total-rows="rows"
:per-page="perPage"
first-number
last-number
/>
</template>

<script setup lang="ts">
import {ref} from 'vue'
const currentPage = ref(5)
const perPage = ref(1)
const rows = ref(100)
</script>
Loading

0 comments on commit fea1afb

Please sign in to comment.