_menu-main-navigation.scss 8.8 KB

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