traxxx/assets/components/container/container.vue

141 lines
2.2 KiB
Vue
Raw Normal View History

<template>
2020-05-25 00:02:28 +00:00
<div
class="container"
:class="theme"
>
2020-12-18 01:10:30 +00:00
<Warning
v-if="showWarning"
class="warning-container"
@enter="closeWarning"
/>
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-03-23 00:43:49 +00:00
import { mapState } from 'vuex';
import EventBus from '../../js/event-bus';
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';
2020-03-23 00:43:49 +00:00
function theme(state) {
2020-05-25 00:02:28 +00:00
return state.ui.theme;
2020-03-23 00:43:49 +00:00
}
function toggleSidebar(state) {
2020-05-25 00:02:28 +00:00
this.showSidebar = typeof state === 'boolean' ? state : !this.showSidebar;
}
2020-12-18 01:10:30 +00:00
function closeWarning() {
this.showWarning = false;
sessionStorage.setItem('warning', 'warned');
}
function mounted() {
2020-05-25 00:02:28 +00:00
document.addEventListener('click', () => {
EventBus.$emit('blur');
});
}
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,
2020-12-18 01:10:30 +00:00
showWarning: sessionStorage.getItem('warning') !== 'warned',
2020-05-25 00:02:28 +00:00
};
},
computed: {
...mapState({
theme,
}),
},
mounted,
methods: {
toggleSidebar,
2020-12-18 01:10:30 +00:00
closeWarning,
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>