Skip to content

Commit fae2d7c

Browse files
committed
feat(navbar): switch to tabs instead of buttons
1 parent 746e26e commit fae2d7c

File tree

4 files changed

+68
-19
lines changed

4 files changed

+68
-19
lines changed

src/components/AppComponent.vue

+13
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,23 @@ const { isAuthenticated } = useSettingsStoreRefs();
1919
</template>
2020

2121
<style lang="scss" scoped>
22+
@use '~/styles/z-index' as layers;
23+
2224
header {
25+
position: sticky;
26+
top: 0;
27+
z-index: layers.$layer-ui;
2328
display: flex;
2429
flex-direction: column;
2530
justify-content: center;
31+
background: rgb(0 0 0 / 30%);
32+
backdrop-filter: blur(2px);
33+
transition: background 0.5s;
34+
will-change: background;
35+
36+
&:hover {
37+
background: rgb(0 0 0 / 60%);
38+
}
2639
}
2740
2841
main {
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,69 @@
11
<script lang="ts" setup>
2-
import { NButton, NButtonGroup } from 'naive-ui';
3-
import { RouterLink } from 'vue-router';
2+
import { NTab, NTabs } from 'naive-ui';
3+
import { useRoute, useRouter } from 'vue-router';
44
55
import { Route } from '~/router';
6-
import { useRouterStore } from '~/stores/router.store';
76
import { useI18n } from '~/utils';
87
9-
const store = useRouterStore();
108
const i18n = useI18n('route');
9+
const route = useRoute();
10+
const router = useRouter();
11+
12+
const navigate = (to: Route) => {
13+
router.push(to);
14+
};
1115
1216
const routes = [Route.Progress, Route.Calendar, Route.History, Route.List, Route.Search, Route.Settings];
1317
</script>
1418

1519
<template>
1620
<nav>
17-
<NButtonGroup class="buttons">
18-
<template v-for="(route, index) in routes" :key="route">
19-
<RouterLink v-slot="{ href, navigate, isActive }" :to="`${ store.baseName }/${route}`" custom>
20-
<NButton :round="index === 0 || index === routes.length - 1" :class="{ active: isActive }" :href="href" @click="navigate">
21-
{{ i18n(route.toLowerCase()) }}
22-
</NButton>
23-
</RouterLink>
21+
<NTabs :value="route.name" class="tabs" type="segment" justify-content="space-evenly" animated>
22+
<template v-for="_route in routes" :key="_route">
23+
<NTab class="tab" :name="_route.toLowerCase()" type="segment" @click="navigate(_route)">
24+
{{ i18n(_route.toLowerCase()) }}
25+
</NTab>
2426
</template>
25-
</NButtonGroup>
27+
</NTabs>
2628
</nav>
2729
</template>
2830

2931
<style lang="scss" scoped>
3032
nav {
31-
margin: 1rem 0;
33+
margin: 0 0.25rem;
3234
font-size: 12px;
3335
text-align: center;
36+
37+
a {
38+
color: inherit; /* blue colors for links too */
39+
text-decoration: inherit; /* no underline */
40+
}
41+
42+
.tabs {
43+
display: flex;
44+
justify-content: center;
45+
min-height: 2.75rem;
46+
}
3447
}
48+
</style>
49+
50+
<style lang="scss">
51+
nav {
52+
.tabs {
53+
--n-bar-color: var(--trakt-red-dark) !important;
54+
--n-tab-text-color-active: var(--vt-c-white) !important;
55+
--n-tab-text-color-hover: color-mix(in srgb, var(--trakt-red) 90%, var(--vt-c-white)) !important;
56+
--n-tab-color-segment: color-mix(in srgb, var(--trakt-red) 50%, transparent) !important;
57+
--n-color-segment: inherit !important;
3558
36-
.buttons {
37-
display: flex;
38-
justify-content: center;
59+
/* stylelint-disable-next-line selector-class-pattern -- overriding theme class */
60+
.n-tabs-tab--active {
61+
--n-tab-text-color-hover: color-mix(in srgb, var(--trakt-white) 99%, var(--vt-c-red)) !important;
62+
}
3963
40-
.active {
41-
color: var(--n-text-color-pressed);
42-
background-color: var(--n-color-pressed);
64+
.n-tabs-capsule {
65+
backdrop-filter: blur(1px);
66+
}
4367
}
4468
}
4569
</style>

src/styles/base.css

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
--vt-c-text-dark-1: var(--vt-c-white);
1717
--vt-c-text-dark-2: rgb(235 235 235 / 64%);
1818

19+
/* trakt.tv brand color */
20+
--trakt-red: #ed1c24;
21+
--trakt-red-dark: #ba080f;
22+
1923
/* semantic color variables for this project */
2024
--section-gap: 160px;
2125
--color-background: var(--vt-c-black);

src/styles/z-index.scss

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
$behind: -1;
2+
$default: 0;
3+
$in-front: 1;
4+
$layer-1: 10;
5+
$layer-2: 100;
6+
$layer-3: 1000;
7+
$layer-ui: 10000;
8+
$layer-max: 2147483647

0 commit comments

Comments
 (0)