next/components/layouts/navbar.vue

102 lines
3.1 KiB
Vue
Raw Normal View History

<script lang="ts" setup>
import { Grid } from "ant-design-vue";
const bp = Grid.useBreakpoint();
2023-10-09 20:07:26 -04:00
const { data, status } = useAuth();
const itemMap = ref({
2023-10-09 20:07:26 -04:00
home: "/",
bands: "/bands",
authors: "/authors",
2023-10-09 20:07:26 -04:00
forum: "/forum",
account: "/my-stuff",
"edit-profile": "/my-stuff/profile",
stories: "/my-stuff/stories",
drafts: "/my-stuff/drafts",
reviews: "/my-stuff/reviews",
messages: "/messages",
profile: `/user/${data?.value?.user?._id || 0}`,
admin: "/admin",
logout: "/auth/logout",
});
const propo = defineProps<{ inline: boolean }>();
2023-12-29 20:11:07 -05:00
let cur = ref<string>(Object.keys(itemMap.value).find((a) => itemMap.value[a] === useRoute().path) || useRoute().path);
let selected: string[] = [cur.value];
2023-10-09 20:07:26 -04:00
const clickFn = (minfo) => {
if (itemMap.value[minfo.key] === undefined) return;
cur.value = itemMap.value[minfo.key];
selected = [cur.value];
navigateTo(itemMap.value[minfo.key]);
};
2023-10-09 20:07:26 -04:00
console.log({ label: "client", value: cur.value, stat: status.value });
</script>
<template>
<div class="some-wrapper" :style="{ flexDirection: inline ? 'column' : 'row' }">
<a-menu
:mode="inline ? 'inline' : 'horizontal'"
class="navibar"
:style="{
height: !inline ? '40px' : '100%',
alignSelf: 'center',
justifyContent: 'stretch',
2023-10-09 20:07:26 -04:00
width: '100%',
}"
@click="clickFn"
:active-key="cur"
>
<a-menu-item key="home"> Home </a-menu-item>
<a-menu-item key="bands"> Bands </a-menu-item>
<a-menu-item key="authors"> Authors </a-menu-item>
<a-menu-item key="forum"> Message Board</a-menu-item>
<a-sub-menu title="My Stuff" v-if="!!data?.user" key="group/my-stuff">
<a-menu-item key="account"> Account </a-menu-item>
<a-menu-item key="edit-profile"> Edit Profile </a-menu-item>
<a-menu-item key="profile"> View Profile </a-menu-item>
<a-menu-item key="stories"> Stories </a-menu-item>
<a-menu-item key="drafts"> Drafts </a-menu-item>
<a-menu-item key="reviews"> Manage Reviews </a-menu-item>
<a-menu-item key="messages"> Private Messages </a-menu-item>
2023-10-09 20:07:26 -04:00
</a-sub-menu>
2023-12-29 20:11:07 -05:00
<a-menu-item key="admin" v-if="data?.user?.profile.isAdmin || false"> Admin </a-menu-item>
<a-menu-item key="logout" v-if="!!data?.user"> Logout </a-menu-item>
</a-menu>
<div>
<nuxt-link to="/new-story">
<a-button v-if="data?.user" type="primary" tooltip="Post a New Story">
<!-- <template #icon>
</template> -->
<icon istyle="regular" name="file-plus" />
<span style="margin-left: 0.5em"> Post a New Story </span>
</a-button>
</nuxt-link>
</div>
<div class="acbut" v-if="!data">
2023-12-29 20:11:07 -05:00
<a-button size="large" @click="() => navigateTo('/auth/login')"> Login </a-button>
<a-button size="large" type="primary" @click="() => navigateTo('/auth/register')"> Register </a-button>
</div>
</div>
</template>
<style scoped>
.navibar {
align-self: stretch;
/* min-width: max-content; */
}
.acbut {
2023-10-09 20:07:26 -04:00
justify-content: space-between;
display: flex;
2023-10-09 20:07:26 -04:00
flex-grow: 0.01;
margin-left: auto;
}
.acbut > * + * {
margin-left: 0.7em;
}
.some-wrapper {
display: flex;
flex-grow: 1.2;
justify-content: stretch;
}
</style>