feat(components): add login + register buttons to navbar

This commit is contained in:
parent aca345f676
commit 24d04983a9
Signed by: tablet
GPG Key ID: 924A5F6AF051E87C

@ -1,28 +1,76 @@
<script lang="ts" setup> <script lang="ts" setup>
import { log } from "~/lib/server/logger";
const itemMap = { const itemMap = {
"bands": "/bands", bands: "/bands",
"authors": "/authors" authors: "/authors",
login: "/login",
register: "/register",
}; };
let cur = Object.keys(itemMap).find(a => itemMap[a] === useRoute().name) || ""; let cur = ref<string>(
let selected: string[] = [cur] Object.keys(itemMap).find((a) => itemMap[a] === useRoute().path) ||
useRoute().path,
);
let selected: string[] = [cur.value];
const clickFn = (minfo) => { const clickFn = (minfo) => {
navigateTo(itemMap[ minfo.key ]) cur.value = itemMap[minfo.key];
} selected = [cur.value];
navigateTo(itemMap[minfo.key]);
};
console.log({ label: "client", message: cur.value });
const { data } = useAuth();
</script> </script>
<template> <template>
<a-menu mode="horizontal" class="navibar" :style="{ <div class="some-wrapper">
<a-menu
mode="horizontal"
class="navibar"
:style="{
height: '40px', height: '40px',
alignSelf: 'center', alignSelf: 'center',
justifyContent: 'stretch' justifyContent: 'stretch',
}" @click="clickFn" :selectedKeys="selected"> // width: '100%'
<a-menu-item key="bands"> }"
Bands @click="clickFn"
</a-menu-item> :active-key="cur"
>
<a-menu-item key="bands"> Bands </a-menu-item>
<a-menu-item key="authors"> Authors </a-menu-item>
</a-menu> </a-menu>
<div class="acbut" v-if="!data">
<a-button size="large" @click="() => navigateTo('/login')">
log in
</a-button>
<a-button
size="large"
type="primary"
@click="() => navigateTo('/register')"
>
register
</a-button>
</div>
</div>
</template> </template>
<style scoped> <style scoped>
.navibar { .navibar {
align-self: stretch; align-self: stretch;
flex-grow: 1;
/* min-width: max-content; */
}
.acbut {
justify-content: space-around;
display: flex;
}
.acbut > * + * {
margin-left: 0.7em;
}
.some-wrapper {
display: flex;
flex-grow: 1.2;
justify-content: stretch;
} }
</style> </style>