Skip to content

Commit

Permalink
feat: add page changing handler to QPagination stories (#146)
Browse files Browse the repository at this point in the history
* fix: add to Pagination stories handlePageChange
* fix: return currentPage to default args, use it in currentPage ref
  • Loading branch information
Sergey authored Sep 1, 2021
1 parent f8596c2 commit 35b95a1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions stories/components/QPagination.stories.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Meta, Story } from '@storybook/vue3';
import { defineComponent } from 'vue';
import { defineComponent, ref } from 'vue';

import QPagination from '@/qComponents/QPagination';
import type { QPaginationProps } from '@/qComponents/QPagination';
Expand All @@ -13,17 +13,26 @@ const QPaginationStory: Story<QPaginationProps> = args =>
defineComponent({
components: { QPagination },
setup() {
return { args };
const currentPage = ref<number>(args.currentPage);

const handlePageChange = (value: number): void => {
// eslint-disable-next-line no-console
console.log('current-change', value);
currentPage.value = value;
};

return { args, currentPage, handlePageChange };
},

template: `
<q-pagination
:page-count="args.pageCount"
:total="args.total"
:page-size="args.pageSize"
:current-page="args.currentPage"
:current-page="currentPage"
:disabled="args.disabled"
:pager-count="args.pagerCount"
@current-change="handlePageChange"
/>
`
});
Expand Down

0 comments on commit 35b95a1

Please sign in to comment.