traxxx/assets/components/container/container.vue

91 lines
1.4 KiB
Vue
Raw Normal View History

<template>
2020-05-25 00:02:28 +00:00
<div
class="container"
:class="theme"
>
<Sidebar
v-if="showSidebar"
:toggle-sidebar="toggleSidebar"
/>
2020-05-25 00:02:28 +00:00
<Header :toggle-sidebar="toggleSidebar" />
2020-05-25 00:02:28 +00:00
<div class="content">
<!-- key forces rerender when new and old path use same component -->
<router-view />
</div>
</div>
</template>
<script>
2020-03-23 00:43:49 +00:00
import { mapState } from 'vuex';
import EventBus from '../../js/event-bus';
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;
}
function mounted() {
2020-05-25 00:02:28 +00:00
document.addEventListener('click', () => {
EventBus.$emit('blur');
this.showSidebar = false;
});
}
export default {
2020-05-25 00:02:28 +00:00
components: {
Header,
Sidebar,
},
data() {
return {
showSidebar: false,
};
},
computed: {
...mapState({
theme,
}),
},
mounted,
methods: {
toggleSidebar,
},
};
</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 {
2020-06-27 02:50:13 +00:00
flex-grow: 1;
overflow-y: auto;
}
</style>