feat: ⚗️ Swiping in featured
This commit is contained in:
parent
11a5a99a6f
commit
00218e7387
|
@ -2,35 +2,45 @@
|
||||||
<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>
|
||||||
<div class="lznhrdub">
|
<div class="lznhrdub">
|
||||||
<div v-if="tab === 'featured'">
|
<swiper
|
||||||
<XFeatured/>
|
:modules="[Virtual]"
|
||||||
</div>
|
:space-between="20"
|
||||||
<div v-else-if="tab === 'users'">
|
:virtual="true"
|
||||||
<XUsers/>
|
@swiper="setSwiperRef"
|
||||||
</div>
|
@slide-change="onSlideChange"
|
||||||
<div v-else-if="tab === 'search'">
|
>
|
||||||
<MkSpacer :content-max="1200">
|
<swiper-slide>
|
||||||
<div>
|
<XFeatured/>
|
||||||
<MkInput v-model="searchQuery" :debounce="true" type="search" class="_formBlock">
|
</swiper-slide>
|
||||||
<template #prefix><i class="fas fa-search"></i></template>
|
<swiper-slide>
|
||||||
<template #label>{{ i18n.ts.searchUser }}</template>
|
<XUsers/>
|
||||||
</MkInput>
|
</swiper-slide>
|
||||||
<MkRadios v-model="searchOrigin" class="_formBlock">
|
<swiper-slide>
|
||||||
<option value="combined">{{ i18n.ts.all }}</option>
|
<MkSpacer :content-max="1200">
|
||||||
<option value="local">{{ i18n.ts.local }}</option>
|
<div>
|
||||||
<option value="remote">{{ i18n.ts.remote }}</option>
|
<MkInput v-model="searchQuery" :debounce="true" type="search" class="_formBlock">
|
||||||
</MkRadios>
|
<template #prefix><i class="fas fa-search"></i></template>
|
||||||
</div>
|
<template #label>{{ i18n.ts.searchUser }}</template>
|
||||||
|
</MkInput>
|
||||||
|
<MkRadios v-model="searchOrigin" class="_formBlock">
|
||||||
|
<option value="combined">{{ i18n.ts.all }}</option>
|
||||||
|
<option value="local">{{ i18n.ts.local }}</option>
|
||||||
|
<option value="remote">{{ i18n.ts.remote }}</option>
|
||||||
|
</MkRadios>
|
||||||
|
</div>
|
||||||
|
|
||||||
<XUserList v-if="searchQuery" ref="searchEl" class="_gap" :pagination="searchPagination"/>
|
<XUserList v-if="searchQuery" ref="searchEl" class="_gap" :pagination="searchPagination"/>
|
||||||
</MkSpacer>
|
</MkSpacer>
|
||||||
</div>
|
</swiper-slide>
|
||||||
|
</swiper>
|
||||||
</div>
|
</div>
|
||||||
</MkStickyContainer>
|
</MkStickyContainer>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, watch } from 'vue';
|
import { computed, watch } from 'vue';
|
||||||
|
import { Virtual } from 'swiper';
|
||||||
|
import { Swiper, SwiperSlide } from 'swiper/vue';
|
||||||
import XFeatured from './explore.featured.vue';
|
import XFeatured from './explore.featured.vue';
|
||||||
import XUsers from './explore.users.vue';
|
import XUsers from './explore.users.vue';
|
||||||
import MkFolder from '@/components/ui/folder.vue';
|
import MkFolder from '@/components/ui/folder.vue';
|
||||||
|
@ -42,12 +52,22 @@ import { definePageMetadata } from '@/scripts/page-metadata';
|
||||||
import { i18n } from '@/i18n';
|
import { i18n } from '@/i18n';
|
||||||
import { instance } from '@/instance';
|
import { instance } from '@/instance';
|
||||||
import XUserList from '@/components/MkUserList.vue';
|
import XUserList from '@/components/MkUserList.vue';
|
||||||
|
import 'swiper/scss';
|
||||||
|
import 'swiper/scss/virtual';
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
tag?: string;
|
tag?: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
let tab = $ref('featured');
|
// let tab = $ref('featured');
|
||||||
|
|
||||||
|
const tab = $computed({
|
||||||
|
get: () => getSrc(),
|
||||||
|
set: (x) => {
|
||||||
|
syncSlide(['featured', 'users', 'search'].indexOf(x));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
let tagsEl = $ref<InstanceType<typeof MkFolder>>();
|
let tagsEl = $ref<InstanceType<typeof MkFolder>>();
|
||||||
let searchQuery = $ref(null);
|
let searchQuery = $ref(null);
|
||||||
let searchOrigin = $ref('combined');
|
let searchOrigin = $ref('combined');
|
||||||
|
@ -85,4 +105,25 @@ definePageMetadata(computed(() => ({
|
||||||
title: i18n.ts.explore,
|
title: i18n.ts.explore,
|
||||||
icon: 'fas fa-hashtag',
|
icon: 'fas fa-hashtag',
|
||||||
})));
|
})));
|
||||||
|
|
||||||
|
let swiperRef = null;
|
||||||
|
|
||||||
|
function setSwiperRef(swiper) {
|
||||||
|
swiperRef = swiper;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSlideChange() {
|
||||||
|
saveSrc(timelines[swiperRef.activeIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncSlide(index) {
|
||||||
|
swiperRef.slideTo(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSrc() {
|
||||||
|
const dSrc = $ref('featured');
|
||||||
|
syncSlide(dSrc);
|
||||||
|
return dSrc;
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue