menu.scss 7.9 KB

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