menu.scss 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. i {
  23. color: inherit;
  24. }
  25. &:hover,
  26. &:focus {
  27. outline: none;
  28. }
  29. &:hover {
  30. background-color: getCssVar('menu-hover-bg-color');
  31. }
  32. @include when(disabled) {
  33. opacity: 0.25;
  34. cursor: not-allowed;
  35. background: none !important;
  36. }
  37. }
  38. :root {
  39. // They are defined on :root so they can be inherited by sub-menu instead of overwritten
  40. @include set-component-css-var('menu', $menu);
  41. }
  42. @include b(menu) {
  43. border-right: solid 1px getCssVar('menu-border-color');
  44. list-style: none;
  45. position: relative;
  46. margin: 0;
  47. padding-left: 0;
  48. background-color: getCssVar('menu-bg-color');
  49. box-sizing: border-box;
  50. @include m(vertical) {
  51. &:not(.#{$namespace}-menu--collapse):not(.#{$namespace}-menu--popup-container) {
  52. & .#{$namespace}-menu-item,
  53. & .#{$namespace}-sub-menu__title,
  54. & .#{$namespace}-menu-item-group__title {
  55. white-space: nowrap;
  56. padding-left: calc(
  57. #{getCssVar('menu-base-level-padding')} + #{getCssVar('menu-level')} *
  58. #{getCssVar('menu-level-padding')}
  59. );
  60. }
  61. }
  62. }
  63. &:not(.#{$namespace}-menu--collapse) .#{$namespace}-sub-menu__title {
  64. padding-right: calc(
  65. #{getCssVar('menu-base-level-padding')} + #{getCssVar('menu-icon-width')}
  66. );
  67. }
  68. @include m(horizontal) {
  69. display: flex;
  70. flex-wrap: nowrap;
  71. border-right: none;
  72. height: getCssVar('menu-horizontal-height');
  73. &.#{$namespace}-menu {
  74. border-bottom: solid 1px getCssVar('menu-border-color');
  75. }
  76. & > .#{$namespace}-menu-item {
  77. display: inline-flex;
  78. justify-content: center;
  79. align-items: center;
  80. height: 100%;
  81. margin: 0;
  82. border-bottom: 2px solid transparent;
  83. color: getCssVar('menu-text-color');
  84. a,
  85. a:hover {
  86. color: inherit;
  87. }
  88. }
  89. & > .#{$namespace}-sub-menu {
  90. &:focus,
  91. &:hover {
  92. outline: none;
  93. }
  94. &:hover {
  95. .#{$namespace}-sub-menu__title {
  96. color: getCssVar('menu-hover-text-color');
  97. }
  98. }
  99. &.is-active {
  100. .#{$namespace}-sub-menu__title {
  101. border-bottom: 2px solid getCssVar('menu-active-color');
  102. color: getCssVar('menu-active-color');
  103. }
  104. }
  105. & .#{$namespace}-sub-menu__title {
  106. height: 100%;
  107. border-bottom: 2px solid transparent;
  108. color: getCssVar('menu-text-color');
  109. &:hover {
  110. background-color: getCssVar('menu-bg-color');
  111. }
  112. }
  113. }
  114. & .#{$namespace}-menu {
  115. & .#{$namespace}-menu-item,
  116. & .#{$namespace}-sub-menu__title {
  117. background-color: getCssVar('menu-bg-color');
  118. display: flex;
  119. align-items: center;
  120. height: getCssVar('menu-horizontal-sub-item-height');
  121. line-height: getCssVar('menu-horizontal-sub-item-height');
  122. padding: 0 10px;
  123. color: getCssVar('menu-text-color');
  124. }
  125. & .#{$namespace}-sub-menu__title {
  126. padding-right: 40px;
  127. }
  128. & .#{$namespace}-menu-item.is-active,
  129. & .#{$namespace}-sub-menu.is-active > .#{$namespace}-sub-menu__title {
  130. color: getCssVar('menu-active-color');
  131. }
  132. }
  133. & .#{$namespace}-menu-item:not(.is-disabled):hover,
  134. & .#{$namespace}-menu-item:not(.is-disabled):focus {
  135. outline: none;
  136. color: getCssVar('menu-hover-text-color');
  137. background-color: getCssVar('menu-hover-bg-color');
  138. }
  139. & > .#{$namespace}-menu-item.is-active {
  140. border-bottom: 2px solid getCssVar('menu-active-color');
  141. color: getCssVar('menu-active-color') !important;
  142. }
  143. }
  144. @include m(collapse) {
  145. width: calc(
  146. #{getCssVar('menu-icon-width')} + #{getCssVar('menu-base-level-padding')} *
  147. 2
  148. );
  149. > .#{$namespace}-menu-item,
  150. > .#{$namespace}-sub-menu > .#{$namespace}-sub-menu__title,
  151. > .#{$namespace}-menu-item-group
  152. > ul
  153. > .#{$namespace}-sub-menu
  154. > .#{$namespace}-sub-menu__title {
  155. [class^='#{$namespace}-icon'] {
  156. margin: 0;
  157. vertical-align: middle;
  158. width: getCssVar('menu-icon-width');
  159. text-align: center;
  160. }
  161. .#{$namespace}-sub-menu__icon-arrow {
  162. display: none;
  163. }
  164. > span {
  165. height: 0;
  166. width: 0;
  167. overflow: hidden;
  168. visibility: hidden;
  169. display: inline-block;
  170. }
  171. }
  172. > .#{$namespace}-menu-item.is-active i {
  173. color: inherit;
  174. }
  175. .#{$namespace}-menu .#{$namespace}-sub-menu {
  176. min-width: 200px;
  177. }
  178. }
  179. @include m(popup) {
  180. z-index: 100;
  181. min-width: 200px;
  182. border: none;
  183. padding: 5px 0;
  184. border-radius: getCssVar('border-radius-small');
  185. box-shadow: getCssVar('box-shadow-light');
  186. }
  187. .#{$namespace}-icon {
  188. flex-shrink: 0;
  189. }
  190. }
  191. @include b(menu-item) {
  192. @include menu-item;
  193. & [class^='#{$namespace}-icon'] {
  194. margin-right: 5px;
  195. width: getCssVar('menu-icon-width');
  196. text-align: center;
  197. font-size: 18px;
  198. vertical-align: middle;
  199. }
  200. @include when(active) {
  201. color: getCssVar('menu-active-color');
  202. i {
  203. color: inherit;
  204. }
  205. }
  206. .#{$namespace}-menu-tooltip__trigger {
  207. position: absolute;
  208. left: 0;
  209. top: 0;
  210. height: 100%;
  211. width: 100%;
  212. display: inline-flex;
  213. align-items: center;
  214. box-sizing: border-box;
  215. padding: 0 getCssVar('menu-base-level-padding');
  216. }
  217. }
  218. @include b(sub-menu) {
  219. list-style: none;
  220. margin: 0;
  221. padding-left: 0;
  222. @include e(title) {
  223. @include menu-item;
  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. }