menu.scss 7.6 KB

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