_dropdown.scss 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 #ccc; // Fallback for IE7-8
  53. border: 1px solid $dropdownBorder;
  54. text-align: left;
  55. // Aligns the dropdown menu to right
  56. &.pull-right {
  57. right: 0;
  58. left: auto;
  59. }
  60. .divider {
  61. height: 1px;
  62. margin: $space-sm 0; // 8px 1px
  63. overflow: hidden;
  64. background-color: $dropdownDividerTop;
  65. border-bottom: 1px solid $dropdownDividerBottom;
  66. }
  67. // Links within the dropdown menu
  68. > li {
  69. > a {
  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: 14px;
  87. height: 14px;
  88. }
  89. }
  90. }
  91. &--navbar {
  92. top: 100%;
  93. min-width: 100%;
  94. }
  95. &--menu,
  96. &--navbar,
  97. &--sidemenu {
  98. background: $menu-dropdown-bg;
  99. box-shadow: $menu-dropdown-shadow;
  100. margin-top: 0px;
  101. border: none;
  102. > li > a {
  103. display: flex;
  104. padding: 5px 10px;
  105. border-left: 2px solid transparent;
  106. &:hover {
  107. @include left-brand-border-gradient();
  108. color: $link-hover-color;
  109. background: $menu-dropdown-hover-bg !important;
  110. }
  111. }
  112. }
  113. &--sidemenu {
  114. li.sidemenu-org-switcher {
  115. > a {
  116. padding: 8px 10px 8px 15px;
  117. }
  118. }
  119. }
  120. }
  121. .dropdown-item-text {
  122. flex-grow: 1;
  123. }
  124. // Hover/Focus state
  125. // -----------
  126. .dropdown-menu > li > a:hover,
  127. .dropdown-menu > li > a:focus,
  128. .dropdown-submenu:hover > a,
  129. .dropdown-submenu:focus > a {
  130. text-decoration: none;
  131. color: $dropdownLinkColorHover;
  132. background-color: $dropdownLinkBackgroundHover;
  133. }
  134. // Active state
  135. // ------------
  136. .dropdown-menu > .active > a,
  137. .dropdown-menu > .active > a:hover,
  138. .dropdown-menu > .active > a:focus {
  139. color: $dropdownLinkColorActive;
  140. text-decoration: none;
  141. outline: 0;
  142. background-color: $dropdownLinkBackgroundHover;
  143. }
  144. // Disabled state
  145. // --------------
  146. // Gray out text and ensure the hover/focus state remains gray
  147. .dropdown-menu > .disabled > a,
  148. .dropdown-menu > .disabled > a:hover,
  149. .dropdown-menu > .disabled > a:focus {
  150. color: $gray-2;
  151. }
  152. // Nuke hover/focus effects
  153. .dropdown-menu > .disabled > a:hover,
  154. .dropdown-menu > .disabled > a:focus {
  155. text-decoration: none;
  156. background-color: transparent;
  157. background-image: none; // Remove CSS gradient
  158. cursor: default;
  159. }
  160. // Open state for the dropdown
  161. // ---------------------------
  162. .open {
  163. & > .dropdown-menu {
  164. display: block;
  165. }
  166. & > .dropdown > .dropdown-menu {
  167. // Panel menu. TODO: See if we can merge this with above
  168. display: block;
  169. }
  170. &.cascade-open {
  171. .dropdown-menu {
  172. display: block;
  173. }
  174. }
  175. }
  176. // Backdrop to catch body clicks on mobile, etc.
  177. // ---------------------------
  178. .dropdown-backdrop {
  179. position: fixed;
  180. left: 0;
  181. right: 0;
  182. bottom: 0;
  183. top: 0;
  184. z-index: $zindex-dropdown - 10;
  185. }
  186. // Right aligned dropdowns
  187. // ---------------------------
  188. .pull-right > .dropdown-menu {
  189. right: 0;
  190. left: auto;
  191. }
  192. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  193. // ------------------------------------------------------
  194. // Just add .dropup after the standard .dropdown class and you're set, bro.
  195. // TODO: abstract this so that the navbar fixed styles are not placed here?
  196. .dropup,
  197. .navbar-fixed-bottom .dropdown {
  198. // Reverse the caret
  199. .caret {
  200. border-top: 0;
  201. border-bottom: 4px solid $black;
  202. content: '';
  203. }
  204. // Different positioning for bottom up menu
  205. .dropdown-menu {
  206. top: auto;
  207. bottom: 0;
  208. margin-bottom: 1px;
  209. }
  210. }
  211. // Sub menus
  212. // ---------------------------
  213. .dropdown-submenu {
  214. position: relative;
  215. }
  216. // Default dropdowns
  217. .dropdown-submenu > .dropdown-menu {
  218. top: 0;
  219. left: 100%;
  220. margin-top: 0px;
  221. margin-left: -1px;
  222. @include border-radius(0 6px 6px 6px);
  223. }
  224. .dropdown-submenu:hover > .dropdown-menu {
  225. display: block;
  226. }
  227. // Dropups
  228. .dropup .dropdown-submenu > .dropdown-menu {
  229. top: auto;
  230. bottom: 0;
  231. margin-top: 0;
  232. margin-bottom: -2px;
  233. @include border-radius(5px 5px 5px 0);
  234. }
  235. // Caret to indicate there is a submenu
  236. .dropdown-submenu > a::after {
  237. position: absolute;
  238. top: 35%;
  239. right: $space-sm;
  240. background-color: transparent;
  241. color: $text-color-weak;
  242. font: normal normal normal $font-size-sm/1 FontAwesome;
  243. content: '\f0da';
  244. pointer-events: none;
  245. font-size: 11px;
  246. }
  247. .dropdown-submenu:hover > a::after {
  248. border-left-color: $dropdownLinkColorHover;
  249. }
  250. // Left aligned submenus
  251. .dropdown-submenu.pull-left {
  252. // Undo the float
  253. // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  254. float: none;
  255. // Positioning the submenu
  256. > .dropdown-menu {
  257. left: -100%;
  258. margin-left: 10px;
  259. @include border-radius(6px 0 6px 6px);
  260. }
  261. }
  262. // Tweak nav headers
  263. // -----------------
  264. // Increase padding from 15px to 20px on sides
  265. .dropdown .dropdown-menu .nav-header {
  266. padding-left: 20px;
  267. padding-right: 20px;
  268. }
  269. // Typeahead
  270. // ---------
  271. .typeahead {
  272. z-index: $zindex-typeahead;
  273. margin-top: 2px; // give it some space to breathe
  274. }
  275. .dropdown-menu-item-shortcut {
  276. display: block;
  277. margin-left: $spacer;
  278. color: $text-muted;
  279. min-width: 47px;
  280. &::before {
  281. font-family: FontAwesome;
  282. width: 28px;
  283. display: inline-block;
  284. text-align: center;
  285. content: '\f11c';
  286. }
  287. }
  288. .dropdown-menu.dropdown-menu--new {
  289. li a {
  290. padding: $spacer/2 $spacer;
  291. border-left: 2px solid $side-menu-bg;
  292. background: $side-menu-bg;
  293. i {
  294. display: inline-block;
  295. padding-right: 21px;
  296. }
  297. &:hover {
  298. @include left-brand-border-gradient();
  299. color: $link-hover-color;
  300. background: $input-label-bg;
  301. }
  302. }
  303. }