menu.scss 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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(
  55. .#{$namespace}-menu--popup-container
  56. ) {
  57. & .#{$namespace}-menu-item,
  58. & .#{$namespace}-sub-menu__title,
  59. & .#{$namespace}-menu-item-group__title {
  60. white-space: nowrap;
  61. padding-left: calc(
  62. #{getCssVar('menu-base-level-padding')} + #{getCssVar('menu-level')} *
  63. #{getCssVar('menu-level-padding')}
  64. );
  65. }
  66. }
  67. }
  68. &:not(.#{$namespace}-menu--collapse) .#{$namespace}-sub-menu__title {
  69. padding-right: calc(
  70. #{getCssVar('menu-base-level-padding')} + #{getCssVar('menu-icon-width')}
  71. );
  72. }
  73. @include m(horizontal) {
  74. display: flex;
  75. flex-wrap: nowrap;
  76. border-right: none;
  77. height: getCssVar('menu-horizontal-height');
  78. // reset menu-item popup height
  79. &.#{$namespace}-menu--popup-container {
  80. height: unset;
  81. }
  82. &.#{$namespace}-menu {
  83. border-bottom: solid 1px getCssVar('menu-border-color');
  84. }
  85. & > .#{$namespace}-menu-item {
  86. display: inline-flex;
  87. justify-content: center;
  88. align-items: center;
  89. height: 100%;
  90. margin: 0;
  91. border-bottom: 2px solid transparent;
  92. color: getCssVar('menu-text-color');
  93. a,
  94. a:hover {
  95. color: inherit;
  96. }
  97. }
  98. & > .#{$namespace}-sub-menu {
  99. &:focus,
  100. &:hover {
  101. outline: none;
  102. }
  103. &:hover {
  104. .#{$namespace}-sub-menu__title {
  105. color: getCssVar('menu-hover-text-color');
  106. }
  107. }
  108. &.is-active {
  109. .#{$namespace}-sub-menu__title {
  110. border-bottom: 2px solid getCssVar('menu-active-color');
  111. color: getCssVar('menu-active-color');
  112. }
  113. }
  114. & .#{$namespace}-sub-menu__title {
  115. height: 100%;
  116. border-bottom: 2px solid transparent;
  117. color: getCssVar('menu-text-color');
  118. &:hover {
  119. background-color: getCssVar('menu-bg-color');
  120. }
  121. }
  122. }
  123. & .#{$namespace}-menu {
  124. & .#{$namespace}-menu-item,
  125. & .#{$namespace}-sub-menu__title {
  126. background-color: getCssVar('menu-bg-color');
  127. display: flex;
  128. align-items: center;
  129. height: getCssVar('menu-horizontal-sub-item-height');
  130. line-height: getCssVar('menu-horizontal-sub-item-height');
  131. padding: 0 10px;
  132. color: getCssVar('menu-text-color');
  133. }
  134. & .#{$namespace}-sub-menu__title {
  135. padding-right: 40px;
  136. }
  137. & .#{$namespace}-menu-item.is-active,
  138. & .#{$namespace}-sub-menu.is-active > .#{$namespace}-sub-menu__title {
  139. color: getCssVar('menu-active-color');
  140. }
  141. }
  142. & .#{$namespace}-menu-item:not(.is-disabled):hover,
  143. & .#{$namespace}-menu-item:not(.is-disabled):focus {
  144. outline: none;
  145. color: getCssVar('menu-hover-text-color');
  146. background-color: getCssVar('menu-hover-bg-color');
  147. }
  148. & > .#{$namespace}-menu-item.is-active {
  149. border-bottom: 2px solid getCssVar('menu-active-color');
  150. color: getCssVar('menu-active-color') !important;
  151. }
  152. }
  153. @include m(collapse) {
  154. width: calc(
  155. #{getCssVar('menu-icon-width')} + #{getCssVar('menu-base-level-padding')} *
  156. 2
  157. );
  158. > .#{$namespace}-menu-item,
  159. > .#{$namespace}-sub-menu > .#{$namespace}-sub-menu__title,
  160. > .#{$namespace}-menu-item-group
  161. > ul
  162. > .#{$namespace}-sub-menu
  163. > .#{$namespace}-sub-menu__title {
  164. [class^='#{$namespace}-icon'] {
  165. margin: 0;
  166. vertical-align: middle;
  167. width: getCssVar('menu-icon-width');
  168. text-align: center;
  169. }
  170. .#{$namespace}-sub-menu__icon-arrow {
  171. display: none;
  172. }
  173. > span {
  174. height: 0;
  175. width: 0;
  176. overflow: hidden;
  177. visibility: hidden;
  178. display: inline-block;
  179. }
  180. }
  181. > .#{$namespace}-menu-item.is-active i {
  182. color: inherit;
  183. }
  184. .#{$namespace}-menu .#{$namespace}-sub-menu {
  185. min-width: 200px;
  186. }
  187. .#{$namespace}-sub-menu {
  188. &.is-active .#{$namespace}-sub-menu__title {
  189. color: getCssVar('menu-active-color');
  190. }
  191. }
  192. }
  193. @include m(popup) {
  194. z-index: 100;
  195. min-width: 200px;
  196. border: none;
  197. padding: 5px 0;
  198. border-radius: getCssVar('border-radius-small');
  199. box-shadow: getCssVar('box-shadow-light');
  200. }
  201. .#{$namespace}-icon {
  202. flex-shrink: 0;
  203. }
  204. }
  205. @include b(menu-item) {
  206. @include menu-item;
  207. & [class^='#{$namespace}-icon'] {
  208. margin-right: 5px;
  209. width: getCssVar('menu-icon-width');
  210. text-align: center;
  211. font-size: 18px;
  212. vertical-align: middle;
  213. }
  214. @include when(active) {
  215. color: getCssVar('menu-active-color');
  216. i {
  217. color: inherit;
  218. }
  219. }
  220. .#{$namespace}-menu-tooltip__trigger {
  221. position: absolute;
  222. left: 0;
  223. top: 0;
  224. height: 100%;
  225. width: 100%;
  226. display: inline-flex;
  227. align-items: center;
  228. box-sizing: border-box;
  229. padding: 0 getCssVar('menu-base-level-padding');
  230. }
  231. }
  232. @include b(sub-menu) {
  233. list-style: none;
  234. margin: 0;
  235. padding-left: 0;
  236. @include e(title) {
  237. @include menu-item;
  238. &:hover {
  239. background-color: getCssVar('menu-hover-bg-color');
  240. }
  241. }
  242. & .#{$namespace}-menu {
  243. border: none;
  244. }
  245. & .#{$namespace}-menu-item {
  246. height: getCssVar('menu-sub-item-height');
  247. line-height: getCssVar('menu-sub-item-height');
  248. }
  249. @include e(hide-arrow) {
  250. .#{$namespace}-sub-menu__icon-arrow {
  251. display: none !important;
  252. }
  253. }
  254. @include when(active) {
  255. .#{$namespace}-sub-menu__title {
  256. border-bottom-color: getCssVar('menu-active-color');
  257. }
  258. }
  259. @include when(disabled) {
  260. .#{$namespace}-sub-menu__title,
  261. .#{$namespace}-menu-item {
  262. opacity: 0.25;
  263. cursor: not-allowed;
  264. background: none !important;
  265. }
  266. }
  267. .#{$namespace}-icon {
  268. vertical-align: middle;
  269. margin-right: 5px;
  270. width: getCssVar('menu-icon-width');
  271. text-align: center;
  272. font-size: 18px;
  273. &.#{$namespace}-sub-menu__icon-more {
  274. margin-right: 0 !important;
  275. }
  276. }
  277. .#{$namespace}-sub-menu__icon-arrow {
  278. position: absolute;
  279. top: 50%;
  280. right: getCssVar('menu-base-level-padding');
  281. margin-top: -6px;
  282. transition: transform getCssVar('transition-duration');
  283. font-size: 12px;
  284. margin-right: 0;
  285. width: inherit;
  286. }
  287. }
  288. @include b(menu-item-group) {
  289. > ul {
  290. padding: 0;
  291. }
  292. @include e(title) {
  293. padding: 7px 0 7px getCssVar('menu-base-level-padding');
  294. line-height: normal;
  295. font-size: 12px;
  296. color: getCssVar('text-color', 'secondary');
  297. }
  298. }
  299. .horizontal-collapse-transition
  300. .#{$namespace}-sub-menu__title
  301. .#{$namespace}-sub-menu__icon-arrow {
  302. transition: getCssVar('transition-duration-fast');
  303. opacity: 0;
  304. }