_menu-main-navigation.scss 8.5 KB

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