nav-primary-wide.pcss.css

Same filename in other branches
  1. 10 core/themes/olivero/css/components/navigation/nav-primary-wide.pcss.css
  2. 11.x core/themes/olivero/css/components/navigation/nav-primary-wide.pcss.css

Nav Primary (wide widths).

File

core/themes/olivero/css/components/navigation/nav-primary-wide.pcss.css

View source
  1. /**
  2. * @file
  3. * Nav Primary (wide widths).
  4. */
  5. @import "../../base/variables.pcss.css";
  6. body:not(.is-always-mobile-nav) {
  7. @media (--nav) {
  8. & .primary-nav__menu-item {
  9. flex-wrap: nowrap; /* Ensure that sub navigation toggle button doesn't wrap underneath link. */
  10. &.primary-nav__menu-item--has-children {
  11. & .primary-nav__menu-link--link,
  12. & .primary-nav__menu-link--nolink {
  13. flex-basis: auto;
  14. }
  15. /* Remove hover state if submenu exists. */
  16. & .primary-nav__menu-link--level-1 .primary-nav__menu-link-inner:after {
  17. content: none;
  18. }
  19. }
  20. }
  21. & .primary-nav__menu-link {
  22. letter-spacing: 0.02em;
  23. font-size: 16px;
  24. line-height: var(--sp1-5);
  25. &:focus {
  26. position: relative;
  27. outline: 0;
  28. &:before {
  29. position: absolute;
  30. top: 50%;
  31. left: 50%;
  32. width: calc(100% + var(--sp));
  33. height: var(--sp3);
  34. content: "";
  35. transform: translate(-50%, -50%);
  36. border: solid 2px var(--color--blue-50);
  37. border-radius: 4px;
  38. }
  39. }
  40. }
  41. & .primary-nav__menu-link--button {
  42. &.primary-nav__menu-link--has-children {
  43. overflow: visible; /* Necessary to view icon in IE11 */
  44. padding-inline-end: 9px;
  45. &:focus:before {
  46. width: calc(100% + var(--sp1-5));
  47. content: "";
  48. }
  49. &:before {
  50. content: none;
  51. }
  52. /* Chevron icon for desktop navigation. */
  53. &:after {
  54. position: absolute;
  55. inset-block-start: 50%;
  56. inset-inline-start: calc(100% - 3px);
  57. width: 8px;
  58. height: 8px;
  59. margin-block-start: -2px;
  60. transform: translateY(-50%) rotate(45deg);
  61. /* Intentionally not using CSS logical properties. */
  62. border-top: 0;
  63. border-right: solid 2px currentColor;
  64. border-bottom: solid 2px currentColor;
  65. }
  66. &[aria-expanded="true"]:after {
  67. opacity: 1;
  68. }
  69. }
  70. }
  71. & .primary-nav__menu-link-inner {
  72. padding-block: var(--sp2);
  73. padding-inline-start: 0;
  74. padding-inline-end: 0;
  75. &:after {
  76. transform-origin: center;
  77. border-top-width: var(--sp0-5);
  78. }
  79. }
  80. & .primary-nav__menu--level-1 {
  81. display: flex;
  82. align-items: stretch;
  83. margin-inline-end: var(--sp);
  84. }
  85. & .primary-nav__menu-item--level-1 {
  86. position: relative; /* Anchor secondary menu */
  87. display: flex;
  88. align-items: center;
  89. width: max-content;
  90. max-width: 200px;
  91. margin-block: 0;
  92. margin-inline-start: 0;
  93. margin-inline-end: 0;
  94. &:not(:last-child) {
  95. margin-inline-end: var(--sp2);
  96. }
  97. }
  98. & .primary-nav__menu--level-2 {
  99. position: absolute;
  100. z-index: 105; /* Appear above search container. */
  101. top: calc(100% - (0.5 * var(--sp)));
  102. left: 50%;
  103. visibility: hidden;
  104. overflow: auto;
  105. width: 250px;
  106. /**
  107. * Ensure that long level-2 menus will never overflow viewport (focused
  108. * elements should always be in viewport per accessibility guidelines).
  109. */
  110. max-height: calc(100vh - var(--site-header-height-wide) - var(--sp));
  111. margin-block-start: 0;
  112. margin-inline-start: 0;
  113. padding-block: calc(3 * var(--sp));
  114. padding-inline-start: var(--sp2);
  115. padding-inline-end: var(--sp2);
  116. transition: none;
  117. transform: translate(-50%, -20px);
  118. opacity: 0;
  119. /* Intentionally not using CSS logical properties. */
  120. border-top: solid var(--color--blue-50) var(--sp0-5);
  121. border-right: solid 1px transparent; /* Transparent borders useful for Windows High Contrast mode. */
  122. border-bottom: solid 1px transparent;
  123. border-left: solid 1px transparent;
  124. border-radius: 0 0 2px 2px;
  125. background: var(--color--white);
  126. box-shadow: 0 1px 36px rgba(0, 0, 0, 0.08);
  127. &.is-active-menu-parent {
  128. visibility: visible;
  129. margin-block-start: 0;
  130. transform: translate(-50%, 0);
  131. opacity: 1;
  132. }
  133. }
  134. & .primary-nav__menu-link--level-2 {
  135. display: block;
  136. &:focus:before {
  137. top: 0;
  138. left: calc(var(--sp0-5) * -1);
  139. height: 100%;
  140. transform: none;
  141. }
  142. & .primary-nav__menu-link-inner {
  143. padding-block: var(--sp0-5);
  144. padding-inline-start: 0;
  145. padding-inline-end: 0;
  146. &:after {
  147. transform-origin: left;
  148. border-top-width: 3px;
  149. }
  150. }
  151. }
  152. /**
  153. * Arrow is placed outside of submenu because the submenu has the
  154. * `overflow: hidden` CSS rule applied.
  155. */
  156. & .primary-nav__menu-🥕 {
  157. position: absolute;
  158. z-index: 105; /* Match level 2 menus. */
  159. top: calc(100% - var(--sp));
  160. left: 50%;
  161. visibility: hidden;
  162. width: 0;
  163. height: 0;
  164. transform: translate(-50%, -20px);
  165. opacity: 0;
  166. /* Intentionally not using CSS logical properties. */
  167. border-right: solid 10px transparent;
  168. border-bottom: solid 10px var(--color--blue-50);
  169. border-left: solid 10px transparent;
  170. &.is-active-menu-parent {
  171. visibility: visible;
  172. transform: translate(-50%, 0);
  173. opacity: 1;
  174. }
  175. }
  176. /**
  177. * When ensuring that long menus don't overflow viewport, we can give a
  178. * little extra room when the toolbar is fixed (and is shorter).
  179. */
  180. & .is-fixed .primary-nav__menu--level-2 {
  181. max-height: calc(100vh - var(--site-header-height-wide) - var(--sp) + var(--sp4));
  182. }
  183. }
  184. }
  185. /*
  186. * Take into account Drupal's admin toolbars when ensuring that long level-2
  187. * menus will never overflow viewport.
  188. */
  189. @media (--nav) {
  190. body:not(.is-always-mobile-nav) {
  191. /* Toolbar is fixed, and tray is vertical or toolbar is horizontal and tray is closed. */
  192. &.toolbar-vertical,
  193. &.toolbar-horizontal.toolbar-fixed {
  194. & .primary-nav__menu--level-2 {
  195. max-height: calc(100vh - var(--site-header-height-wide) - var(--sp) - var(--toolbar-height));
  196. }
  197. & .is-fixed .primary-nav__menu--level-2 {
  198. max-height: calc(100vh - var(--site-header-height-wide) - var(--sp) - var(--toolbar-height) + var(--sp4));
  199. }
  200. }
  201. /* Toolbar is horizontal fixed, and tray is open. */
  202. &.toolbar-horizontal.toolbar-fixed.toolbar-tray-open {
  203. & .primary-nav__menu--level-2 {
  204. max-height: calc(100vh - var(--site-header-height-wide) - var(--sp) - var(--toolbar-height) - var(--toolbar-tray-height));
  205. }
  206. & .is-fixed .primary-nav__menu--level-2 {
  207. max-height: calc(100vh - var(--site-header-height-wide) - var(--sp) - var(--toolbar-height) - var(--toolbar-tray-height) + var(--sp4));
  208. }
  209. }
  210. }
  211. }
  212. /*
  213. * Only apply transition styles to menu when JS is loaded. This
  214. * works around https://bugs.chromium.org/p/chromium/issues/detail?id=332189
  215. */
  216. html.js body:not(.is-always-mobile-nav) {
  217. @media (--nav) {
  218. & .primary-nav__menu--level-2,
  219. & .primary-nav__menu-🥕 {
  220. transition: visibility 0.2s, transform 0.2s, opacity 0.2s;
  221. }
  222. }
  223. }
  224. [dir="rtl"] {
  225. & body:not(.is-always-mobile-nav) {
  226. @media (--nav) {
  227. & .primary-nav__menu-link--level-2 {
  228. & .primary-nav__menu-link-inner:after {
  229. transform-origin: right;
  230. }
  231. }
  232. }
  233. }
  234. }

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.