2022-11-25 17:13:35 +09:00
|
|
|
<script setup lang="ts">
|
2024-04-12 18:38:43 +09:00
|
|
|
import type { Component } from 'vue'
|
|
|
|
import type { NavButtonName } from '../../composables/settings'
|
2024-03-07 07:00:07 +09:00
|
|
|
|
2024-10-21 17:48:06 +09:00
|
|
|
import {
|
|
|
|
NavButtonBookmark,
|
|
|
|
NavButtonCompose,
|
|
|
|
NavButtonExplore,
|
|
|
|
NavButtonFavorite,
|
|
|
|
NavButtonFederated,
|
|
|
|
NavButtonHashtag,
|
|
|
|
NavButtonHome,
|
|
|
|
NavButtonList,
|
|
|
|
NavButtonLocal,
|
|
|
|
NavButtonMention,
|
|
|
|
NavButtonMoreMenu,
|
|
|
|
NavButtonNotification,
|
|
|
|
NavButtonSearch,
|
|
|
|
} from '#components'
|
2024-04-12 18:38:43 +09:00
|
|
|
|
2024-09-30 17:11:56 +09:00
|
|
|
import { STORAGE_KEY_BOTTOM_NAV_BUTTONS } from '~/constants'
|
|
|
|
|
2024-04-12 18:38:43 +09:00
|
|
|
interface NavButton {
|
|
|
|
name: string
|
|
|
|
component: Component
|
|
|
|
}
|
|
|
|
|
|
|
|
const navButtons: NavButton[] = [
|
|
|
|
{ name: 'home', component: NavButtonHome },
|
|
|
|
{ name: 'search', component: NavButtonSearch },
|
|
|
|
{ name: 'notification', component: NavButtonNotification },
|
|
|
|
{ name: 'mention', component: NavButtonMention },
|
2024-10-21 17:48:06 +09:00
|
|
|
{ name: 'favorite', component: NavButtonFavorite },
|
|
|
|
{ name: 'bookmark', component: NavButtonBookmark },
|
|
|
|
{ name: 'compose', component: NavButtonCompose },
|
2024-04-12 18:38:43 +09:00
|
|
|
{ name: 'explore', component: NavButtonExplore },
|
|
|
|
{ name: 'local', component: NavButtonLocal },
|
|
|
|
{ name: 'federated', component: NavButtonFederated },
|
2024-10-21 17:48:06 +09:00
|
|
|
{ name: 'list', component: NavButtonList },
|
|
|
|
{ name: 'hashtag', component: NavButtonHashtag },
|
2024-04-12 18:38:43 +09:00
|
|
|
{ name: 'moreMenu', component: NavButtonMoreMenu },
|
|
|
|
]
|
2023-02-12 23:39:05 +09:00
|
|
|
|
2024-04-12 18:38:43 +09:00
|
|
|
const defaultSelectedNavButtonNames: NavButtonName[] = currentUser.value
|
|
|
|
? ['home', 'search', 'notification', 'mention', 'moreMenu']
|
|
|
|
: ['explore', 'local', 'federated', 'moreMenu']
|
|
|
|
const selectedNavButtonNames = useLocalStorage<NavButtonName[]>(STORAGE_KEY_BOTTOM_NAV_BUTTONS, defaultSelectedNavButtonNames)
|
|
|
|
|
|
|
|
const selectedNavButtons = computed(() => selectedNavButtonNames.value.map(name => navButtons.find(navButton => navButton.name === name)))
|
|
|
|
|
|
|
|
// only one icon can be lit up at the same time
|
|
|
|
const moreMenuVisible = ref(false)
|
2022-11-25 17:13:35 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-04-12 18:38:43 +09:00
|
|
|
<!-- This weird styles above are used for scroll locking, don't change it unless you know exactly what you're doing. -->
|
2022-12-04 23:17:02 +09:00
|
|
|
<nav
|
|
|
|
h-14 border="t base" flex flex-row text-xl
|
2022-12-05 22:20:23 +09:00
|
|
|
of-y-scroll scrollbar-hide overscroll-none
|
|
|
|
class="after-content-empty after:(h-[calc(100%+0.5px)] w-0.1px pointer-events-none)"
|
2022-12-04 23:17:02 +09:00
|
|
|
>
|
2024-04-12 18:38:43 +09:00
|
|
|
<Component :is="navButton!.component" v-for="navButton in selectedNavButtons" :key="navButton!.name" :active-class="moreMenuVisible ? '' : 'text-primary'" />
|
2022-11-25 17:13:35 +09:00
|
|
|
</nav>
|
|
|
|
</template>
|