_menu-main-navigation.scss 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. /** === Main menu === */
  2. .main-navigation {
  3. display: block;
  4. margin-top: 1rem;
  5. margin-bottom: 0;
  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: $font__weight_semi_bold;
  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. svg {
  89. height: 24px;
  90. width: 24px;
  91. top: #{-0.125 * $size__spacing-unit};
  92. vertical-align: text-bottom;
  93. }
  94. }
  95. .wp-customizer-unloading &,
  96. &.is-empty {
  97. display: none;
  98. }
  99. svg {
  100. position: relative;
  101. top: 0.2rem;
  102. }
  103. }
  104. }
  105. &:last-child > a,
  106. &:last-child.menu-item-has-children .submenu-expand {
  107. margin-right: 0;
  108. }
  109. }
  110. }
  111. .sub-menu {
  112. text-align: left;
  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. font-weight: $font__weight_semi_bold;
  166. &:hover,
  167. &:focus {
  168. background: $color__link-hover;
  169. &:after {
  170. background: $color__link-hover;
  171. }
  172. }
  173. }
  174. > .menu-item-link-return {
  175. width: 100%;
  176. font-size: $font__size_base;
  177. font-weight: normal;
  178. text-align: left;
  179. }
  180. > a:empty {
  181. display: none;
  182. }
  183. &.mobile-parent-nav-menu-item {
  184. display: none;
  185. font-size: $font__size-sm;
  186. font-weight: normal;
  187. svg {
  188. position: relative;
  189. top: 0.2rem;
  190. margin-right: calc( .25 * #{$size__spacing-unit} );
  191. }
  192. }
  193. }
  194. }
  195. /*
  196. * Sub-menu styles
  197. *
  198. * :focus-within needs its own selector so other similar
  199. * selectors don’t get ignored if a browser doesn’t recognize it
  200. */
  201. .main-menu .menu-item-has-children:not(.off-canvas):focus-within > .sub-menu {
  202. display: block;
  203. left: 0;
  204. margin-top: 0;
  205. opacity: 1;
  206. width: auto;
  207. min-width: 100%;
  208. font-weight: $font__weight_semi_bold;
  209. /* Non-mobile position */
  210. @include media(tablet) {
  211. display: block;
  212. margin-top: 0;
  213. opacity: 1;
  214. position: absolute;
  215. left: 0;
  216. right: auto;
  217. top: auto;
  218. bottom: auto;
  219. height: auto;
  220. min-width: -moz-max-content;
  221. min-width: -webkit-max-content;
  222. min-width: max-content;
  223. transform: none;
  224. }
  225. &.hidden-links {
  226. left: 0;
  227. width: 100%;
  228. display: table;
  229. position: absolute;
  230. @include media(tablet) {
  231. right: 0;
  232. left: auto;
  233. display: block;
  234. width: max-content;
  235. }
  236. }
  237. .submenu-expand {
  238. display: none;
  239. }
  240. .sub-menu {
  241. display: block;
  242. margin-top: inherit;
  243. position: relative;
  244. width: 100%;
  245. left: 0;
  246. opacity: 1;
  247. font-weight: $font__weight_semi_bold;
  248. /* Non-mobile position */
  249. @include media(tablet) {
  250. float: none;
  251. max-width: 100%;
  252. }
  253. }
  254. /* Nested sub-menu dashes */
  255. .sub-menu {
  256. counter-reset: submenu;
  257. }
  258. .sub-menu > li > a::before {
  259. font-family: $font__body;
  260. font-weight: normal;
  261. content: "\2013\00a0" counters(submenu, "\2013\00a0", none);
  262. counter-increment: submenu
  263. }
  264. }
  265. .main-menu .menu-item-has-children:not(.off-canvas):hover > .sub-menu,
  266. .main-menu .menu-item-has-children:not(.off-canvas):focus > .sub-menu,
  267. .main-menu .menu-item-has-children.is-focused:not(.off-canvas) > .sub-menu {
  268. display: block;
  269. left: 0;
  270. margin-top: 0;
  271. opacity: 1;
  272. width: auto;
  273. min-width: 100%;
  274. /* Non-mobile position */
  275. @include media(tablet) {
  276. display: block;
  277. float: none;
  278. margin-top: 0;
  279. opacity: 1;
  280. position: absolute;
  281. left: 0;
  282. right: auto;
  283. top: auto;
  284. bottom: auto;
  285. height: auto;
  286. min-width: -moz-max-content;
  287. min-width: -webkit-max-content;
  288. min-width: max-content;
  289. transform: none;
  290. }
  291. &.hidden-links {
  292. left: 0;
  293. width: 100%;
  294. display: table;
  295. position: absolute;
  296. @include media(tablet) {
  297. right: 0;
  298. left: auto;
  299. display: table;
  300. width: max-content;
  301. }
  302. }
  303. .submenu-expand {
  304. display: none;
  305. }
  306. .sub-menu {
  307. display: block;
  308. margin-top: inherit;
  309. position: relative;
  310. width: 100%;
  311. left: 0;
  312. opacity: 1;
  313. /* Non-mobile position */
  314. @include media(tablet) {
  315. float: none;
  316. max-width: 100%;
  317. }
  318. }
  319. /* Nested sub-menu dashes */
  320. .sub-menu {
  321. counter-reset: submenu;
  322. }
  323. .sub-menu > li > a::before {
  324. font-family: $font__body;
  325. font-weight: normal;
  326. content: "\2013\00a0" counters(submenu, "\2013\00a0", none);
  327. counter-increment: submenu
  328. }
  329. }
  330. /**
  331. * Fade-in animation for top-level submenus
  332. */
  333. .main-menu > .menu-item-has-children:not(.off-canvas):hover > .sub-menu {
  334. animation: fade_in 0.1s forwards;
  335. }
  336. /**
  337. * Off-canvas touch device styles
  338. */
  339. .main-menu .menu-item-has-children.off-canvas .sub-menu {
  340. .submenu-expand .svg-icon {
  341. transform: rotate(270deg);
  342. }
  343. .sub-menu {
  344. opacity: 0;
  345. position: absolute;
  346. z-index: 0;
  347. transform: translateX(-100%);
  348. }
  349. li:hover,
  350. li:focus,
  351. li > a:hover,
  352. li > a:focus {
  353. background-color: transparent;
  354. }
  355. > li > a,
  356. > li > .menu-item-link-return {
  357. white-space: inherit;
  358. }
  359. &.expanded-true {
  360. display: table;
  361. margin-top: 0;
  362. opacity: 1;
  363. padding-left: 0;
  364. /* Mobile position */
  365. left: 0;
  366. top: 0;
  367. right: 0;
  368. bottom: 0;
  369. position: fixed;
  370. z-index: 100000; /* Make sure appears above mobile admin bar */
  371. width: 100vw;
  372. height: 100vh;
  373. max-width: 100vw;
  374. transform: translateX(+100%);
  375. animation: slide_in_right 0.3s forwards;
  376. > .mobile-parent-nav-menu-item {
  377. display: block;
  378. }
  379. /* Prevent menu from being blocked by admin bar */
  380. .admin-bar & {
  381. top: 46px;
  382. height: calc( 100vh - 46px );
  383. .sub-menu.expanded-true {
  384. top: 0;
  385. }
  386. /* WP core breakpoint */
  387. @media only screen and ( min-width: 782px ) {
  388. top: 32px;
  389. height: calc( 100vh - 32px );
  390. .sub-menu.expanded-true {
  391. top: 0;
  392. }
  393. }
  394. }
  395. }
  396. }
  397. // Hide duplicate menu-more-link when re-loading a menu in the customizer
  398. .main-menu-more {
  399. &:nth-child(n+3) {
  400. display: none;
  401. }
  402. }
  403. }
  404. /* Menu animation */
  405. @keyframes slide_in_right {
  406. 100% {
  407. transform: translateX(0%);
  408. }
  409. }
  410. @keyframes fade_in {
  411. from {
  412. opacity: 0;
  413. }
  414. to {
  415. opacity: 1;
  416. }
  417. }