2022-11-25 11:13:35 +03:00
|
|
|
<script setup lang="ts">
|
2024-04-12 12:38:43 +03:00
|
|
|
import type { Component } from 'vue'
|
|
|
|
import type { NavButtonName } from '../../composables/settings'
|
2024-03-07 01:00:07 +03:00
|
|
|
|
2024-04-12 12:38:43 +03:00
|
|
|
import { STORAGE_KEY_BOTTOM_NAV_BUTTONS } from '~/constants'
|
|
|
|
|
|
|
|
import { NavButtonExplore, NavButtonFederated, NavButtonHome, NavButtonLocal, NavButtonMention, NavButtonMoreMenu, NavButtonNotification, NavButtonSearch } from '#components'
|
|
|
|
|
|
|
|
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 },
|
|
|
|
{ name: 'explore', component: NavButtonExplore },
|
|
|
|
{ name: 'local', component: NavButtonLocal },
|
|
|
|
{ name: 'federated', component: NavButtonFederated },
|
|
|
|
{ name: 'moreMenu', component: NavButtonMoreMenu },
|
|
|
|
]
|
2023-02-12 17:39:05 +03:00
|
|
|
|
2024-04-12 12:38:43 +03: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 11:13:35 +03:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-04-12 12:38:43 +03: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 17:17:02 +03:00
|
|
|
<nav
|
|
|
|
h-14 border="t base" flex flex-row text-xl
|
2022-12-05 16:20:23 +03: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 17:17:02 +03:00
|
|
|
>
|
2024-04-12 12:38:43 +03:00
|
|
|
<Component :is="navButton!.component" v-for="navButton in selectedNavButtons" :key="navButton!.name" :active-class="moreMenuVisible ? '' : 'text-primary'" />
|
2022-11-25 11:13:35 +03:00
|
|
|
</nav>
|
|
|
|
</template>
|