sharkey/packages/frontend/src/pages/explore.vue

97 lines
2.5 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 18:09:41 +09:00
<div v-else-if="tab === 'users'">
<XUsers/>
</div>
<div v-else-if="tab === 'roles'">
<XRoles/>
</div>
<div v-else-if="tab === 'search'">
2022-07-05 22:40:15 +09:00
<MkSpacer :content-max="1200">
<div>
2023-01-05 21:04:56 +09:00
<MkInput v-model="searchQuery" :debounce="true" type="search">
<template #prefix><i class="ti ti-search"></i></template>
2022-07-20 22:24:26 +09:00
<template #label>{{ i18n.ts.searchUser }}</template>
2022-07-05 22:40:15 +09:00
</MkInput>
2023-01-05 21:04:56 +09:00
<MkRadios v-model="searchOrigin">
2022-07-20 22:24:26 +09:00
<option value="combined">{{ i18n.ts.all }}</option>
<option value="local">{{ i18n.ts.local }}</option>
<option value="remote">{{ i18n.ts.remote }}</option>
2022-07-05 22:40:15 +09:00
</MkRadios>
</div>
2021-10-10 15:19:16 +09:00
<MkUserList v-if="searchQuery" ref="searchEl" class="_margin" :pagination="searchPagination"/>
2022-07-05 22:40:15 +09:00
</MkSpacer>
2021-10-10 15:19:16 +09: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';
import XRoles from './explore.roles.vue';
2023-01-09 09:41:25 +09:00
import MkFoldableSection from '@/components/MkFoldableSection.vue';
2023-01-07 15:09:46 +09:00
import MkInput from '@/components/MkInput.vue';
import MkRadios from '@/components/MkRadios.vue';
import { definePageMetadata } from '@/scripts/page-metadata';
import { i18n } from '@/i18n';
import MkUserList from '@/components/MkUserList.vue';
const props = withDefaults(defineProps<{
tag?: string;
initialTab?: string;
}>(), {
initialTab: 'featured',
});
let tab = $ref(props.initialTab);
2023-01-09 09:41:25 +09:00
let tagsEl = $shallowRef<InstanceType<typeof MkFoldableSection>>();
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: 'ti ti-bolt',
title: i18n.ts.featured,
}, {
2022-07-13 18:09:41 +09:00
key: 'users',
icon: 'ti ti-users',
title: i18n.ts.users,
}, {
key: 'roles',
icon: 'ti ti-badges',
title: i18n.ts.roles,
}, {
key: 'search',
icon: 'ti ti-search',
title: i18n.ts.search,
}]);
definePageMetadata(computed(() => ({
title: i18n.ts.explore,
icon: 'ti ti-hash',
})));
</script>