_dropdown.scss 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. //
  2. // Dropdown menus
  3. // --------------------------------------------------
  4. // Use the .menu class on any <li> element within the topbar or ul.tabs and you'll get some superfancy dropdowns
  5. .dropup,
  6. .dropdown {
  7. position: relative;
  8. }
  9. .dropdown-toggle:active,
  10. .open .dropdown-toggle {
  11. outline: 0;
  12. }
  13. .dropdown-desc {
  14. position: relative;
  15. top: -3px;
  16. width: 250px;
  17. font-size: $font-size-sm;
  18. margin-left: 22px;
  19. color: $gray-2;
  20. white-space: normal;
  21. }
  22. // Dropdown arrow/caret
  23. // --------------------
  24. .caret {
  25. display: inline-block;
  26. width: 0;
  27. height: 0;
  28. vertical-align: top;
  29. border-top: 4px solid $text-color-weak;
  30. border-right: 4px solid transparent;
  31. border-left: 4px solid transparent;
  32. content: '';
  33. }
  34. // Place the caret
  35. .dropdown .caret {
  36. margin-top: 8px;
  37. margin-left: 2px;
  38. }
  39. // The dropdown menu (ul)
  40. // ----------------------
  41. .dropdown-menu {
  42. position: absolute;
  43. top: 100%;
  44. left: 0;
  45. z-index: $zindex-dropdown;
  46. display: none; // none by default, but block on "open" of the menu
  47. float: left;
  48. min-width: 140px;
  49. margin: 2px 0 0; // override default ul
  50. list-style: none;
  51. background-color: $dropdownBackground;
  52. border: 1px solid $dropdownBorder;
  53. text-align: left;
  54. // Aligns the dropdown menu to right
  55. &.pull-left {
  56. right: 0;
  57. left: auto;
  58. }
  59. .divider {
  60. height: 1px;
  61. margin: $space-sm 0; // 8px 1px
  62. overflow: hidden;
  63. background-color: $dropdownDividerTop;
  64. border-bottom: 1px solid $dropdownDividerBottom;
  65. }
  66. // Links within the dropdown menu
  67. > li {
  68. > a,
  69. > button {
  70. display: block;
  71. padding: 3px 20px 3px 15px;
  72. clear: both;
  73. font-weight: normal;
  74. line-height: $line-height-base;
  75. color: $dropdownLinkColor;
  76. white-space: nowrap;
  77. i {
  78. display: inline-block;
  79. margin-right: 10px;
  80. color: $link-color-disabled;
  81. position: relative;
  82. top: 3px;
  83. }
  84. .gicon {
  85. opacity: 0.7;
  86. width: 18px;
  87. height: 14px;
  88. }
  89. }
  90. }
  91. &--menu {
  92. background: $menu-dropdown-bg;
  93. box-shadow: $menu-dropdown-shadow;
  94. margin-top: 0px;
  95. > li > a,
  96. > li > button {
  97. display: flex;
  98. padding: 5px 10px;
  99. border-left: 2px solid transparent;
  100. &:hover {
  101. color: $link-hover-color;
  102. background: $menu-dropdown-hover-bg !important;
  103. }
  104. }
  105. }
  106. }
  107. .dropdown-item-text {
  108. flex-grow: 1;
  109. }
  110. // Hover/Focus state
  111. // -----------
  112. .dropdown-menu > li > a:hover,
  113. .dropdown-menu > li > a:focus,
  114. .dropdown-submenu:hover > a,
  115. .dropdown-submenu:focus > a,
  116. .dropdown-menu > li > button:hover,
  117. .dropdown-menu > li > button:focus,
  118. .dropdown-submenu:hover > button,
  119. .dropdown-submenu:focus > button {
  120. text-decoration: none;
  121. color: $dropdownLinkColorHover;
  122. background-color: $dropdownLinkBackgroundHover;
  123. }
  124. // Active state
  125. // ------------
  126. .dropdown-menu > .active > a,
  127. .dropdown-menu > .active > a:hover,
  128. .dropdown-menu > .active > a:focus,
  129. .dropdown-menu > .active > button,
  130. .dropdown-menu > .active > button:hover,
  131. .dropdown-menu > .active > button:focus {
  132. color: $dropdownLinkColorActive;
  133. text-decoration: none;
  134. outline: 0;
  135. background-color: $dropdownLinkBackgroundHover;
  136. }
  137. // Disabled state
  138. // --------------
  139. // Gray out text and ensure the hover/focus state remains gray
  140. .dropdown-menu > .disabled > a,
  141. .dropdown-menu > .disabled > a:hover,
  142. .dropdown-menu > .disabled > a:focus,
  143. .dropdown-menu > .disabled > button,
  144. .dropdown-menu > .disabled > button:hover,
  145. .dropdown-menu > .disabled > button:focus {
  146. color: $gray-2;
  147. }
  148. // Nuke hover/focus effects
  149. .dropdown-menu > .disabled > a:hover,
  150. .dropdown-menu > .disabled > a:focus,
  151. .dropdown-menu > .disabled > button:hover,
  152. .dropdown-menu > .disabled > button:focus {
  153. text-decoration: none;
  154. background-color: transparent;
  155. background-image: none; // Remove CSS gradient
  156. cursor: default;
  157. }
  158. // Open state for the dropdown
  159. // ---------------------------
  160. .open {
  161. > .dropdown-menu {
  162. display: block;
  163. }
  164. > .dropdown > .dropdown-menu {
  165. // Panel menu. TODO: See if we can merge this with above
  166. display: block;
  167. }
  168. &.cascade-open {
  169. .dropdown-menu {
  170. display: block;
  171. }
  172. }
  173. }
  174. // Backdrop to catch body clicks on mobile, etc.
  175. // ---------------------------
  176. .dropdown-backdrop {
  177. position: fixed;
  178. left: 0;
  179. right: 0;
  180. bottom: 0;
  181. top: 0;
  182. z-index: $zindex-dropdown - 10;
  183. }
  184. // Right aligned dropdowns
  185. // ---------------------------
  186. .pull-right > .dropdown-menu {
  187. left: 100%;
  188. right: unset;
  189. }
  190. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  191. // ------------------------------------------------------
  192. // Just add .dropup after the standard .dropdown class and you're set, bro.
  193. // TODO: abstract this so that the navbar fixed styles are not placed here?
  194. .dropup,
  195. .navbar-fixed-bottom .dropdown {
  196. // Reverse the caret
  197. .caret {
  198. border-top: 0;
  199. border-bottom: 4px solid $black;
  200. content: '';
  201. }
  202. // Different positioning for bottom up menu
  203. .dropdown-menu {
  204. top: auto;
  205. bottom: 0;
  206. margin-bottom: 1px;
  207. }
  208. }
  209. // Sub menus
  210. // ---------------------------
  211. .dropdown-submenu {
  212. position: relative;
  213. }
  214. // Default dropdowns
  215. .dropdown-submenu > .dropdown-menu {
  216. top: 0;
  217. left: 100%;
  218. margin-top: 0px;
  219. margin-left: -1px;
  220. }
  221. .dropdown-submenu:hover > .dropdown-menu {
  222. display: block;
  223. }
  224. // Dropups
  225. .dropup .dropdown-submenu > .dropdown-menu {
  226. top: auto;
  227. bottom: 0;
  228. margin-top: 0;
  229. margin-bottom: -2px;
  230. }
  231. // .dropdown-submenu > a::after {
  232. // position: absolute;
  233. // top: 35%;
  234. // right: $space-sm;
  235. // background-color: transparent;
  236. // color: $text-color-weak;
  237. // font: normal normal normal $font-size-sm/1 FontAwesome;
  238. // content: '\f0da';
  239. // pointer-events: none;
  240. // font-size: 11px;
  241. // }
  242. .dropdown-submenu:hover > a::after,
  243. .dropdown-submenu:hover > button::after {
  244. border-left-color: $dropdownLinkColorHover;
  245. }
  246. // Left aligned submenus
  247. .dropdown-submenu.pull-left {
  248. // Undo the float
  249. // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  250. float: none !important;
  251. // Positioning the submenu
  252. > .dropdown-menu {
  253. left: -100%;
  254. width: 100%;
  255. margin-left: 2px;
  256. }
  257. }
  258. .dropdown-submenu.pull-right {
  259. float: none !important;
  260. }
  261. // Tweak nav headers
  262. // -----------------
  263. // Increase padding from 15px to 20px on sides
  264. .dropdown .dropdown-menu .nav-header {
  265. padding-left: 20px;
  266. padding-right: 20px;
  267. }
  268. // Typeahead
  269. // ---------
  270. .typeahead {
  271. z-index: $zindex-typeahead;
  272. }
  273. .dropdown-menu-item-shortcut {
  274. display: block;
  275. margin-left: $spacer;
  276. color: $text-muted;
  277. min-width: 47px;
  278. }
  279. .dropdown-menu.dropdown-menu--new {
  280. li a,
  281. li button {
  282. padding: calc($spacer/2) $spacer;
  283. border-left: 2px solid $side-menu-bg;
  284. background: $side-menu-bg;
  285. i {
  286. display: inline-block;
  287. padding-right: 21px;
  288. }
  289. &:hover {
  290. color: $link-hover-color;
  291. background: $input-label-bg;
  292. }
  293. }
  294. }