enhance(client): Use tab component for page list

This commit is contained in:
syuilo 2020-07-28 10:08:08 +09:00
parent 1b9d316e7c
commit 6b8354ccbf
2 changed files with 21 additions and 20 deletions

View file

@ -1,6 +1,6 @@
<template> <template>
<div class="pxhvhrfw" v-size="[{ max: 500 }]"> <div class="pxhvhrfw" v-size="[{ max: 500 }]">
<button v-for="item in items" class="_button" @click="$emit('input', item.value)" :class="{ active: value === item.value }" :key="item.value">{{ item.label }}</button> <button v-for="item in items" class="_button" @click="$emit('input', item.value)" :class="{ active: value === item.value }" :key="item.value"><fa v-if="item.icon" :icon="item.icon" class="icon"/>{{ item.label }}</button>
</div> </div>
</template> </template>
@ -33,6 +33,10 @@ export default Vue.extend({
color: var(--accent); color: var(--accent);
border-bottom-color: var(--accent); border-bottom-color: var(--accent);
} }
> .icon {
margin-right: 6px;
}
} }
&.max-width_500px { &.max-width_500px {

View file

@ -3,24 +3,20 @@
<portal to="icon"><fa :icon="faStickyNote"/></portal> <portal to="icon"><fa :icon="faStickyNote"/></portal>
<portal to="title">{{ $t('pages') }}</portal> <portal to="title">{{ $t('pages') }}</portal>
<mk-container :body-togglable="true"> <mk-tab v-model="tab" :items="[{ label: $t('_pages.my'), value: 'my', icon: faEdit }, { label: $t('_pages.liked'), value: 'liked', icon: faHeart }]"/>
<template #header><fa :icon="faEdit" fixed-width/>{{ $t('_pages.my') }}</template>
<div class="rknalgpo my">
<mk-button class="new" @click="create()"><fa :icon="faPlus"/></mk-button>
<mk-pagination :pagination="myPagesPagination" #default="{items}">
<mk-page-preview v-for="page in items" class="ckltabjg" :page="page" :key="page.id"/>
</mk-pagination>
</div>
</mk-container>
<mk-container :body-togglable="true"> <div class="rknalgpo my" v-if="tab === 'my'">
<template #header><fa :icon="faHeart" fixed-width/>{{ $t('_pages.liked') }}</template> <mk-button class="new" @click="create()"><fa :icon="faPlus"/></mk-button>
<div class="rknalgpo"> <mk-pagination :pagination="myPagesPagination" #default="{items}">
<mk-pagination :pagination="likedPagesPagination" #default="{items}"> <mk-page-preview v-for="page in items" class="ckltabjg" :page="page" :key="page.id"/>
<mk-page-preview v-for="like in items" class="ckltabjg" :page="like.page" :key="like.page.id"/> </mk-pagination>
</mk-pagination> </div>
</div>
</mk-container> <div class="rknalgpo" v-if="tab === 'liked'">
<mk-pagination :pagination="likedPagesPagination" #default="{items}">
<mk-page-preview v-for="like in items" class="ckltabjg" :page="like.page" :key="like.page.id"/>
</mk-pagination>
</div>
</div> </div>
</template> </template>
@ -31,14 +27,15 @@ import { faStickyNote, faHeart } from '@fortawesome/free-regular-svg-icons';
import MkPagePreview from '../components/page-preview.vue'; import MkPagePreview from '../components/page-preview.vue';
import MkPagination from '../components/ui/pagination.vue'; import MkPagination from '../components/ui/pagination.vue';
import MkButton from '../components/ui/button.vue'; import MkButton from '../components/ui/button.vue';
import MkContainer from '../components/ui/container.vue'; import MkTab from '../components/tab.vue';
export default Vue.extend({ export default Vue.extend({
components: { components: {
MkPagePreview, MkPagination, MkButton, MkContainer MkPagePreview, MkPagination, MkButton, MkTab
}, },
data() { data() {
return { return {
tab: 'my',
myPagesPagination: { myPagesPagination: {
endpoint: 'i/pages', endpoint: 'i/pages',
limit: 5, limit: 5,