menu-theme-mixin.less 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /**
  2. @bg: 菜单整体背景色
  3. @color: 未激活时字体颜色
  4. @activeColor: 激活时颜色
  5. @subMenuOpenedBg: 子菜单展开式颜色
  6. */
  7. .menu-theme(@bg, @color, @activeBg, @activeColor, @subMenuOpenedBg){
  8. .normal-menu-item-mix(){
  9. border-left: 5px solid transparent;
  10. color: @color;
  11. }
  12. .active-menu-item-mix(){
  13. border-left-color: @activeColor !important;
  14. background: @activeBg !important;
  15. color: @activeColor !important;
  16. }
  17. .hover-menu-item-mix(){
  18. color: @activeColor !important;
  19. background: transparent !important;
  20. }
  21. .@{elNamespace}-menu{
  22. background: @bg;
  23. // 普通状态的item激活 和 hover 逻辑
  24. .@{elNamespace}-menu-item{
  25. .normal-menu-item-mix();
  26. &:hover{
  27. .hover-menu-item-mix();
  28. }
  29. // is-active的样式需要覆盖hover的样式
  30. &.is-active{
  31. .active-menu-item-mix();
  32. }
  33. }
  34. // 普通状态的subMenu的处理
  35. .@{elNamespace}-sub-menu{
  36. // title类似item的处理
  37. .@{elNamespace}-sub-menu__title{
  38. .normal-menu-item-mix();
  39. &:hover{
  40. .hover-menu-item-mix();
  41. }
  42. }
  43. &.is-opened{
  44. // 控制已打开的sub-menu的背景色
  45. .@{elNamespace}-menu{
  46. background: @subMenuOpenedBg;
  47. }
  48. }
  49. }
  50. }
  51. // collapse状态的样式 [注此处与menu平级]
  52. .@{elNamespace}-menu.@{elNamespace}-menu--collapse{
  53. .@{elNamespace}-sub-menu.is-active{
  54. .@{elNamespace}-sub-menu__title{
  55. .active-menu-item-mix();
  56. }
  57. }
  58. }
  59. }
  60. // 弹出部分样式修改
  61. .menu-theme--popup(@bg, @color, @activeBg, @activeColor, @subMenuOpenedBg){
  62. .normal-menu-item-mix(){
  63. border-left: 5px solid transparent;
  64. background-color: @bg;
  65. color: @color;
  66. }
  67. .active-menu-item-mix(){
  68. border-left-color: @activeColor !important;
  69. background: @activeBg !important;
  70. color: @activeColor !important;
  71. }
  72. .hover-menu-item-mix(){
  73. color: @color !important;
  74. background: @activeBg !important;
  75. }
  76. .@{elNamespace}-menu--vertical.@{elNamespace}-menu--popup-container.cip-menu-popper{
  77. .@{elNamespace}-menu.@{elNamespace}-menu--popup{
  78. background-color: @bg;
  79. }
  80. .@{elNamespace}-menu-item{
  81. .normal-menu-item-mix();
  82. &:hover{
  83. .hover-menu-item-mix();
  84. }
  85. &.is-active{
  86. .active-menu-item-mix();
  87. }
  88. }
  89. .@{elNamespace}-sub-menu{
  90. .@{elNamespace}-sub-menu__title{
  91. .normal-menu-item-mix();
  92. }
  93. &.is-active{
  94. > .@{elNamespace}-sub-menu__title{
  95. .hover-menu-item-mix();
  96. color: @activeColor !important;
  97. }
  98. }
  99. }
  100. }
  101. .@{elNamespace}-menu--horizontal.@{elNamespace}-menu--popup-container.cip-menu-popper{
  102. .@{elNamespace}-menu-item{
  103. border: none !important;
  104. }
  105. }
  106. }
  107. .menu-theme--horizontal(@bg, @color, @activeBg, @activeColor){
  108. @defaultColor: hardlight(@color,#666);
  109. /**内部混入定义**/
  110. // 激活菜单项
  111. .menu-item-active(){
  112. background: @activeBg !important;
  113. color: @activeColor !important;
  114. //font-weight: bold;
  115. }
  116. .menu-item-focus(){
  117. color: @defaultColor ;
  118. background: @bg;
  119. }
  120. // 一级菜单激活下划线
  121. .cip-menu__underline(){
  122. position: relative;
  123. &::after{
  124. content: ' ';
  125. position: absolute;
  126. bottom: -8px;
  127. display: inline-block;
  128. width: 12px;
  129. height: 4px;
  130. background: @activeColor;
  131. left: 50%;
  132. border-radius: 4px;
  133. transform: translateX(-50%);
  134. }
  135. }
  136. /**混入定义结束**/
  137. .@{elNamespace}-menu{
  138. background: @bg;
  139. .@{elNamespace}-menu-item{
  140. font-weight: bold;
  141. color: @defaultColor;
  142. border-bottom: none;
  143. &.is-active{
  144. .menu-item-active();
  145. .cip-menu__title{
  146. .cip-menu__underline();
  147. }
  148. }
  149. &:hover{
  150. .menu-item-active();
  151. }
  152. &:focus{
  153. .menu-item-focus()
  154. }
  155. }
  156. .@{elNamespace}-sub-menu{
  157. &.is-active{ // 子菜单激活
  158. .cip-menu__title{
  159. .menu-item-active();
  160. .cip-menu__underline();
  161. }
  162. }
  163. .@{elNamespace}-sub-menu__title{
  164. background: @bg;
  165. font-weight: bold;
  166. color: @defaultColor;
  167. border-bottom: none;
  168. &:hover{
  169. .menu-item-active()
  170. }
  171. &:focus{
  172. .menu-item-focus()
  173. }
  174. &.is-active{
  175. .menu-item-active()
  176. }
  177. }
  178. }
  179. }
  180. }