_menu-main-navigation.scss 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. /** === Main menu === */
  2. .main-navigation {
  3. display: block;
  4. margin-top: #{0.25 * $size__spacing-unit};
  5. width: 100%;
  6. body.page & {
  7. display: block;
  8. }
  9. > div {
  10. display: inline;
  11. }
  12. /* Un-style buttons */
  13. button {
  14. display: inline-block;
  15. border: none;
  16. padding: 0;
  17. margin: 0;
  18. font-family: $font__heading;
  19. font-weight: 700;
  20. line-height: $font__line-height-heading;
  21. text-decoration: none;
  22. background: transparent;
  23. color: inherit;
  24. cursor: pointer;
  25. transition: background 250ms ease-in-out,
  26. transform 150ms ease;
  27. -webkit-appearance: none;
  28. -moz-appearance: none;
  29. &:hover,
  30. &:focus {
  31. background: transparent;
  32. }
  33. &:focus {
  34. outline: 1px solid transparent;
  35. outline-offset: -4px;
  36. }
  37. &:active {
  38. transform: scale(0.99);
  39. }
  40. }
  41. .main-menu {
  42. display: inline-block;
  43. margin: 0;
  44. padding: 0;
  45. > li {
  46. color: $color__link;
  47. display: inline;
  48. position: relative;
  49. > a {
  50. font-weight: 600;
  51. color: $color__link;
  52. margin-right: #{0.5 * $size__spacing-unit};
  53. + svg {
  54. margin-right: #{0.5 * $size__spacing-unit};
  55. }
  56. &:hover,
  57. &:hover + svg {
  58. color: $color__link-hover;
  59. }
  60. }
  61. &.menu-item-has-children {
  62. display: inline-block;
  63. position: inherit;
  64. @include media(tablet) {
  65. position: relative;
  66. }
  67. > a {
  68. margin-right: #{0.125 * $size__spacing-unit};
  69. }
  70. & > a,
  71. .menu-item-has-children > a {
  72. &:after {
  73. content: "";
  74. display: none;
  75. }
  76. }
  77. .submenu-expand {
  78. display: inline-block;
  79. margin-right: #{0.25 * $size__spacing-unit};
  80. /* Priority+ Menu */
  81. &.main-menu-more-toggle {
  82. position: relative;
  83. height: 24px;
  84. line-height: $font__line-height-heading;
  85. width: 24px;
  86. padding: 0;
  87. margin-left: #{0.5 * $size__spacing-unit};
  88. top: 6px;
  89. svg {
  90. height: 24px;
  91. width: 24px;
  92. top: #{-0.125 * $size__spacing-unit};
  93. vertical-align: text-bottom;
  94. }
  95. }
  96. .wp-customizer-unloading &,
  97. &.is-empty {
  98. display: none;
  99. }
  100. svg {
  101. position: relative;
  102. top: 0.2rem;
  103. }
  104. }
  105. }
  106. &:last-child > a,
  107. &:last-child.menu-item-has-children .submenu-expand {
  108. margin-right: 0;
  109. }
  110. }
  111. }
  112. .sub-menu {
  113. background-color: $color__link;
  114. color: $color__background-body;
  115. list-style: none;
  116. padding-left: 0;
  117. position: absolute;
  118. opacity: 0;
  119. left: -9999px;
  120. z-index: 99999;
  121. @include media(tablet) {
  122. width: auto;
  123. min-width: -moz-max-content;
  124. min-width: -webkit-max-content;
  125. min-width: max-content;
  126. }
  127. > li {
  128. display: block;
  129. float: none;
  130. position: relative;
  131. &.menu-item-has-children {
  132. .submenu-expand {
  133. display: inline-block;
  134. position: absolute;
  135. width: calc( 24px + #{$size__spacing-unit} );
  136. right: 0;
  137. top: calc( .125 * #{$size__spacing-unit} );
  138. bottom: 0;
  139. color: white;
  140. line-height: 1;
  141. padding: calc( .5 * #{$size__spacing-unit} );
  142. svg {
  143. top: 0;
  144. }
  145. }
  146. .submenu-expand {
  147. margin-right: 0;
  148. }
  149. @include media(tablet) {
  150. .menu-item-has-children > a {
  151. &:after {
  152. content: "\203a";
  153. }
  154. }
  155. }
  156. }
  157. > a,
  158. > .menu-item-link-return {
  159. color: $color__background-body;
  160. display: block;
  161. line-height: $font__line-height-heading;
  162. text-shadow: none;
  163. padding: calc( .5 * #{$size__spacing-unit} ) calc( 24px + #{$size__spacing-unit} ) calc( .5 * #{$size__spacing-unit} ) $size__spacing-unit;
  164. white-space: nowrap;
  165. &:hover,
  166. &:focus {
  167. background: $color__link-hover;
  168. &:after {
  169. background: $color__link-hover;
  170. }
  171. }
  172. }
  173. > .menu-item-link-return {
  174. width: 100%;
  175. font-size: $font__size_base;
  176. font-weight: normal;
  177. text-align: left;
  178. }
  179. > a:empty {
  180. display: none;
  181. }
  182. &.mobile-parent-nav-menu-item {
  183. display: none;
  184. font-size: $font__size-sm;
  185. font-weight: normal;
  186. svg {
  187. position: relative;
  188. top: 0.2rem;
  189. margin-right: calc( .25 * #{$size__spacing-unit} );
  190. }
  191. }
  192. }
  193. }
  194. /*
  195. * Sub-menu styles
  196. *
  197. * :focus-within needs its own selector so other similar
  198. * selectors don’t get ignored if a browser doesn’t recognize it
  199. */
  200. .main-menu .menu-item-has-children:not(.off-canvas):focus-within > .sub-menu {
  201. display: block;
  202. left: 0;
  203. margin-top: 0;
  204. opacity: 1;
  205. width: auto;
  206. min-width: 100%;
  207. /* Non-mobile position */
  208. @include media(tablet) {
  209. display: block;
  210. margin-top: 0;
  211. opacity: 1;
  212. position: absolute;
  213. left: 0;
  214. right: auto;
  215. top: auto;
  216. bottom: auto;
  217. height: auto;
  218. min-width: -moz-max-content;
  219. min-width: -webkit-max-content;
  220. min-width: max-content;
  221. transform: none;
  222. }
  223. &.hidden-links {
  224. left: 0;
  225. width: 100%;
  226. display: table;
  227. position: absolute;
  228. @include media(tablet) {
  229. right: 0;
  230. left: auto;
  231. display: block;
  232. width: max-content;
  233. }
  234. }
  235. .submenu-expand {
  236. display: none;
  237. }
  238. .sub-menu {
  239. display: block;
  240. margin-top: inherit;
  241. position: relative;
  242. width: 100%;
  243. left: 0;
  244. opacity: 1;
  245. /* Non-mobile position */
  246. @include media(tablet) {
  247. float: none;
  248. max-width: 100%;
  249. }
  250. }
  251. /* Nested sub-menu dashes */
  252. .sub-menu {
  253. counter-reset: submenu;
  254. }
  255. .sub-menu > li > a::before {
  256. font-family: $font__body;
  257. font-weight: normal;
  258. content: "\2013\00a0" counters(submenu, "\2013\00a0", none);
  259. counter-increment: submenu
  260. }
  261. }
  262. .main-menu .menu-item-has-children:not(.off-canvas):hover > .sub-menu,
  263. .main-menu .menu-item-has-children:not(.off-canvas):focus > .sub-menu,
  264. .main-menu .menu-item-has-children.is-focused:not(.off-canvas) > .sub-menu {
  265. display: block;
  266. left: 0;
  267. margin-top: 0;
  268. opacity: 1;
  269. width: auto;
  270. min-width: 100%;
  271. /* Non-mobile position */
  272. @include media(tablet) {
  273. display: block;
  274. float: none;
  275. margin-top: 0;
  276. opacity: 1;
  277. position: absolute;
  278. left: 0;
  279. right: auto;
  280. top: auto;
  281. bottom: auto;
  282. height: auto;
  283. min-width: -moz-max-content;
  284. min-width: -webkit-max-content;
  285. min-width: max-content;
  286. transform: none;
  287. }
  288. &.hidden-links {
  289. left: 0;
  290. width: 100%;
  291. display: table;
  292. position: absolute;
  293. @include media(tablet) {
  294. right: 0;
  295. left: auto;
  296. display: table;
  297. width: max-content;
  298. }
  299. }
  300. .submenu-expand {
  301. display: none;
  302. }
  303. .sub-menu {
  304. display: block;
  305. margin-top: inherit;
  306. position: relative;
  307. width: 100%;
  308. left: 0;
  309. opacity: 1;
  310. /* Non-mobile position */
  311. @include media(tablet) {
  312. float: none;
  313. max-width: 100%;
  314. }
  315. }
  316. /* Nested sub-menu dashes */
  317. .sub-menu {
  318. counter-reset: submenu;
  319. }
  320. .sub-menu > li > a::before {
  321. font-family: $font__body;
  322. font-weight: normal;
  323. content: "\2013\00a0" counters(submenu, "\2013\00a0", none);
  324. counter-increment: submenu
  325. }
  326. }
  327. /**
  328. * Fade-in animation for top-level submenus
  329. */
  330. .main-menu > .menu-item-has-children:not(.off-canvas):hover > .sub-menu {
  331. animation: fade_in 0.1s forwards;
  332. }
  333. /**
  334. * Off-canvas touch device styles
  335. */
  336. .main-menu .menu-item-has-children.off-canvas .sub-menu {
  337. .submenu-expand .svg-icon {
  338. transform: rotate(270deg);
  339. }
  340. .sub-menu {
  341. opacity: 0;
  342. position: absolute;
  343. z-index: 0;
  344. transform: translateX(-100%);
  345. }
  346. li:hover,
  347. li:focus,
  348. li > a:hover,
  349. li > a:focus {
  350. background-color: transparent;
  351. }
  352. > li > a,
  353. > li > .menu-item-link-return {
  354. white-space: inherit;
  355. }
  356. &.expanded-true {
  357. display: table;
  358. margin-top: 0;
  359. opacity: 1;
  360. padding-left: 0;
  361. /* Mobile position */
  362. left: 0;
  363. top: 0;
  364. right: 0;
  365. bottom: 0;
  366. position: fixed;
  367. z-index: 100000; /* Make sure appears above mobile admin bar */
  368. width: 100vw;
  369. height: 100vh;
  370. max-width: 100vw;
  371. transform: translateX(+100%);
  372. animation: slide_in_right 0.3s forwards;
  373. > .mobile-parent-nav-menu-item {
  374. display: block;
  375. }
  376. /* Prevent menu from being blocked by admin bar */
  377. .admin-bar & {
  378. top: 46px;
  379. height: calc( 100vh - 46px );
  380. .sub-menu.expanded-true {
  381. top: 0;
  382. }
  383. /* WP core breakpoint */
  384. @media only screen and ( min-width: 782px ) {
  385. top: 32px;
  386. height: calc( 100vh - 32px );
  387. .sub-menu.expanded-true {
  388. top: 0;
  389. }
  390. }
  391. }
  392. }
  393. }
  394. // Hide duplicate menu-more-link when re-loading a menu in the customizer
  395. .main-menu-more {
  396. &:nth-child(n+3) {
  397. display: none;
  398. }
  399. }
  400. }
  401. /* Menu animation */
  402. @keyframes slide_in_right {
  403. 100% {
  404. transform: translateX(0%);
  405. }
  406. }
  407. @keyframes fade_in {
  408. from {
  409. opacity: 0;
  410. }
  411. to {
  412. opacity: 1;
  413. }
  414. }