|
| 1 | +<script setup lang="ts"> |
| 2 | +import { useDisplay, useDrawer, useNuxtifyConfig, mdiArrowTopRight, mdiClose, mdiMenu } from '#imports' |
| 3 | +
|
| 4 | +// App state |
| 5 | +const { smAndDown } = useDisplay() |
| 6 | +const nuxtifyConfig = useNuxtifyConfig() |
| 7 | +const drawer = useDrawer() |
| 8 | +
|
| 9 | +// Navigation |
| 10 | +const primaryNavLinks = nuxtifyConfig.navigation?.primary |
| 11 | +const secondaryNavLinks = nuxtifyConfig.navigation?.secondary |
| 12 | +const featuredSecondaryLink = secondaryNavLinks?.slice(0, 1)[0] // first link gets featured |
| 13 | +</script> |
| 14 | + |
| 15 | +<template> |
| 16 | + <v-app-bar |
| 17 | + :density="smAndDown ? 'compact' : 'default'" |
| 18 | + flat |
| 19 | + class="px-sm-2 bottom-border" |
| 20 | + > |
| 21 | + <template #prepend> |
| 22 | + <!-- Logo --> |
| 23 | + <NuxtLink |
| 24 | + to="/" |
| 25 | + class="ml-2" |
| 26 | + > |
| 27 | + <AppLogo /> |
| 28 | + </NuxtLink> |
| 29 | + </template> |
| 30 | + |
| 31 | + <!-- Desktop navigation --> |
| 32 | + <div v-if="!smAndDown"> |
| 33 | + <!-- Primary links --> |
| 34 | + <v-btn |
| 35 | + v-for="link in primaryNavLinks" |
| 36 | + :key="link.text" |
| 37 | + :to="link.to" |
| 38 | + :href="link.href" |
| 39 | + :active="false" |
| 40 | + :prepend-icon="link.icon" |
| 41 | + slim |
| 42 | + exact |
| 43 | + :ripple="false" |
| 44 | + size="large" |
| 45 | + color="unset" |
| 46 | + :target="link.openInNew ? '_blank' : undefined" |
| 47 | + :rel="link.openInNew ? 'noopener nofollow' : undefined" |
| 48 | + class="nav-items mx-2" |
| 49 | + > |
| 50 | + {{ link.text }} |
| 51 | + <v-icon |
| 52 | + v-if="link.openInNew" |
| 53 | + :icon="mdiArrowTopRight" |
| 54 | + size="x-small" |
| 55 | + color="grey" |
| 56 | + class="ml-1" |
| 57 | + /> |
| 58 | + </v-btn> |
| 59 | + </div> |
| 60 | + |
| 61 | + <template #append> |
| 62 | + <!-- Mobile navigation --> |
| 63 | + <v-app-bar-nav-icon |
| 64 | + v-if="smAndDown" |
| 65 | + :icon="drawer ? mdiClose : mdiMenu" |
| 66 | + color="primary" |
| 67 | + aria-label="Navigation Menu" |
| 68 | + @click="drawer = !drawer" |
| 69 | + /> |
| 70 | + |
| 71 | + <!-- Desktop navigation --> |
| 72 | + <nav |
| 73 | + v-else |
| 74 | + class="d-flex align-center" |
| 75 | + > |
| 76 | + <!-- Secondary links --> |
| 77 | + <v-btn |
| 78 | + v-for="link in secondaryNavLinks?.slice(1).reverse()" |
| 79 | + :key="link.text" |
| 80 | + :to="link.to" |
| 81 | + :href="link.href" |
| 82 | + :prepend-icon="link.icon" |
| 83 | + :active="false" |
| 84 | + size="large" |
| 85 | + color="unset" |
| 86 | + :target="link.openInNew ? '_blank' : undefined" |
| 87 | + :rel="link.openInNew ? 'noopener nofollow' : undefined" |
| 88 | + class="nav-items mx-2" |
| 89 | + > |
| 90 | + {{ link.text }} |
| 91 | + <v-icon |
| 92 | + v-if="link.openInNew" |
| 93 | + :icon="mdiArrowTopRight" |
| 94 | + size="x-small" |
| 95 | + color="grey" |
| 96 | + class="ml-1" |
| 97 | + /> |
| 98 | + </v-btn> |
| 99 | + |
| 100 | + <!-- Featured secondary link --> |
| 101 | + <v-btn |
| 102 | + v-if="featuredSecondaryLink?.text" |
| 103 | + :to="featuredSecondaryLink.to" |
| 104 | + :href="featuredSecondaryLink.href" |
| 105 | + :prepend-icon="featuredSecondaryLink.icon" |
| 106 | + :active="false" |
| 107 | + variant="flat" |
| 108 | + size="large" |
| 109 | + :target="featuredSecondaryLink.openInNew ? '_blank' : undefined" |
| 110 | + :rel="featuredSecondaryLink.openInNew ? 'noopener nofollow' : undefined" |
| 111 | + class="mx-2" |
| 112 | + > |
| 113 | + {{ featuredSecondaryLink.text }} |
| 114 | + <v-icon |
| 115 | + v-if="featuredSecondaryLink.openInNew" |
| 116 | + :icon="mdiArrowTopRight" |
| 117 | + size="small" |
| 118 | + class="ml-1" |
| 119 | + /> |
| 120 | + </v-btn> |
| 121 | + </nav> |
| 122 | + </template> |
| 123 | + </v-app-bar> |
| 124 | +</template> |
| 125 | + |
| 126 | +<style scoped> |
| 127 | +/* Links */ |
| 128 | +a { |
| 129 | + text-decoration: none; |
| 130 | +} |
| 131 | +
|
| 132 | +/* Nav links hover */ |
| 133 | +.nav-items:hover { |
| 134 | + color: rgb(var(--v-theme-secondary)) !important; |
| 135 | +} |
| 136 | +:deep(.v-btn--variant-text .v-btn__overlay) { |
| 137 | + background-color: transparent; |
| 138 | +} |
| 139 | +
|
| 140 | +/* Bottom border */ |
| 141 | +.bottom-border { |
| 142 | + border-bottom: 1px solid rgb(231, 237, 246); |
| 143 | +} |
| 144 | +
|
| 145 | +/* Vuetify app bar overrides */ |
| 146 | +:deep(.v-toolbar__content) { |
| 147 | + align-self: center; |
| 148 | + max-width: 1280px; |
| 149 | +} |
| 150 | +:deep(.v-toolbar__prepend) { |
| 151 | + margin-inline: 4px 12px; |
| 152 | +} |
| 153 | +
|
| 154 | +/* Fix for emoji misalignment in button text */ |
| 155 | +:deep(.v-btn__content) { |
| 156 | + line-height: 1; |
| 157 | +} |
| 158 | +</style> |
0 commit comments