_navbar.scss 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. @mixin navbar-vertical-nav {
  2. .navbar-collapse {
  3. flex-direction: column;
  4. [class^="container"] {
  5. flex-direction: column;
  6. align-items: stretch;
  7. padding: 0;
  8. }
  9. .navbar-nav {
  10. margin-left: 0;
  11. margin-right: 0;
  12. .nav-link {
  13. padding: 0.5rem calc(#{$container-padding-x} / 2);
  14. justify-content: flex-start;
  15. }
  16. }
  17. .dropdown-menu-columns {
  18. flex-direction: column;
  19. }
  20. .dropdown-menu {
  21. padding: 0;
  22. background: transparent;
  23. position: static;
  24. color: inherit;
  25. box-shadow: none;
  26. border: none;
  27. min-width: 0;
  28. margin: 0;
  29. .dropdown-item {
  30. min-width: 0;
  31. display: flex;
  32. width: auto;
  33. padding-left: add(calc(#{$container-padding-x} / 2), 1.75rem);
  34. color: inherit;
  35. &.disabled {
  36. color: var(--#{$prefix}gray-300);
  37. pointer-events: none;
  38. background-color: transparent;
  39. }
  40. &.active,
  41. &:active {
  42. background: var(--#{$prefix}navbar-active-bg);
  43. }
  44. }
  45. .dropdown-menu .dropdown-item {
  46. padding-left: add(calc(#{$container-padding-x} / 2), 3.25rem);
  47. }
  48. .dropdown-menu .dropdown-menu .dropdown-item {
  49. padding-left: add(calc(#{$container-padding-x} / 2), 4.75rem);
  50. }
  51. }
  52. .dropdown-toggle:after {
  53. margin-left: auto;
  54. }
  55. .nav-item.active:after {
  56. border-bottom-width: 0;
  57. border-left-width: 3px;
  58. right: auto;
  59. top: 0;
  60. bottom: 0;
  61. }
  62. }
  63. }
  64. /**
  65. Navbar
  66. */
  67. .navbar {
  68. --#{$prefix}navbar-bg: var(--#{$prefix}bg-surface);
  69. --#{$prefix}navbar-border-width: #{$navbar-border-width};
  70. --#{$prefix}navbar-active-border-color: #{$navbar-active-border-color};
  71. --#{$prefix}navbar-active-bg: #{$navbar-light-active-bg};
  72. --#{$prefix}navbar-color: var(--#{$prefix}body-color);
  73. --#{$prefix}navbar-border-color: #{$navbar-border-color};
  74. align-items: stretch;
  75. min-height: $navbar-height;
  76. box-shadow: inset 0 calc(-1 * var(--#{$prefix}navbar-border-width)) 0 0 var(--#{$prefix}navbar-border-color);
  77. background: var(--#{$prefix}navbar-bg);
  78. color: var(--#{$prefix}navbar-color);
  79. .navbar-collapse & {
  80. flex-grow: 1;
  81. }
  82. &.collapsing {
  83. min-height: 0;
  84. }
  85. .dropdown-menu {
  86. position: absolute;
  87. z-index: $zindex-fixed;
  88. }
  89. .navbar-nav {
  90. min-height: subtract($navbar-height, 2 * $navbar-padding-y);
  91. .nav-link {
  92. position: relative;
  93. min-width: 2rem;
  94. min-height: 2rem;
  95. justify-content: center;
  96. border-radius: var(--#{$prefix}border-radius);
  97. .badge {
  98. position: absolute;
  99. top: 0.375rem;
  100. right: 0.375rem;
  101. transform: translate(50%, -50%);
  102. }
  103. }
  104. }
  105. }
  106. .navbar-nav {
  107. margin: 0;
  108. padding: 0;
  109. }
  110. .navbar-expand {
  111. @each $breakpoint in map-keys($grid-breakpoints) {
  112. $next: breakpoint-next($breakpoint, $grid-breakpoints);
  113. $infix: breakpoint-infix($next, $grid-breakpoints);
  114. &#{$infix} {
  115. @include media-breakpoint-down(breakpoint-next($breakpoint)) {
  116. @include navbar-vertical-nav;
  117. }
  118. @include media-breakpoint-up($next) {
  119. .navbar-collapse {
  120. width: auto;
  121. flex: 1 1 auto;
  122. }
  123. .nav-item.active {
  124. position: relative;
  125. &:after {
  126. content: "";
  127. position: absolute;
  128. left: 0;
  129. right: 0;
  130. bottom: -0.25rem;
  131. border: 0 var(--#{$prefix}border-style) var(--#{$prefix}navbar-active-border-color);
  132. border-bottom-width: 2px;
  133. }
  134. }
  135. &.navbar-vertical {
  136. box-shadow: inset calc(-1 * var(--#{$prefix}navbar-border-width)) 0 0 0 var(--#{$prefix}navbar-border-color);
  137. &.navbar-right {
  138. box-shadow: inset calc(1 * var(--#{$prefix}navbar-border-width)) 0 0 0 var(--#{$prefix}navbar-border-color);
  139. }
  140. }
  141. &.navbar-vertical {
  142. ~ .navbar,
  143. ~ .page-wrapper {
  144. margin-left: $sidebar-width;
  145. }
  146. }
  147. &.navbar-vertical.navbar-right {
  148. ~ .navbar,
  149. ~ .page-wrapper {
  150. margin-left: 0;
  151. margin-right: $sidebar-width;
  152. }
  153. }
  154. }
  155. }
  156. }
  157. }
  158. /**
  159. Navbar brand
  160. */
  161. .navbar-brand {
  162. display: inline-flex;
  163. align-items: center;
  164. font-weight: $navbar-brand-font-weight;
  165. margin: 0;
  166. line-height: 1;
  167. gap: $spacer-2;
  168. }
  169. .navbar-brand-image {
  170. height: $navbar-brand-image-height;
  171. width: auto;
  172. }
  173. /**
  174. Navbar toggler
  175. */
  176. .navbar-toggler {
  177. border: 0;
  178. width: $navbar-brand-image-height;
  179. height: $navbar-brand-image-height;
  180. position: relative;
  181. display: flex;
  182. align-items: center;
  183. justify-content: center;
  184. }
  185. .navbar-toggler-icon {
  186. height: 2px;
  187. width: 1.25em;
  188. background: currentColor;
  189. border-radius: 10px;
  190. @include transition(
  191. top $navbar-toggler-animation-time $navbar-toggler-animation-time,
  192. bottom $navbar-toggler-animation-time $navbar-toggler-animation-time,
  193. transform $navbar-toggler-animation-time,
  194. opacity 0s $navbar-toggler-animation-time
  195. );
  196. position: relative;
  197. &:before,
  198. &:after {
  199. content: "";
  200. display: block;
  201. height: inherit;
  202. width: inherit;
  203. border-radius: inherit;
  204. background: inherit;
  205. position: absolute;
  206. left: 0;
  207. @include transition(inherit);
  208. }
  209. &:before {
  210. top: -0.45em;
  211. }
  212. &:after {
  213. bottom: -0.45em;
  214. }
  215. .navbar-toggler[aria-expanded="true"] & {
  216. transform: rotate(45deg);
  217. @include transition(top $transition-time, bottom $transition-time, transform $transition-time $transition-time, opacity 0s $transition-time);
  218. &:before {
  219. top: 0;
  220. transform: rotate(-90deg);
  221. }
  222. &:after {
  223. bottom: 0;
  224. opacity: 0;
  225. }
  226. }
  227. }
  228. /**
  229. Navbar transparent
  230. */
  231. .navbar-transparent {
  232. --#{$prefix}navbar-border-color: transparent !important;
  233. background: transparent !important;
  234. }
  235. /**
  236. Navbar nav
  237. */
  238. .navbar-nav {
  239. align-items: stretch;
  240. .nav-item {
  241. display: flex;
  242. flex-direction: column;
  243. justify-content: center;
  244. }
  245. }
  246. /**
  247. Navbar side
  248. */
  249. .navbar-side {
  250. margin: 0;
  251. display: flex;
  252. flex-direction: row;
  253. align-items: center;
  254. justify-content: space-around;
  255. }
  256. /**
  257. Navbar vertical
  258. */
  259. @if $enable-navbar-vertical {
  260. .navbar-vertical {
  261. &.navbar-expand {
  262. @each $breakpoint in map-keys($grid-breakpoints) {
  263. $next: breakpoint-next($breakpoint, $grid-breakpoints);
  264. $infix: breakpoint-infix($next, $grid-breakpoints);
  265. &#{$infix} {
  266. @include media-breakpoint-up($next) {
  267. width: $sidebar-width;
  268. position: fixed;
  269. top: 0;
  270. left: 0;
  271. bottom: 0;
  272. z-index: $zindex-fixed;
  273. align-items: flex-start;
  274. @include transition(transform $transition-time);
  275. overflow-y: scroll;
  276. padding: 0;
  277. &.navbar-right {
  278. left: auto;
  279. right: 0;
  280. }
  281. .navbar-brand {
  282. padding: (($navbar-height - $navbar-brand-image-height) * 0.5) 0;
  283. justify-content: center;
  284. }
  285. .navbar-collapse {
  286. align-items: stretch;
  287. }
  288. .navbar-nav {
  289. flex-direction: column;
  290. flex-grow: 1;
  291. min-height: auto;
  292. .nav-link {
  293. padding-top: 0.5rem;
  294. padding-bottom: 0.5rem;
  295. }
  296. }
  297. > [class^="container"] {
  298. flex-direction: column;
  299. align-items: stretch;
  300. min-height: 100%;
  301. justify-content: flex-start;
  302. padding: 0;
  303. }
  304. ~ .page {
  305. padding-left: $sidebar-width;
  306. [class^="container"] {
  307. padding-left: 1.5rem;
  308. padding-right: 1.5rem;
  309. }
  310. }
  311. &.navbar-right ~ .page {
  312. padding-left: 0;
  313. padding-right: $sidebar-width;
  314. }
  315. @include navbar-vertical-nav;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. }
  322. .navbar-overlap {
  323. &:after {
  324. content: "";
  325. height: $navbar-overlap-height;
  326. position: absolute;
  327. top: 100%;
  328. left: 0;
  329. right: 0;
  330. background: inherit;
  331. z-index: -1;
  332. box-shadow: inherit;
  333. }
  334. }