Нема описа

navigation.scss 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. // Navigation
  2. // Mobile menu toggles
  3. .menu-button-container {
  4. display: none;
  5. justify-content: space-between;
  6. position: absolute;
  7. right: 0;
  8. padding-top: calc(0.5 * var(--global--spacing-vertical));
  9. padding-bottom: calc(0.25 * var(--global--spacing-vertical));
  10. @include media(mobile-only) {
  11. display: flex;
  12. }
  13. // Override specificity from default button styles.
  14. #primary-mobile-menu {
  15. display: flex;
  16. margin-left: auto;
  17. padding: calc(var(--button--padding-vertical) - (0.25 * var(--global--spacing-unit))) calc(0.5 * var(--button--padding-horizontal));
  18. font-size: var(--primary-nav--font-size-button);
  19. font-weight: var(--primary-nav--font-weight-button);
  20. background-color: transparent;
  21. border: none;
  22. color: var(--primary-nav--color-link);
  23. .dropdown-icon {
  24. display: flex;
  25. align-items: center;
  26. .svg-icon {
  27. margin-left: calc(0.25 * var(--global--spacing-unit));
  28. }
  29. // Menu icon is off-center vertically to prevent blurry pixels.
  30. &.open .svg-icon {
  31. position: relative;
  32. top: -1px;
  33. }
  34. &.close {
  35. display: none;
  36. }
  37. }
  38. &[aria-expanded*="true"] {
  39. .dropdown-icon {
  40. &.open {
  41. display: none;
  42. }
  43. &.close {
  44. display: flex;
  45. .has-logo.has-title-and-tagline & {
  46. animation-name: twentytwentyone-close-button-transition;
  47. animation-duration: 0.3s;
  48. }
  49. }
  50. }
  51. }
  52. }
  53. // When the menu is open, hide the close button and show the hide button.
  54. .primary-navigation-open & {
  55. width: 100%;
  56. z-index: 500;
  57. background-color: var(--global--color-background);
  58. #primary-mobile-menu {
  59. position: static;
  60. }
  61. }
  62. }
  63. .primary-navigation {
  64. position: absolute;
  65. top: var(--global--admin-bar--height);
  66. right: 0;
  67. color: var(--primary-nav--color-text);
  68. font-size: var(--primary-nav--font-size);
  69. line-height: 1.15;
  70. margin-top: 0;
  71. margin-bottom: 0;
  72. // Mobile menu closed
  73. > .primary-menu-container {
  74. position: fixed;
  75. visibility: hidden;
  76. opacity: 0;
  77. top: 0;
  78. right: 0;
  79. bottom: 0;
  80. left: 0;
  81. // Height of the menu-button-container using font size, line height, and total padding, plus 5px so the focus of the first item is visible.
  82. padding-top: calc(var(--button--line-height) * var(--primary-nav--font-size-button) + 42px + 5px);
  83. padding-left: var(--global--spacing-unit);
  84. padding-right: var(--global--spacing-unit);
  85. padding-bottom: var(--global--spacing-horizontal);
  86. background-color: var(--global--color-background);
  87. transition: all .15s ease-in-out;
  88. transform: translateY(var(--global--spacing-vertical));
  89. @include media(mobile-only) {
  90. height: 100vh;
  91. z-index: 499;
  92. overflow-x: hidden;
  93. overflow-y: auto;
  94. border: 2px solid transparent;
  95. .has-logo.has-title-and-tagline & {
  96. position: fixed;
  97. transform: translateY(0) translateX(100%);
  98. }
  99. .admin-bar .has-logo.has-title-and-tagline & {
  100. top: var(--global--admin-bar--height);
  101. }
  102. .admin-bar & {
  103. height: calc(100vh - var(--global--admin-bar--height));
  104. }
  105. &:focus {
  106. border: 2px solid var(--global--color-primary);
  107. }
  108. }
  109. }
  110. // Mobile menu open
  111. .primary-navigation-open & {
  112. @include media(mobile-only) {
  113. width: 100%;
  114. position: fixed;
  115. z-index: 2; // To be greater than the cover block and embeds.
  116. }
  117. > .primary-menu-container {
  118. position: absolute;
  119. visibility: visible;
  120. opacity: 1;
  121. transform: translateY(0);
  122. }
  123. }
  124. .primary-navigation-open .has-logo.has-title-and-tagline & {
  125. @include media(mobile-only) {
  126. > .primary-menu-container {
  127. transform: translateX(0) translateY(0);
  128. }
  129. }
  130. }
  131. @include media(mobile) {
  132. position: relative;
  133. margin-left: auto;
  134. // Hide Mobile menu on desktop
  135. > .primary-menu-container {
  136. visibility: visible;
  137. opacity: 1;
  138. position: relative;
  139. padding: 0;
  140. background-color: transparent;
  141. overflow: initial;
  142. transform: none;
  143. }
  144. // Hide mobile menu toggle
  145. #toggle-menu {
  146. display: none;
  147. }
  148. // Hide sub-sub-menus
  149. > .primary-menu-container ul > li .sub-menu-toggle[aria-expanded="false"] ~ ul {
  150. display: none;
  151. }
  152. // Don't adjust position when logged-in
  153. .admin-bar & {
  154. top: initial;
  155. > .primary-menu-container {
  156. top: initial;
  157. }
  158. }
  159. }
  160. // Menu list wrapper
  161. > div > .menu-wrapper {
  162. display: flex;
  163. justify-content: flex-start;
  164. flex-wrap: wrap;
  165. list-style: none;
  166. margin: 0;
  167. max-width: none;
  168. padding-left: 0;
  169. position: relative;
  170. @include media(mobile-only) {
  171. padding-bottom: 100px;
  172. ul {
  173. padding-left: 0;
  174. }
  175. }
  176. li {
  177. display: block;
  178. position: relative;
  179. width: 100%;
  180. @include media(mobile) {
  181. margin: 0;
  182. width: inherit;
  183. &:last-child {
  184. margin-right: 0;
  185. }
  186. }
  187. }
  188. // Sub-menu buttons
  189. .sub-menu-toggle {
  190. display: flex;
  191. height: calc(2 * var(--primary-nav--padding) + 1.15em + 1px);
  192. width: 44px;
  193. padding: 0;
  194. justify-content: center;
  195. align-items: center;
  196. background: transparent;
  197. color: currentColor;
  198. border: none;
  199. &:focus {
  200. outline: 2px solid var(--wp--style--color--link, var(--global--color-primary));
  201. }
  202. @include media(mobile-only) {
  203. display: none;
  204. }
  205. .icon-plus,
  206. .icon-minus {
  207. height: 100%;
  208. display: flex;
  209. align-items: center;
  210. svg {
  211. margin-top: -1px;
  212. }
  213. }
  214. .icon-minus {
  215. display: none;
  216. }
  217. // When the sub-menu is open, display the minus icon
  218. &[aria-expanded="true"] {
  219. .icon-minus {
  220. display: flex;
  221. }
  222. .icon-plus {
  223. display: none;
  224. }
  225. }
  226. }
  227. // Sub-menus Flyout
  228. > li > .sub-menu {
  229. position: relative;
  230. @include media(mobile) {
  231. left: 0;
  232. margin: 0;
  233. min-width: max-content;
  234. position: absolute;
  235. top: 100%;
  236. padding-top: 3px;
  237. transition: all 0.5s ease;
  238. z-index: 88888;
  239. &:before,
  240. &:after {
  241. content: "";
  242. display: block;
  243. position: absolute;
  244. width: 0;
  245. top: -10px;
  246. left: var(--global--spacing-horizontal);
  247. border-style: solid;
  248. border-color: var(--primary-nav--border-color) transparent;
  249. border-width: 0 7px 10px 7px;
  250. }
  251. &:after {
  252. top: -9px;
  253. border-color: var(--global--color-background) transparent;
  254. }
  255. li {
  256. background: var(--global--color-background);
  257. }
  258. &.submenu-reposition-left {
  259. /* rtl:ignore */
  260. left: 0;
  261. /* rtl:ignore */
  262. right: auto;
  263. &:before,
  264. &:after {
  265. /* rtl:ignore */
  266. left: var(--global--spacing-horizontal);
  267. /* rtl:ignore */
  268. right: auto;
  269. }
  270. }
  271. &.submenu-reposition-right {
  272. /* rtl:ignore */
  273. right: 0;
  274. /* rtl:ignore */
  275. left: auto;
  276. &:before,
  277. &:after {
  278. /* rtl:ignore */
  279. left: auto;
  280. /* rtl:ignore */
  281. right: var(--global--spacing-horizontal);
  282. }
  283. }
  284. }
  285. }
  286. }
  287. // Top-level Item Link Colors
  288. .primary-menu > .menu-item:hover > a {
  289. color: var(--primary-nav--color-link-hover);
  290. }
  291. .primary-menu-container {
  292. @include media(mobile) {
  293. // Better align with the site title when the menu wraps.
  294. margin-right: calc(0px - var(--primary-nav--padding));
  295. margin-left: calc(0px - var(--primary-nav--padding));
  296. // Top-level Menu Item
  297. > ul > .menu-item {
  298. display: flex;
  299. > a {
  300. padding-left: var(--primary-nav--padding);
  301. padding-right: var(--primary-nav--padding);
  302. + .sub-menu-toggle {
  303. margin-left: calc(5px - var(--primary-nav--padding));
  304. }
  305. }
  306. }
  307. }
  308. }
  309. // Menu Item Link
  310. a {
  311. display: block;
  312. font-family: var(--primary-nav--font-family-mobile);
  313. font-size: var(--primary-nav--font-size-mobile);
  314. font-weight: var(--primary-nav--font-weight);
  315. padding: var(--primary-nav--padding) 0;
  316. text-decoration: none;
  317. @include media(mobile) {
  318. display: block;
  319. font-family: var(--primary-nav--font-family);
  320. font-size: var(--primary-nav--font-size);
  321. font-weight: var(--primary-nav--font-weight);
  322. }
  323. + svg {
  324. fill: var(--primary-nav--color-text);
  325. }
  326. &:hover,
  327. &:link,
  328. &:visited {
  329. color: var(--primary-nav--color-link-hover);
  330. }
  331. &:hover {
  332. text-decoration: underline;
  333. text-decoration-style: dotted;
  334. }
  335. &:focus {
  336. position: relative;
  337. z-index: 99999; // Ensure focus styles appear above absolute positioned elements
  338. outline-offset: 0;
  339. text-decoration-thickness: 2px;
  340. }
  341. }
  342. .current-menu-item > a:first-child,
  343. .current_page_item > a:first-child {
  344. text-decoration: underline;
  345. text-decoration-style: solid;
  346. &:hover {
  347. text-decoration: underline;
  348. text-decoration-style: dotted;
  349. }
  350. }
  351. // Sub-menu depth indicators + text styles
  352. .sub-menu {
  353. margin: 0;
  354. padding: 0;
  355. list-style: none;
  356. margin-left: var(--primary-nav--padding);
  357. border: 1px solid var(--primary-nav--border-color);
  358. .sub-menu {
  359. border: none;
  360. }
  361. // Sub-menu items om wide screens.
  362. @include media(mobile) {
  363. // For nested sub-menus, don't duplicate the padding
  364. > .menu-item > .sub-menu {
  365. padding: 0;
  366. }
  367. }
  368. .menu-item {
  369. @include media(mobile-only) {
  370. &:last-child {
  371. margin-bottom: 0;
  372. }
  373. }
  374. > a {
  375. padding: calc(1.25 * var(--primary-nav--padding)) var(--primary-nav--padding);
  376. display: block;
  377. font-size: var(--primary-nav--font-size-sub-menu-mobile);
  378. font-style: var(--primary-nav--font-style-sub-menu-mobile);
  379. @include media(mobile) {
  380. font-size: var(--primary-nav--font-size-sub-menu);
  381. font-style: var(--primary-nav--font-style);
  382. }
  383. }
  384. }
  385. }
  386. // Show top-level sub-menu indicators above mobile-breakpoint-only
  387. .menu-item-has-children {
  388. > .svg-icon {
  389. display: none;
  390. }
  391. @include media(mobile) {
  392. > .svg-icon {
  393. display: inline-block;
  394. height: 100%;
  395. }
  396. .sub-menu .svg-icon {
  397. display: none;
  398. }
  399. }
  400. }
  401. .menu-item-description {
  402. display: block;
  403. clear: both;
  404. font-size: var(--global--font-size-xs);
  405. text-transform: none;
  406. line-height: 1.7;
  407. > span {
  408. display: inline-block;
  409. }
  410. }
  411. }
  412. // Keep the menu pinned to the top when the menu is open.
  413. @include media(mobile-only) {
  414. .lock-scrolling .site {
  415. position: fixed;
  416. max-width: 100%;
  417. width: 100%;
  418. }
  419. }
  420. // Close button animation for when a custom logo is present.
  421. @keyframes twentytwentyone-close-button-transition {
  422. from {
  423. opacity: 0;
  424. }
  425. to {
  426. opacity: 1;
  427. }
  428. }