_primary-navigation.scss 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. // Navigation
  2. .primary-navigation,
  3. .woo-navigation {
  4. position: absolute;
  5. top: 0;
  6. right: 0;
  7. color: var(--primary-nav--color-text);
  8. font-size: var(--primary-nav--font-size);
  9. margin-top: 0;
  10. margin-bottom: 0;
  11. @include media(mobile-only) {
  12. width: 100%;
  13. }
  14. // Mobile menu closed
  15. & > div {
  16. visibility: hidden;
  17. opacity: 0;
  18. position: fixed;
  19. top: 0;
  20. right: 0;
  21. bottom: 0;
  22. left: 0;
  23. padding: calc(4* var(--global--spacing-unit)) var(--global--spacing-unit) var(--global--spacing-horizontal);
  24. background-color: var(--global--color-background);
  25. overflow-x: hidden;
  26. overflow-y: scroll;
  27. transition: all .15s ease-in-out;
  28. transform: translateY(var(--global--spacing-vertical));
  29. @include media(mobile-only) {
  30. z-index: 499;
  31. }
  32. }
  33. // Mobile menu toggles
  34. > .button {
  35. position: absolute;
  36. display: inline-block;
  37. margin: 0;
  38. right: 0;
  39. top: 0;
  40. background-color: transparent;
  41. color: var(--primary-nav--color-link);
  42. &:hover {
  43. color: var(--primary-nav--color-hover);
  44. }
  45. }
  46. // Mobile menu open
  47. .primary-navigation-open & {
  48. > .primary-menu-container {
  49. visibility: visible;
  50. opacity: 1;
  51. transform: translateY(0);
  52. }
  53. > #toggle-menu {
  54. z-index: 500;
  55. .open {
  56. display: none;
  57. }
  58. .close {
  59. display: flex;
  60. }
  61. }
  62. }
  63. .dropdown-icon {
  64. display: flex;
  65. align-items: center;
  66. .svg-icon {
  67. margin-left: calc(0.25 * var(--global--spacing-unit));
  68. }
  69. // Menu icon is off-center vertically to prevent blurry pixels.
  70. &.open .svg-icon {
  71. position: relative;
  72. top: -1px;
  73. }
  74. &.close {
  75. display: none;
  76. }
  77. }
  78. // Adjust button postion when scrolling is locked
  79. .lock-scrolling & > .button {
  80. position: fixed;
  81. top: 0;
  82. right: 0;
  83. }
  84. // Adjust positions when logged-in
  85. .admin-bar &,
  86. .admin-bar & > div,
  87. .admin-bar.lock-scrolling & > .button {
  88. top: 46px;
  89. }
  90. @include media(mobile) {
  91. position: relative;
  92. display: flex;
  93. justify-content: var(--primary-nav--justify-content);
  94. margin-top: calc( var(--global--spacing-vertical) * 1.5 );
  95. // Mobile menu on desktop
  96. & > div {
  97. visibility: visible;
  98. opacity: 1;
  99. position: relative;
  100. padding: 0;
  101. background-color: transparent;
  102. overflow: initial;
  103. transform: none;
  104. }
  105. // Hide mobile menu toggle
  106. #toggle-menu {
  107. display: none;
  108. }
  109. // Hide sub-sub-menus
  110. & > div > ul > li > ul {
  111. display: none;
  112. }
  113. // Don't adjust position when logged-in
  114. .admin-bar & {
  115. top: initial;
  116. & > div {
  117. top: initial;
  118. }
  119. }
  120. }
  121. // Menu list wrapper
  122. & > div > ul {
  123. display: flex;
  124. justify-content: var(--primary-nav--justify-content);
  125. flex-wrap: wrap;
  126. list-style: none;
  127. margin: 0;
  128. max-width: none;
  129. padding-left: 0;
  130. position: relative;
  131. ul {
  132. padding-left: 0;
  133. }
  134. li {
  135. display: block;
  136. position: relative;
  137. width: 100%;
  138. z-index: 1;
  139. &:hover,
  140. &:focus-within {
  141. cursor: pointer;
  142. z-index: 99999;
  143. }
  144. @include media(mobile) {
  145. display: inherit;
  146. width: inherit;
  147. /* Submenu display */
  148. &:hover > ul,
  149. &:focus-within > ul,
  150. & ul:hover,
  151. & ul:focus {
  152. visibility: visible;
  153. opacity: 1;
  154. display: block;
  155. }
  156. }
  157. }
  158. & > li {
  159. @include media(mobile) {
  160. & > a {
  161. @include crop-text(var(--global--line-height-base));
  162. }
  163. }
  164. }
  165. /* Sub-menus Flyout */
  166. & > li > .sub-menu {
  167. position: relative;
  168. @include media(mobile) {
  169. margin: 0;
  170. background: var(--global--color-background);
  171. box-shadow: var(--global--elevation);
  172. left: 0;
  173. top: 100%;
  174. min-width: max-content;
  175. opacity: 0;
  176. position: absolute;
  177. transition: all 0.5s ease;
  178. visibility: hidden;
  179. }
  180. .sub-menu {
  181. width: 100%;
  182. }
  183. }
  184. }
  185. // Top-level Item Link Colors
  186. .primary-menu > .menu-item:hover > a {
  187. color: var(--primary-nav--color-link-hover);
  188. }
  189. // Menu Item Link Colors
  190. .menu-item > a {
  191. color: var(--primary-nav--color-link);
  192. &:hover,
  193. &:focus {
  194. color: var(--primary-nav--color-link-hover);
  195. }
  196. &:active {
  197. color: var(--primary-nav--color-link);
  198. }
  199. }
  200. // Menu Item
  201. a {
  202. color: currentColor;
  203. display: block;
  204. font-family: var(--primary-nav--font-family-mobile);
  205. font-size: var(--primary-nav--font-size-mobile);
  206. font-weight: var(--primary-nav--font-weight);
  207. padding: calc(0.5 * var(--primary-nav--padding)) 0;
  208. @include media(mobile) {
  209. font-family: var(--primary-nav--font-family);
  210. font-size: var(--primary-nav--font-size);
  211. font-weight: var(--primary-nav--font-weight);
  212. padding: var(--primary-nav--padding);
  213. }
  214. & + svg {
  215. fill: currentColor;
  216. }
  217. &:hover,
  218. &:link,
  219. &:visited {
  220. color: currentColor;
  221. }
  222. }
  223. // Sub-menu depth indicators + text styles
  224. .sub-menu {
  225. list-style: none;
  226. margin-left: var(--primary-nav--padding);
  227. .menu-item a {
  228. font-size: var(--primary-nav--font-size-sub-menu-mobile);
  229. font-style: var(--primary-nav--font-style-sub-menu-mobile);
  230. padding-top: calc(0.5 * var(--primary-nav--padding));
  231. padding-bottom: calc(0.5 * var(--primary-nav--padding));
  232. @include media(mobile) {
  233. font-size: var(--primary-nav--font-size);
  234. font-style: var(--primary-nav--font-style);
  235. }
  236. }
  237. }
  238. // Show top-level sub-menu indicators above mobile-breakpoint-only
  239. .menu-item-has-children {
  240. > .svg-icon {
  241. display: none;
  242. }
  243. @include media(mobile) {
  244. > a {
  245. padding-right: 0;
  246. }
  247. > .svg-icon {
  248. display: inline-block;
  249. height: 100%;
  250. margin-right: var(--primary-nav--padding);
  251. }
  252. }
  253. }
  254. .hide-visually {
  255. position: absolute !important;
  256. clip: rect(1px, 1px, 1px, 1px);
  257. padding:0 !important;
  258. border:0 !important;
  259. height: 1px !important;
  260. width: 1px !important;
  261. overflow: hidden;
  262. }
  263. }
  264. // Keep the menu pinned to the top when the menu is open.
  265. @include media(mobile-only) {
  266. .lock-scrolling .site {
  267. position: fixed;
  268. max-width: 100%;
  269. }
  270. }