Added filter dialog toggle to sidebar. Moved filter dialog to container. Using events to toggle sidebar from header.

This commit is contained in:
DebaucheryLibrarian 2021-01-03 23:32:09 +01:00
parent 7bbb2f3557
commit cb4b5ce640
5 changed files with 69 additions and 36 deletions

View File

@ -10,15 +10,24 @@
<transition name="slide"> <transition name="slide">
<Sidebar <Sidebar
v-if="showSidebar" v-if="showSidebar"
@toggle="(state) => showSidebar = state" @toggle-sidebar="(state) => toggleSidebar(state)"
@show-filters="(state) => toggleFilters(state)"
/> />
</transition> </transition>
<Header :toggle-sidebar="toggleSidebar" /> <Header
@toggle-sidebar="(state) => toggleSidebar(state)"
@show-filters="(state) => toggleFilters(state)"
/>
<div class="content"> <div class="content">
<router-view /> <router-view />
</div> </div>
<Filters
v-if="showFilters"
@close="toggleFilters(false)"
/>
</div> </div>
</template> </template>
@ -26,11 +35,17 @@
import Warning from './warning.vue'; import Warning from './warning.vue';
import Header from '../header/header.vue'; import Header from '../header/header.vue';
import Sidebar from '../sidebar/sidebar.vue'; import Sidebar from '../sidebar/sidebar.vue';
import Filters from './filters.vue';
function toggleSidebar(state) { function toggleSidebar(state) {
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar; this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
} }
function toggleFilters(state) {
this.showFilters = state;
this.showSidebar = false;
}
async function setConsent(consent) { async function setConsent(consent) {
if (consent) { if (consent) {
this.showWarning = false; this.showWarning = false;
@ -61,17 +76,20 @@ export default {
Header, Header,
Sidebar, Sidebar,
Warning, Warning,
Filters,
}, },
data() { data() {
return { return {
showSidebar: false, showSidebar: false,
showWarning: localStorage.getItem('consent') !== window.env.sessionId, showWarning: localStorage.getItem('consent') !== window.env.sessionId,
showFilters: false,
}; };
}, },
mounted, mounted,
beforeUnmount, beforeUnmount,
methods: { methods: {
toggleSidebar, toggleSidebar,
toggleFilters,
setConsent, setConsent,
blur, blur,
resize, resize,

View File

@ -31,7 +31,7 @@
<li class="nav-item"> <li class="nav-item">
<router-link <router-link
v-slot="{ href, isActive, navigate }" v-slot="{ href, isActive, navigate }"
to="/networks" to="/channels"
custom custom
> >
<a <a
@ -79,7 +79,7 @@
<div class="header-section"> <div class="header-section">
<div <div
class="sidebar-toggle noselect" class="sidebar-toggle noselect"
@click.stop="toggleSidebar" @click.stop="$emit('toggleSidebar')"
><Icon icon="menu" /></div> ><Icon icon="menu" /></div>
<Tooltip> <Tooltip>
@ -148,7 +148,7 @@
<li <li
class="menu-item" class="menu-item"
@click="showFilters = true" @click="$emit('showFilters', true)"
> >
<Icon icon="filter" />Filters <Icon icon="filter" />Filters
</li> </li>
@ -157,11 +157,6 @@
</template> </template>
</Tooltip> </Tooltip>
<Filters
v-if="showFilters"
@close="showFilters = false"
/>
<Search class="search-full" /> <Search class="search-full" />
<Tooltip <Tooltip
@ -194,7 +189,6 @@
import { mapState } from 'vuex'; import { mapState } from 'vuex';
import Search from './search.vue'; import Search from './search.vue';
import Filters from './filters.vue';
import logo from '../../img/logo.svg'; import logo from '../../img/logo.svg';
@ -217,14 +211,8 @@ function setSfw(enabled) {
export default { export default {
components: { components: {
Search, Search,
Filters,
},
props: {
toggleSidebar: {
type: Function,
default: null,
},
}, },
emits: ['toggleSidebar', 'showFilters'],
data() { data() {
return { return {
logo, logo,

View File

@ -1,7 +1,7 @@
<template> <template>
<div <div
class="sidebar-container" class="sidebar-container"
@click="$emit('toggle', false)" @click="$emit('toggleSidebar', false)"
> >
<div <div
class="sidebar" class="sidebar"
@ -12,7 +12,7 @@
<router-link <router-link
to="/updates" to="/updates"
class="logo-link" class="logo-link"
@click.native="$emit('toggle', false)" @click="$emit('toggleSidebar', false)"
> >
<h1 class="sidebar-logo"> <h1 class="sidebar-logo">
<div <div
@ -25,23 +25,25 @@
<Icon <Icon
icon="cross2" icon="cross2"
class="sidebar-close noselect" class="sidebar-close noselect"
@click.native="$emit('toggle', false)" @click.native="$emit('toggleSidebar', false)"
/> />
</div> </div>
<Search <Search
class="search" class="search"
@search="$emit('toggle', false)" @search="$emit('toggleSidebar', false)"
/> />
<nav class="nav"> <nav class="nav">
<ul class="nolist"> <ul class="nolist">
<li class="nav-item"> <li
class="nav-item"
@click="$emit('toggleSidebar', false)"
>
<router-link <router-link
v-slot="{ href, isActive, navigate }" v-slot="{ href, isActive, navigate }"
to="/updates" to="/updates"
custom custom
@click.native="$emit('toggle', false)"
> >
<a <a
class="nav-link" class="nav-link"
@ -52,12 +54,14 @@
</router-link> </router-link>
</li> </li>
<li class="nav-item"> <li
class="nav-item"
@click="$emit('toggleSidebar', false)"
>
<router-link <router-link
v-slot="{ href, isActive, navigate }" v-slot="{ href, isActive, navigate }"
to="/actors" to="/actors"
custom custom
@click.native="$emit('toggle', false)"
> >
<a <a
class="nav-link" class="nav-link"
@ -68,12 +72,14 @@
</router-link> </router-link>
</li> </li>
<li class="nav-item"> <li
class="nav-item"
@click="$emit('toggleSidebar', false)"
>
<router-link <router-link
v-slot="{ href, isActive, navigate }" v-slot="{ href, isActive, navigate }"
to="/networks" to="/channels"
custom custom
@click.native="$emit('toggle', false)"
> >
<a <a
class="nav-link" class="nav-link"
@ -84,12 +90,14 @@
</router-link> </router-link>
</li> </li>
<li class="nav-item"> <li
class="nav-item"
@click="$emit('toggleSidebar', false)"
>
<router-link <router-link
v-slot="{ href, isActive, navigate }" v-slot="{ href, isActive, navigate }"
to="/movies" to="/movies"
custom custom
@click.native="$emit('toggle', false)"
> >
<a <a
class="nav-link" class="nav-link"
@ -100,12 +108,14 @@
</router-link> </router-link>
</li> </li>
<li class="nav-item"> <li
class="nav-item"
@click="$emit('toggleSidebar', false)"
>
<router-link <router-link
v-slot="{ href, isActive, navigate }" v-slot="{ href, isActive, navigate }"
to="/tags" to="/tags"
custom custom
@click.native="$emit('toggle', false)"
> >
<a <a
class="nav-link" class="nav-link"
@ -143,6 +153,11 @@
class="toggle" class="toggle"
@click="setTheme('dark')" @click="setTheme('dark')"
><Icon icon="moon" />Use dark theme</label> ><Icon icon="moon" />Use dark theme</label>
<label
class="toggle"
@click="$emit('showFilters', true)"
><Icon icon="filter" />Filters</label>
</div> </div>
</div> </div>
</div> </div>
@ -175,6 +190,7 @@ export default {
components: { components: {
Search, Search,
}, },
emits: ['toggleSidebar', 'showFilters'],
data() { data() {
return { return {
logo, logo,
@ -240,6 +256,12 @@ export default {
margin: 0; margin: 0;
} }
.sidebar-section {
display: flex;
flex-direction: column;
overflow: hidden;
}
.logo-link { .logo-link {
display: block; display: block;
height: 100%; height: 100%;
@ -265,6 +287,11 @@ export default {
} }
} }
.nav {
flex-grow: 1;
overflow-x: auto;
}
.nav-item { .nav-item {
display: block; display: block;
} }
@ -286,13 +313,13 @@ export default {
} }
.toggles { .toggles {
flex-shrink: 0;
border-top: solid 1px var(--shadow-hint); border-top: solid 1px var(--shadow-hint);
margin: .5rem 0 0 0; margin: .5rem 0 0 0;
} }
.toggle { .toggle {
display: flex; display: flex;
align-self: flex-end;
padding: 1rem; padding: 1rem;
color: var(--shadow); color: var(--shadow);
font-weight: bold; font-weight: bold;

View File

@ -151,9 +151,9 @@ const routes = [
name: 'actors', name: 'actors',
}, },
{ {
path: '/networks', path: '/channels',
component: Networks, component: Networks,
name: 'networks', name: 'channels',
}, },
{ {
path: '/movies', path: '/movies',