traxxx/assets/components/container/container.vue

143 lines
2.4 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"
2020-12-19 22:01:17 +00:00
@enter="setConsent(true)"
@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="(state) => showSidebar = state"
/>
</transition>
2020-05-25 00:02:28 +00:00
<Header :toggle-sidebar="toggleSidebar" />
2020-05-25 00:02:28 +00:00
<div class="content">
<router-view />
</div>
</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';
function toggleSidebar(state) {
2020-05-25 00:02:28 +00:00
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
}
2020-12-19 22:01:17 +00:00
async function setConsent(consent) {
if (consent) {
this.showWarning = false;
localStorage.setItem('consent', window.env.sessionId);
2020-12-19 22:01:17 +00:00
}
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);
}
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,
2020-05-25 00:02:28 +00:00
},
data() {
return {
showSidebar: false,
showWarning: localStorage.getItem('consent') !== window.env.sessionId,
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,
2020-12-19 22:01:17 +00:00
setConsent,
2020-12-27 03:21:10 +00:00
blur,
resize,
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;
box-shadow: 0 0 3px var(--shadow-weak);
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
}
}
.slide-enter,
.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;
}
</style>