From b44000c9dea21525c600a6881c3b0973fe218d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8A=B1=E8=A3=A4=E8=A1=A9?= Date: Wed, 30 Jan 2019 12:58:11 +0800 Subject: [PATCH] perf[Style]: optimize the sidebar style to make it better to set (#1568) --- src/styles/sidebar.scss | 39 ++++++++++++++++++++++++++++----------- src/styles/variables.scss | 19 +++++++++++++------ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/styles/sidebar.scss b/src/styles/sidebar.scss index 723f9a12..f4f699a5 100644 --- a/src/styles/sidebar.scss +++ b/src/styles/sidebar.scss @@ -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,16 +126,6 @@ } } - .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; } @@ -150,10 +158,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; + } + } } diff --git a/src/styles/variables.scss b/src/styles/variables.scss index 87a5dd50..50d9b3ef 100644 --- a/src/styles/variables.scss +++ b/src/styles/variables.scss @@ -9,19 +9,26 @@ $yellow:#FEC171; $panGreen: #30B08F; //sidebar -$menuBg:#304156; -$subMenuBg:#1f2d3d; -$menuHover:#001528; $menuText:#bfcbd9; $menuActiveText:#409EFF; +$subMenuActiveText:#f4f4f5; //https://github.com/ElemeFE/element/issues/12951 + +$menuBg:#304156; +$menuHover:#263445; + +$subMenuBg:#1f2d3d; +$subMenuHover:#001528; + $sideBarWidth: 180px; // the :export directive is the magic sauce for webpack :export { + menuText: $menuText; + menuActiveText: $menuActiveText; + subMenuActiveText: $subMenuActiveText; menuBg: $menuBg; - subMenuBg: $subMenuBg; menuHover: $menuHover; - menuText:$menuText; - menuActiveText:$menuActiveText; + subMenuBg: $subMenuBg; + subMenuHover: $subMenuHover; sideBarWidth: $sideBarWidth; }