traxxx/assets/components/header/header.vue

322 lines
7.0 KiB
Vue

<template>
<header class="header">
<div class="header-nav">
<router-link
to="/home"
class="logo-link"
><h1 class="logo">
<Icon
icon="logo"
/>
<Icon
icon="logo_t"
class="logo-compact"
/>
</h1></router-link>
<nav class="nav">
<ul class="nolist">
<li class="nav-item">
<router-link
v-slot="{ href, isActive, navigate }"
to="/actors"
>
<a
class="nav-link"
:href="href"
:class="{ active: isActive }"
@click="navigate"
>Actors</a>
</router-link>
</li>
<li class="nav-item">
<router-link
v-slot="{ href, isActive, navigate }"
to="/networks"
>
<a
class="nav-link"
:href="href"
:class="{ active: isActive }"
@click="navigate"
>Networks</a>
</router-link>
</li>
<li class="nav-item">
<router-link
v-slot="{ href, isActive, navigate }"
to="/tags"
>
<a
class="nav-link"
:href="href"
:class="{ active: isActive }"
@click="navigate"
>Tags</a>
</router-link>
</li>
</ul>
</nav>
</div>
<div class="header-section">
<div class="header-toggles">
<Icon
v-show="!sfw"
v-tooltip="'Enable safe-for-work mode'"
icon="flower"
class="toggle noselect"
@click.native="setSfw(true)"
/>
<Icon
v-show="sfw"
v-tooltip="'Disable safe-for-work mode'"
icon="flower"
class="toggle active noselect"
@click.native="setSfw(false)"
/>
<Icon
v-show="theme === 'light'"
v-tooltip="'Switch to dark theme'"
icon="moon"
class="toggle noselect"
@click.native="setTheme('dark')"
/>
<Icon
v-show="theme === 'dark'"
v-tooltip="'Switch to light theme'"
icon="sun"
class="toggle noselect"
@click.native="setTheme('light')"
/>
</div>
<Search class="search-full" />
<v-popover
class="search-compact"
:open="searching"
@show="searching = true"
@hide="searching = false"
>
<button
type="button"
class="search-button"
><Icon
icon="search"
/></button>
<Search
slot="popover"
:searching="searching"
class="compact"
@search="searching = false"
/>
</v-popover>
</div>
</header>
</template>
<script>
import { mapState } from 'vuex';
import Search from './search.vue';
function sfw(state) {
return state.ui.sfw;
}
function theme(state) {
return state.ui.theme;
}
function setTheme(newTheme) {
this.$store.dispatch('setTheme', newTheme);
}
function setSfw(enabled) {
this.$store.dispatch('setSfw', enabled);
}
export default {
components: {
Search,
},
data() {
return {
searching: false,
};
},
computed: {
...mapState({
sfw,
theme,
}),
},
methods: {
setSfw,
setTheme,
},
};
</script>
<style lang="scss" scoped>
@import 'theme';
.header {
display: flex;
align-items: center;
justify-content: space-between;
background: var(--background);
color: var(--primary);
border-bottom: solid 1px var(--shadow-hint);
font-size: 0;
}
.header-nav {
display: flex;
align-items: center;
}
.header-section {
height: 100%;
align-items: center;
display: flex;
flex-direction: row;
}
.logo-link {
color: inherit;
display: inline-block;
text-decoration: none;
}
.logo {
display: inline-block;
padding: .75rem 0 .75rem 1rem;
margin: 0 1rem 0 0;
.icon {
width: 6rem;
height: 1.5rem;
}
.logo-compact {
display: none;
}
}
.nav {
display: inline-block;
}
.nav-link {
display: flex;
align-items: center;
justify-content: center;
padding: 1rem 1rem calc(1rem - 5px) 1rem;
border-bottom: solid 5px transparent;
color: var(--shadow);
text-decoration: none;
font-size: .9rem;
font-weight: bold;
cursor: pointer;
&.active {
color: var(--primary);
border-bottom: solid 5px var(--primary);
.icon {
fill: var(--primary);
}
}
&:hover:not(.active) {
color: var(--primary);
.icon {
fill: var(--primary);
}
}
}
.header-toggles {
margin: 0 .5rem 0 0;
.icon {
padding: 1rem .75rem;
fill: var(--shadow);
&:hover {
fill: var(--shadow-strong);
cursor: pointer;
}
&.active {
fill: var(--primary);
}
}
}
.search-button {
height: 100%;
padding: 0 1rem;
background: none;
border: none;
outline: none;
margin: .2rem 0 0 0;
.icon {
fill: var(--shadow);
}
}
.search-compact {
display: none;
}
@media(max-width: $breakpoint2) {
.search-full {
display: none;
}
.search-compact {
display: flex;
}
}
@media(max-width: $breakpoint0) {
.nav-label {
display: none;
}
.nav .nolist {
display: flex;
}
.nav,
.nav-item {
flex-grow: 1;
}
.logo {
margin: 0 .5rem 0 0;
.icon {
display: none;
}
.icon.logo-compact {
width: 1.5rem;
display: inline-block;
}
}
}
</style>