traxxx/assets/components/container/container.vue

198 lines
3.6 KiB
Vue
Raw Normal View History

<template>
<div class="container">
2020-12-18 01:10:30 +00:00
<Warning
v-if="showWarning"
class="warning-container"
@enter="(includeQueer) => setConsent(true, includeQueer)"
2020-12-19 22:01:17 +00:00
@leave="setConsent(false)"
2020-12-18 01:10:30 +00:00
/>
2020-08-08 20:18:55 +00:00
<transition name="slide">
<Sidebar
v-if="showSidebar"
@toggle-sidebar="(state) => toggleSidebar(state)"
@show-filters="(state) => toggleFilters(state)"
2020-08-08 20:18:55 +00:00
/>
</transition>
<Header
@toggle-sidebar="(state) => toggleSidebar(state)"
@show-filters="(state) => toggleFilters(state)"
/>
2021-02-05 02:50:03 +00:00
<p
v-if="config.showDisclaimer"
class="disclaimer"
>{{ config.disclaimer }}</p>
2021-01-17 20:24:20 +00:00
<div
ref="content"
class="content"
2021-02-28 02:38:54 +00:00
@scroll="scroll"
2021-01-17 20:24:20 +00:00
>
<router-view @scroll="scrollToTop" />
2020-05-25 00:02:28 +00:00
</div>
<Filters
v-if="showFilters"
@close="toggleFilters(false)"
/>
2020-05-25 00:02:28 +00:00
</div>
</template>
<script>
2020-12-18 01:10:30 +00:00
import Warning from './warning.vue';
import Header from '../header/header.vue';
import Sidebar from '../sidebar/sidebar.vue';
import Filters from './filters.vue';
function toggleSidebar(state) {
2020-05-25 00:02:28 +00:00
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
}
function toggleFilters(state) {
this.showFilters = state;
this.showSidebar = false;
}
async function setConsent(consent, includeQueer) {
2020-12-19 22:01:17 +00:00
if (consent) {
this.showWarning = false;
localStorage.setItem('consent', window.env.sessionId);
2020-12-19 22:01:17 +00:00
}
if (includeQueer) {
this.$store.dispatch('setTagFilter', this.$store.state.ui.tagFilter.filter(tag => !['gay', 'bisexual', 'transsexual'].includes(tag)));
return;
}
this.$store.dispatch('setTagFilter', this.$store.state.ui.tagFilter.concat(['gay', 'bisexual', 'transsexual']));
2020-12-18 01:10:30 +00:00
}
2020-12-27 03:21:10 +00:00
function blur(event) {
this.events.emit('blur', event);
}
function resize(event) {
this.events.emit('resize', event);
}
2021-02-28 02:38:54 +00:00
function scroll(event) {
this.events.emit('scroll', event);
}
2021-01-17 20:24:20 +00:00
function scrollToTop() {
this.$refs.content.scrollTop = 0;
}
2020-12-27 03:21:10 +00:00
function mounted() {
document.addEventListener('click', this.blur);
window.addEventListener('resize', this.resize);
}
function beforeUnmount() {
document.removeEventListener('click', this.blur);
window.removeEventListener('resize', this.resize);
}
export default {
2020-05-25 00:02:28 +00:00
components: {
Header,
Sidebar,
2020-12-18 01:10:30 +00:00
Warning,
Filters,
2020-05-25 00:02:28 +00:00
},
data() {
return {
showSidebar: false,
showWarning: localStorage.getItem('consent') !== window.env.sessionId,
showFilters: false,
2020-05-25 00:02:28 +00:00
};
},
2020-12-27 03:21:10 +00:00
mounted,
beforeUnmount,
2020-05-25 00:02:28 +00:00
methods: {
toggleSidebar,
toggleFilters,
2020-12-19 22:01:17 +00:00
setConsent,
2020-12-27 03:21:10 +00:00
blur,
resize,
2021-02-28 02:38:54 +00:00
scroll,
2021-01-17 20:24:20 +00:00
scrollToTop,
2020-05-25 00:02:28 +00:00
},
};
</script>
<style lang="scss">
2019-11-14 00:18:19 +00:00
@import 'theme';
.container {
position: relative;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
2020-05-25 00:02:28 +00:00
background: var(--background-soft);
color: var(--text);
}
.content {
display: flex;
flex-direction: column;
flex-grow: 1;
2019-11-14 00:18:19 +00:00
overflow-y: auto;
2020-06-29 23:07:48 +00:00
overflow-x: hidden;
}
.content-inner {
display: flex;
flex-direction: column;
2020-06-27 02:50:13 +00:00
flex-grow: 1;
overflow-y: auto;
overflow-x: hidden;
z-index: 1;
}
2020-08-08 20:18:55 +00:00
.slide-enter-active,
.slide-leave-active {
&.sidebar-container {
transition: background .15s ease-in-out;
2020-08-08 20:18:55 +00:00
}
.sidebar {
transition: transform .15s ease-in-out;
2020-08-08 20:18:55 +00:00
}
}
2020-12-29 19:04:18 +00:00
.slide-enter-from,
2020-08-08 20:18:55 +00:00
.slide-leave-to {
&.sidebar-container {
background: transparent;
}
.sidebar {
transform: translate(100%, 0);
2020-08-08 20:18:55 +00:00
}
}
.column {
width: 1200px;
max-width: 100%;
padding: 0 1rem;
margin: 0 auto;
box-sizing: border-box;
}
2021-03-03 18:21:56 +00:00
</style>
2021-02-05 02:50:03 +00:00
2021-03-03 18:21:56 +00:00
<style lang="scss" scoped>
2021-02-05 02:50:03 +00:00
.disclaimer {
padding: .5rem 1rem;
2021-02-05 02:50:03 +00:00
margin: 0;
color: var(--text-light);
background: var(--warn);
font-weight: bold;
box-shadow: inset 0 0 3px var(--darken-weak);
text-align: center;
}
</style>