perf[Style]: optimize the sidebar style to make it better to set

This commit is contained in:
Pan 2019-01-30 14:18:01 +08:00
parent dbd7ccd690
commit c1719929cb
3 changed files with 63 additions and 22 deletions

View File

@ -1,6 +1,6 @@
#app {
// 主体区域
// 主体区域 Main container
.main-container {
min-height: 100%;
transition: margin-left .28s;
@ -8,7 +8,7 @@
position: relative;
}
// 侧边栏
// 侧边栏 Sidebar container
.sidebar-container {
transition: width 0.28s;
width: $sideBarWidth !important;
@ -26,10 +26,6 @@
transition: 0s width ease-in-out, 0s padding-left ease-in-out, 0s padding-right ease-in-out;
}
.el-scrollbar__bar.is-vertical {
right: 0px;
}
.scrollbar-wrapper {
overflow-x: hidden !important;
@ -38,6 +34,10 @@
}
}
.el-scrollbar__bar.is-vertical {
right: 0px;
}
.is-horizontal {
display: none;
}
@ -58,8 +58,26 @@
width: 100% !important;
}
// menu hover
.submenu-title-noDropdown,
.el-submenu__title {
&:hover {
background-color: $menuHover !important;
}
}
.is-active>.el-submenu__title {
color: #f4f4f5 !important;
color: $subMenuActiveText !important;
}
& .nest-menu .el-submenu>.el-submenu__title,
& .el-submenu .el-menu-item {
min-width: $sideBarWidth !important;
background-color: $subMenuBg !important;
&:hover {
background-color: $subMenuHover !important;
}
}
}
@ -108,21 +126,11 @@
}
}
.sidebar-container .nest-menu .el-submenu>.el-submenu__title,
.sidebar-container .el-submenu .el-menu-item {
min-width: $sideBarWidth !important;
background-color: $subMenuBg !important;
&:hover {
background-color: $menuHover !important;
}
}
.el-menu--collapse .el-menu .el-submenu {
min-width: $sideBarWidth !important;
}
//适配移动端
// 适配移动端, Mobile responsive
.mobile {
.main-container {
margin-left: 0px;
@ -135,6 +143,7 @@
&.hideSidebar {
.sidebar-container {
pointer-events: none;
transition-duration: 0.3s;
transform: translate3d(-$sideBarWidth, 0, 0);
}
@ -150,10 +159,19 @@
}
}
// when menu collapsed
.el-menu--vertical {
&>.el-menu {
.svg-icon {
margin-right: 16px;
}
}
.nest-menu .el-submenu>.el-submenu__title,
.el-menu-item {
&:hover {
// You can use $subMenuHover
background-color: $menuHover !important;
}
}
}

View File

@ -1,5 +1,24 @@
//sidebar
$menuText:#bfcbd9;
$menuActiveText:#409EFF;
$subMenuActiveText:#f4f4f5; //https://github.com/ElemeFE/element/issues/12951
$menuBg:#304156;
$menuHover:#263445;
$subMenuBg:#1f2d3d;
$menuHover:#001528;
$subMenuHover:#001528;
$sideBarWidth: 180px;
// the :export directive is the magic sauce for webpack
:export {
menuText: $menuText;
menuActiveText: $menuActiveText;
subMenuActiveText: $subMenuActiveText;
menuBg: $menuBg;
menuHover: $menuHover;
subMenuBg: $subMenuBg;
subMenuHover: $subMenuHover;
sideBarWidth: $sideBarWidth;
}

View File

@ -4,10 +4,10 @@
:show-timeout="200"
:default-active="$route.path"
:collapse="isCollapse"
:background-color="variables.menuBg"
:text-color="variables.menuText"
:active-text-color="variables.menuActiveText"
mode="vertical"
background-color="#304156"
text-color="#bfcbd9"
active-text-color="#409EFF"
>
<sidebar-item v-for="route in routes" :key="route.path" :item="route" :base-path="route.path"/>
</el-menu>
@ -16,6 +16,7 @@
<script>
import { mapGetters } from 'vuex'
import variables from '@/styles/variables.scss'
import SidebarItem from './SidebarItem'
export default {
@ -27,6 +28,9 @@ export default {
routes() {
return this.$router.options.routes
},
variables() {
return variables
},
isCollapse() {
return !this.sidebar.opened
}