calckey/packages/client/src/pages/explore.vue

88 lines
2.4 KiB
Vue
Raw Normal View History

<template>
<MkStickyContainer>
<template #header><MkPageHeader v-model:tab="tab" :actions="headerActions" :tabs="headerTabs"/></template>
<div class="lznhrdub">
<div v-if="tab === 'featured'">
<XFeatured/>
</div>
2022-07-13 09:09:41 +00:00
<div v-else-if="tab === 'users'">
<XUsers/>
</div>
<div v-else-if="tab === 'search'">
2022-07-05 13:40:15 +00:00
<MkSpacer :content-max="1200">
<div>
<MkInput v-model="searchQuery" :debounce="true" type="search" class="_formBlock">
<template #prefix><i class="fas fa-search"></i></template>
<template #label>{{ $ts.searchUser }}</template>
</MkInput>
<MkRadios v-model="searchOrigin" class="_formBlock">
<option value="combined">{{ $ts.all }}</option>
<option value="local">{{ $ts.local }}</option>
<option value="remote">{{ $ts.remote }}</option>
</MkRadios>
</div>
2021-10-10 06:19:16 +00:00
2022-07-05 13:40:15 +00:00
<XUserList v-if="searchQuery" ref="searchEl" class="_gap" :pagination="searchPagination"/>
</MkSpacer>
2021-10-10 06:19:16 +00:00
</div>
</div>
</MkStickyContainer>
</template>
<script lang="ts" setup>
import { computed, watch } from 'vue';
import XFeatured from './explore.featured.vue';
import XUsers from './explore.users.vue';
2021-11-11 17:02:25 +00:00
import MkFolder from '@/components/ui/folder.vue';
import MkInput from '@/components/form/input.vue';
import MkRadios from '@/components/form/radios.vue';
import number from '@/filters/number';
import * as os from '@/os';
import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n';
import { instance } from '@/instance';
import XUserList from '@/components/user-list.vue';
const props = defineProps<{
tag?: string;
}>();
let tab = $ref('featured');
let tagsEl = $ref<InstanceType<typeof MkFolder>>();
let searchQuery = $ref(null);
let searchOrigin = $ref('combined');
watch(() => props.tag, () => {
if (tagsEl) tagsEl.toggleContent(props.tag == null);
});
const searchPagination = {
endpoint: 'users/search' as const,
limit: 10,
params: computed(() => (searchQuery && searchQuery !== '') ? {
query: searchQuery,
origin: searchOrigin,
} : null),
};
const headerActions = $computed(() => []);
const headerTabs = $computed(() => [{
key: 'featured',
icon: 'fas fa-bolt',
title: i18n.ts.featured,
}, {
2022-07-13 09:09:41 +00:00
key: 'users',
icon: 'fas fa-users',
title: i18n.ts.users,
}, {
key: 'search',
title: i18n.ts.search,
}]);
definePageMetadata(computed(() => ({
title: i18n.ts.explore,
icon: 'fas fa-hashtag',
})));
</script>