menu.scss 7.7 KB

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