menu.scss 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. @use 'mixins/mixins' as *;
  2. @use 'mixins/var' as *;
  3. @use 'mixins/utils' as *;
  4. @use 'common/var' as *;
  5. @use 'common/transition';
  6. @mixin menu-item {
  7. display: flex;
  8. align-items: center;
  9. height: getCssVar('menu-item-height');
  10. line-height: getCssVar('menu-item-height');
  11. font-size: getCssVar('menu-item-font-size');
  12. color: getCssVar('menu-text-color');
  13. padding: 0 getCssVar('menu-base-level-padding');
  14. list-style: none;
  15. cursor: pointer;
  16. position: relative;
  17. transition: border-color getCssVar('transition-duration'),
  18. background-color getCssVar('transition-duration'),
  19. color getCssVar('transition-duration');
  20. box-sizing: border-box;
  21. white-space: nowrap;
  22. * {
  23. vertical-align: bottom;
  24. }
  25. i {
  26. color: inherit;
  27. }
  28. &:hover,
  29. &:focus {
  30. outline: none;
  31. }
  32. &:hover {
  33. background-color: getCssVar('menu-hover-bg-color');
  34. }
  35. @include when(disabled) {
  36. opacity: 0.25;
  37. cursor: not-allowed;
  38. background: none !important;
  39. }
  40. }
  41. :root {
  42. // They are defined on :root so they can be inherited by sub-menu instead of overwritten
  43. @include set-component-css-var('menu', $menu);
  44. }
  45. @include b(menu) {
  46. border-right: solid 1px getCssVar('menu-border-color');
  47. list-style: none;
  48. position: relative;
  49. margin: 0;
  50. padding-left: 0;
  51. background-color: getCssVar('menu-bg-color');
  52. box-sizing: border-box;
  53. @include m(vertical) {
  54. &:not(.#{$namespace}-menu--collapse):not(.#{$namespace}-menu--popup-container) {
  55. & .#{$namespace}-menu-item,
  56. & .#{$namespace}-sub-menu__title,
  57. & .#{$namespace}-menu-item-group__title {
  58. white-space: nowrap;
  59. padding-left: calc(
  60. #{getCssVar('menu-base-level-padding')} + #{getCssVar('menu-level')} *
  61. #{getCssVar('menu-level-padding')}
  62. );
  63. }
  64. }
  65. }
  66. @include m(horizontal) {
  67. display: flex;
  68. flex-wrap: nowrap;
  69. border-right: none;
  70. &.#{$namespace}-menu {
  71. border-bottom: solid 1px getCssVar('menu-border-color');
  72. }
  73. & > .#{$namespace}-menu-item {
  74. display: inline-flex;
  75. justify-content: center;
  76. align-items: center;
  77. height: 100%;
  78. margin: 0;
  79. border-bottom: 2px solid transparent;
  80. color: getCssVar('menu-text-color');
  81. a,
  82. a:hover {
  83. color: inherit;
  84. }
  85. }
  86. & > .#{$namespace}-sub-menu {
  87. &:focus,
  88. &:hover {
  89. outline: none;
  90. }
  91. &:hover {
  92. .#{$namespace}-sub-menu__title {
  93. color: getCssVar('menu-hover-text-color');
  94. }
  95. }
  96. &.is-active {
  97. .#{$namespace}-sub-menu__title {
  98. border-bottom: 2px solid getCssVar('menu-active-color');
  99. color: getCssVar('menu-active-color');
  100. }
  101. }
  102. & .#{$namespace}-sub-menu__title {
  103. height: 100%;
  104. border-bottom: 2px solid transparent;
  105. color: getCssVar('menu-text-color');
  106. &:hover {
  107. background-color: getCssVar('bg-color', 'overlay');
  108. }
  109. }
  110. }
  111. & .#{$namespace}-menu {
  112. & .#{$namespace}-menu-item,
  113. & .#{$namespace}-sub-menu__title {
  114. background-color: getCssVar('menu-bg-color');
  115. display: flex;
  116. align-items: center;
  117. height: getCssVar('menu-horizontal-sub-item-height');
  118. line-height: getCssVar('menu-horizontal-sub-item-height');
  119. padding: 0 10px;
  120. color: getCssVar('menu-text-color');
  121. }
  122. & .#{$namespace}-sub-menu__title {
  123. padding-right: 40px;
  124. }
  125. & .#{$namespace}-menu-item.is-active,
  126. & .#{$namespace}-sub-menu.is-active > .#{$namespace}-sub-menu__title {
  127. color: getCssVar('menu-active-color');
  128. }
  129. }
  130. & .#{$namespace}-menu-item:not(.is-disabled):hover,
  131. & .#{$namespace}-menu-item:not(.is-disabled):focus {
  132. outline: none;
  133. color: getCssVar('menu-hover-text-color');
  134. background-color: getCssVar('menu-hover-bg-color');
  135. }
  136. & > .#{$namespace}-menu-item.is-active {
  137. border-bottom: 2px solid getCssVar('menu-active-color');
  138. color: getCssVar('menu-active-color') !important;
  139. }
  140. }
  141. @include m(collapse) {
  142. width: calc(
  143. #{getCssVar('menu-icon-width')} + #{getCssVar('menu-base-level-padding')} *
  144. 2
  145. );
  146. > .#{$namespace}-menu-item,
  147. > .#{$namespace}-sub-menu > .#{$namespace}-sub-menu__title,
  148. > .#{$namespace}-menu-item-group
  149. > ul
  150. > .#{$namespace}-sub-menu
  151. > .#{$namespace}-sub-menu__title {
  152. [class^='#{$namespace}-icon'] {
  153. margin: 0;
  154. vertical-align: middle;
  155. width: getCssVar('menu-icon-width');
  156. text-align: center;
  157. }
  158. .#{$namespace}-sub-menu__icon-arrow {
  159. display: none;
  160. }
  161. > span {
  162. height: 0;
  163. width: 0;
  164. overflow: hidden;
  165. visibility: hidden;
  166. display: inline-block;
  167. }
  168. }
  169. > .#{$namespace}-menu-item.is-active i {
  170. color: inherit;
  171. }
  172. .#{$namespace}-menu .#{$namespace}-sub-menu {
  173. min-width: 200px;
  174. }
  175. }
  176. @include m(popup) {
  177. z-index: 100;
  178. min-width: 200px;
  179. border: none;
  180. padding: 5px 0;
  181. border-radius: getCssVar('border-radius-small');
  182. box-shadow: getCssVar('box-shadow-light');
  183. }
  184. .#{$namespace}-icon {
  185. flex-shrink: 0;
  186. }
  187. }
  188. @include b(menu-item) {
  189. @include menu-item;
  190. & [class^='#{$namespace}-icon'] {
  191. margin-right: 5px;
  192. width: getCssVar('menu-icon-width');
  193. text-align: center;
  194. font-size: 18px;
  195. vertical-align: middle;
  196. }
  197. @include when(active) {
  198. color: getCssVar('menu-active-color');
  199. i {
  200. color: inherit;
  201. }
  202. }
  203. .#{$namespace}-menu-tooltip__trigger {
  204. position: absolute;
  205. left: 0;
  206. top: 0;
  207. height: 100%;
  208. width: 100%;
  209. display: inline-flex;
  210. align-items: center;
  211. box-sizing: border-box;
  212. padding: 0 getCssVar('menu-base-level-padding');
  213. }
  214. }
  215. @include b(sub-menu) {
  216. list-style: none;
  217. margin: 0;
  218. padding-left: 0;
  219. @include e(title) {
  220. @include menu-item;
  221. padding-right: calc(
  222. #{getCssVar('menu-base-level-padding')} + #{getCssVar('menu-icon-width')}
  223. );
  224. &:hover {
  225. background-color: getCssVar('menu-hover-bg-color');
  226. }
  227. }
  228. & .#{$namespace}-menu {
  229. border: none;
  230. }
  231. & .#{$namespace}-menu-item {
  232. height: getCssVar('menu-sub-item-height');
  233. line-height: getCssVar('menu-sub-item-height');
  234. }
  235. @include e(hide-arrow) {
  236. .#{$namespace}-sub-menu__icon-arrow {
  237. display: none !important;
  238. }
  239. }
  240. @include when(active) {
  241. .#{$namespace}-sub-menu__title {
  242. border-bottom-color: getCssVar('menu-active-color');
  243. }
  244. }
  245. @include when(disabled) {
  246. .#{$namespace}-sub-menu__title,
  247. .#{$namespace}-menu-item {
  248. opacity: 0.25;
  249. cursor: not-allowed;
  250. background: none !important;
  251. }
  252. }
  253. .#{$namespace}-icon {
  254. vertical-align: middle;
  255. margin-right: 5px;
  256. width: getCssVar('menu-icon-width');
  257. text-align: center;
  258. font-size: 18px;
  259. &.#{$namespace}-sub-menu__icon-more {
  260. margin-right: 0 !important;
  261. }
  262. }
  263. .#{$namespace}-sub-menu__icon-arrow {
  264. position: absolute;
  265. top: 50%;
  266. right: getCssVar('menu-base-level-padding');
  267. margin-top: -6px;
  268. transition: transform getCssVar('transition-duration');
  269. font-size: 12px;
  270. margin-right: 0;
  271. width: inherit;
  272. }
  273. }
  274. @include b(menu-item-group) {
  275. > ul {
  276. padding: 0;
  277. }
  278. @include e(title) {
  279. padding: 7px 0 7px getCssVar('menu-base-level-padding');
  280. line-height: normal;
  281. font-size: 12px;
  282. color: getCssVar('text-color', 'secondary');
  283. }
  284. }
  285. .horizontal-collapse-transition
  286. .#{$namespace}-sub-menu__title
  287. .#{$namespace}-sub-menu__icon-arrow {
  288. transition: getCssVar('transition-duration-fast');
  289. opacity: 0;
  290. }