traxxx/assets/components/container/container.vue

141 lines
2.2 KiB
Vue

<template>
<div
class="container"
:class="theme"
>
<Warning
v-if="showWarning"
class="warning-container"
@enter="closeWarning"
/>
<transition name="slide">
<Sidebar
v-if="showSidebar"
@toggle="(state) => showSidebar = state"
/>
</transition>
<Header :toggle-sidebar="toggleSidebar" />
<div class="content">
<router-view />
</div>
</div>
</template>
<script>
import { mapState } from 'vuex';
import EventBus from '../../js/event-bus';
import Warning from './warning.vue';
import Header from '../header/header.vue';
import Sidebar from '../sidebar/sidebar.vue';
function theme(state) {
return state.ui.theme;
}
function toggleSidebar(state) {
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
}
function closeWarning() {
this.showWarning = false;
sessionStorage.setItem('warning', 'warned');
}
function mounted() {
document.addEventListener('click', () => {
EventBus.$emit('blur');
});
}
export default {
components: {
Header,
Sidebar,
Warning,
},
data() {
return {
showSidebar: false,
showWarning: sessionStorage.getItem('warning') !== 'warned',
};
},
computed: {
...mapState({
theme,
}),
},
mounted,
methods: {
toggleSidebar,
closeWarning,
},
};
</script>
<style lang="scss">
@import 'theme';
.container {
position: relative;
height: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
background: var(--background-soft);
color: var(--text);
}
.content {
display: flex;
flex-direction: column;
flex-grow: 1;
overflow-y: auto;
overflow-x: hidden;
}
.content-inner {
display: flex;
flex-direction: column;
flex-grow: 1;
overflow-y: auto;
overflow-x: hidden;
box-shadow: 0 0 3px var(--shadow-weak);
z-index: 1;
}
.slide-enter-active,
.slide-leave-active {
&.sidebar-container {
transition: background .15s ease-in-out;
}
.sidebar {
transition: transform .15s ease-in-out;
}
}
.slide-enter,
.slide-leave-to {
&.sidebar-container {
background: transparent;
}
.sidebar {
transform: translate(100%, 0);
}
}
.column {
width: 1200px;
max-width: 100%;
padding: 0 1rem;
margin: 0 auto;
box-sizing: border-box;
}
</style>