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>
const itemMap = { import { log } from "~/lib/server/logger";
"bands": "/bands",
"authors": "/authors" const itemMap = {
}; bands: "/bands",
let cur = Object.keys(itemMap).find(a => itemMap[a] === useRoute().name) || ""; authors: "/authors",
let selected: string[] = [cur] login: "/login",
const clickFn = (minfo) => { register: "/register",
navigateTo(itemMap[ minfo.key ]) };
} let cur = ref<string>(
Object.keys(itemMap).find((a) => itemMap[a] === useRoute().path) ||
useRoute().path,
);
let selected: string[] = [cur.value];
const clickFn = (minfo) => {
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">
height: '40px', <a-menu
alignSelf: 'center', mode="horizontal"
justifyContent: 'stretch' class="navibar"
}" @click="clickFn" :selectedKeys="selected"> :style="{
<a-menu-item key="bands"> height: '40px',
Bands alignSelf: 'center',
</a-menu-item> justifyContent: 'stretch',
</a-menu> // width: '100%'
}"
@click="clickFn"
:active-key="cur"
>
<a-menu-item key="bands"> Bands </a-menu-item>
<a-menu-item key="authors"> Authors </a-menu-item>
</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>