Added navbar on public pages
This commit is contained in:
39
app/components/global/Navbar.vue
Normal file
39
app/components/global/Navbar.vue
Normal file
@@ -0,0 +1,39 @@
|
||||
<template>
|
||||
<header role="banner" class="sticky top-0 border-b-1 border-border py-4 px-2 z-50 backdrop-blur">
|
||||
<div class="max-w-4xl mx-auto">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="md:flex-1 flex justify-start" />
|
||||
|
||||
<nav class="md:flex-1">
|
||||
<menu class="text-sm flex items-center justify-center gap-4">
|
||||
<li>
|
||||
<NuxtLink to="/" class="block p-1 font-medium text-foreground/70 hover:text-foreground transition-colors" active-class="text-primary">
|
||||
{{ $t('breadcrumbs.home') }}
|
||||
</NuxtLink>
|
||||
</li>
|
||||
<li>
|
||||
<NuxtLink to="/explore" class="block p-1 font-medium text-foreground/70 hover:text-foreground transition-colors" active-class="text-primary">
|
||||
{{ $t('pages.explore.menuLabel') }}
|
||||
</NuxtLink>
|
||||
</li>
|
||||
<li>
|
||||
<NuxtLink to="/about" class="block p-1 font-medium text-foreground/70 hover:text-foreground transition-colors" active-class="text-primary">
|
||||
{{ $t('pages.about.menuLabel') }}
|
||||
</NuxtLink>
|
||||
</li>
|
||||
</menu>
|
||||
</nav>
|
||||
|
||||
<div class="md:flex-1 flex justify-end">
|
||||
<UserDashboardLink size="xs" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
header {
|
||||
background-color: color-mix(in srgb, var(--color-background) 75%, transparent);
|
||||
}
|
||||
</style>
|
||||
@@ -40,7 +40,7 @@ const breakpoints = useBreakpoints(
|
||||
<nav
|
||||
ref="sidebarRef"
|
||||
:class="cn(
|
||||
['md:relative md:isolate w-16 py-6 grid gap-4 grid-rows-[1fr_auto] justify-center md:transition-colors'], // Base appearance
|
||||
['md:relative md:isolate w-16 py-6 grid gap-4 grid-rows-[1fr_auto] bg-background justify-center md:transition-colors'], // Base appearance
|
||||
['after:opacity-50 after:contrast-125 dark:after:opacity-75'], // After styling
|
||||
['border-r-[1px] border-r-border dark:border-r-border'], // Colours
|
||||
['max-md:justify-stretch max-md:px-4 max-md:py-4 max-md:absolute max-md:left-0 max-md:inset-0 max-md:z-50 max-md:w-40 max-md:max-w-full max-md:transition-all'], // Responsive behaviours
|
||||
|
||||
45
app/components/global/user/DashboardLink.vue
Normal file
45
app/components/global/user/DashboardLink.vue
Normal file
@@ -0,0 +1,45 @@
|
||||
<script lang="ts" setup>
|
||||
import type { PrimitiveProps } from 'radix-vue'
|
||||
import type { HTMLAttributes } from 'vue'
|
||||
import type { ButtonVariants } from '@/components/ui/button'
|
||||
|
||||
const { auth } = useSupabaseClient()
|
||||
const user = useSupabaseUser()
|
||||
const profileUrl: string = `${useRequestURL().origin}/my/`
|
||||
|
||||
interface Props extends PrimitiveProps {
|
||||
size?: ButtonVariants["size"]
|
||||
}
|
||||
|
||||
defineProps<Props>()
|
||||
|
||||
async function handleGoogleLogin() {
|
||||
const { error } = await auth.signInWithOAuth({
|
||||
provider: "google",
|
||||
options: {
|
||||
queryParams: {
|
||||
access_type: "offline",
|
||||
prompt: "consent"
|
||||
},
|
||||
redirectTo: profileUrl
|
||||
}
|
||||
})
|
||||
|
||||
if (error) {
|
||||
console.log(error.message)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<TransitionGroup name="fade-group" appear>
|
||||
<UiButton v-if="user" as-child :size>
|
||||
<NuxtLink to="/my">
|
||||
Dashboard
|
||||
</NuxtLink>
|
||||
</UiButton>
|
||||
<UiButton v-else @click="handleGoogleLogin" :size>
|
||||
Log in
|
||||
</UiButton>
|
||||
</TransitionGroup>
|
||||
</template>
|
||||
Reference in New Issue
Block a user