<template>
  <el-container>
    <el-header class="nav-container">
      <navbar :nav-index="0" @nav-items-click="handleClickOutside" />
    </el-header>
    <el-container>
      <el-aside width="210px">
         <sidebar class="sidebar-container" />
      </el-aside>
      <el-main id="workbench-main-container">
        <div :class="{ 'fixed-header': fixedHeader }">
          <tags-view v-if="needTagsView" />
        </div>
        <app-main />
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import RightPanel from '@/components/RightPanel'
import { AppMain, Navbar, Settings, Sidebar, TagsView } from './components'
import ResizeMixin from './mixin/ResizeHandler'
import { mapState } from 'vuex'

export default {
  name: 'Layout',
  components: {
    AppMain,
    Navbar,
    RightPanel,
    Settings,
    Sidebar,
    TagsView
  },
  mixins: [ResizeMixin],
  computed: {
    ...mapState({
      sidebar: state => state.app.sidebar,
      device: state => state.app.device,
      showSettings: state => state.settings.showSettings,
      needTagsView: state => state.settings.tagsView,
      fixedHeader: state => state.settings.fixedHeader
    }),
    classObj() {
      return {
        hideSidebar: !this.sidebar.opened,
        openSidebar: this.sidebar.opened,
        withoutAnimation: this.sidebar.withoutAnimation,
        mobile: this.device === 'mobile'
      }
    }
  },
  methods: {
    handleClickOutside() {
      this.$store.dispatch('app/closeSideBar', { withoutAnimation: false })
    }
  }
}
</script>

<style lang="scss" scoped>
@import "./styles/common.scss";
.el-container {
  min-height: 0;
}
.aside-container {
  position: relative;
  background-color: #2d3037;
  box-sizing: border-box;
  border-right: solid 1px #e6e6e6;
  overflow: visible;
}

.nav-container {
  padding: 0;
  /*box-shadow: 0px 1px 2px #dbdbdb;*/
  z-index: 100;
  min-width: 1200px;
  height: 45px !important;
}
.quick-add {
  height: 178px;
}
</style>
