Add swiper to pages

This commit is contained in:
ThatOneCalculator 2022-09-09 15:47:53 -07:00
parent 79d7f0804e
commit aff8d59c1c

View file

@ -2,40 +2,57 @@
<MkStickyContainer> <MkStickyContainer>
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template> <template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
<MkSpacer :content-max="700"> <MkSpacer :content-max="700">
<div v-if="tab === 'featured'" class="rknalgpo"> <swiper
<MkPagination v-slot="{items}" :pagination="featuredPagesPagination"> :modules="[Virtual]"
<MkPagePreview v-for="page in items" :key="page.id" class="ckltabjg" :page="page"/> :space-between="20"
</MkPagination> :virtual="true"
</div> @swiper="setSwiperRef"
@slide-change="onSlideChange"
<div v-else-if="tab === 'my'" class="rknalgpo my"> >
<MkButton class="new" @click="create()"><i class="fas fa-plus"></i></MkButton> <swiper-slide>
<MkPagination v-slot="{items}" :pagination="myPagesPagination"> <div class="rknalgpo">
<MkPagePreview v-for="page in items" :key="page.id" class="ckltabjg" :page="page"/> <MkPagination v-slot="{items}" :pagination="featuredPagesPagination">
</MkPagination> <MkPagePreview v-for="page in items" :key="page.id" class="ckltabjg" :page="page"/>
</div> </MkPagination>
</div>
<div v-else-if="tab === 'liked'" class="rknalgpo"> </swiper-slide>
<MkPagination v-slot="{items}" :pagination="likedPagesPagination"> <swiper-slide>
<MkPagePreview v-for="like in items" :key="like.page.id" class="ckltabjg" :page="like.page"/> <div class="rknalgpo my">
</MkPagination> <MkButton class="new" @click="create()"><i class="fas fa-plus"></i></MkButton>
</div> <MkPagination v-slot="{items}" :pagination="myPagesPagination">
<MkPagePreview v-for="page in items" :key="page.id" class="ckltabjg" :page="page"/>
</MkPagination>
</div>
</swiper-slide>
<swiper-slide>
<div class="rknalgpo">
<MkPagination v-slot="{items}" :pagination="likedPagesPagination">
<MkPagePreview v-for="like in items" :key="like.page.id" class="ckltabjg" :page="like.page"/>
</MkPagination>
</div>
</swiper-slide>
</swiper>
</MkSpacer> </MkSpacer>
</MkStickyContainer> </MkStickyContainer>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { computed, inject } from 'vue'; import { computed, inject } from 'vue';
import Virtual from 'swiper';
import { Swiper, SwiperSlide } from 'swiper/vue';
import MkPagePreview from '@/components/MkPagePreview.vue'; import MkPagePreview from '@/components/MkPagePreview.vue';
import MkPagination from '@/components/MkPagination.vue'; import MkPagination from '@/components/MkPagination.vue';
import MkButton from '@/components/MkButton.vue'; import MkButton from '@/components/MkButton.vue';
import { useRouter } from '@/router'; import { useRouter } from '@/router';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
import { definePageMetadata } from '@/scripts/page-metadata'; import { definePageMetadata } from '@/scripts/page-metadata';
import 'swiper/scss';
import 'swiper/scss/virtual';
const router = useRouter(); const router = useRouter();
let tab = $ref('featured'); let tab = $ref('featured');
const tabs = ['featured', 'my', 'liked'];
const featuredPagesPagination = { const featuredPagesPagination = {
endpoint: 'pages/featured' as const, endpoint: 'pages/featured' as const,