|
| 1 | +@include govuk-exports("govuk/component/service-navigation") { |
| 2 | + $govuk-service-navigation-active-link-border-width: govuk-spacing(1); |
| 3 | + $govuk-service-navigation-background: $govuk-canvas-background-colour; |
| 4 | + $govuk-service-navigation-border-colour: $govuk-border-colour; |
| 5 | + |
| 6 | + // We make the link colour a little darker than normal here so that it has |
| 7 | + // better perceptual contrast with the navigation background. |
| 8 | + $govuk-service-navigation-link-colour: govuk-shade($govuk-link-colour, 10%); |
| 9 | + |
| 10 | + .govuk-service-navigation { |
| 11 | + border-bottom: 1px solid $govuk-service-navigation-border-colour; |
| 12 | + background-color: $govuk-service-navigation-background; |
| 13 | + } |
| 14 | + |
| 15 | + .govuk-service-navigation__container { |
| 16 | + display: flex; |
| 17 | + flex-direction: column; |
| 18 | + align-items: start; |
| 19 | + |
| 20 | + @include govuk-media-query($from: tablet) { |
| 21 | + flex-direction: row; |
| 22 | + flex-wrap: wrap; |
| 23 | + } |
| 24 | + } |
| 25 | + |
| 26 | + // These styles are shared between nav items and the service name, they |
| 27 | + // ensure that both of them remain vertically aligned with one another |
| 28 | + .govuk-service-navigation__item, |
| 29 | + .govuk-service-navigation__service-name { |
| 30 | + position: relative; |
| 31 | + margin: govuk-spacing(2) 0; |
| 32 | + border: 0 solid $govuk-service-navigation-link-colour; |
| 33 | + |
| 34 | + @include govuk-media-query($from: tablet) { |
| 35 | + margin-top: 0; |
| 36 | + margin-bottom: 0; |
| 37 | + padding: govuk-spacing(4) 0; |
| 38 | + |
| 39 | + &:not(:last-child) { |
| 40 | + @include govuk-responsive-margin(6, $direction: right); |
| 41 | + } |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + .govuk-service-navigation__item--active { |
| 46 | + @include govuk-media-query($until: tablet) { |
| 47 | + // Negative offset the left margin so we can place a current page indicator |
| 48 | + // to the left without misaligning the list item text. |
| 49 | + margin-left: ((govuk-spacing(2) + $govuk-service-navigation-active-link-border-width) * -1); |
| 50 | + padding-left: govuk-spacing(2); |
| 51 | + border-left-width: $govuk-service-navigation-active-link-border-width; |
| 52 | + } |
| 53 | + |
| 54 | + @include govuk-media-query($from: tablet) { |
| 55 | + padding-bottom: govuk-spacing(4) - $govuk-service-navigation-active-link-border-width; |
| 56 | + border-bottom-width: $govuk-service-navigation-active-link-border-width; |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + .govuk-service-navigation__link { |
| 61 | + @include govuk-link-common; |
| 62 | + @include govuk-link-style-no-underline; |
| 63 | + @include govuk-link-style-no-visited-state; |
| 64 | + |
| 65 | + &:not(:hover):not(:focus) { |
| 66 | + // We set the colour here as we don't want to override the hover or |
| 67 | + // focus colours |
| 68 | + color: $govuk-service-navigation-link-colour; |
| 69 | + } |
| 70 | + } |
| 71 | + |
| 72 | + // |
| 73 | + // Service name specific code |
| 74 | + // |
| 75 | + |
| 76 | + .govuk-service-navigation__service-name { |
| 77 | + @include govuk-font($size: 19, $weight: bold); |
| 78 | + } |
| 79 | + |
| 80 | + // Annoyingly this requires a compound selector in order to overcome the |
| 81 | + // specificity of the other link colour override we're doing |
| 82 | + .govuk-service-navigation__service-name .govuk-service-navigation__link { |
| 83 | + @include govuk-link-style-text; |
| 84 | + } |
| 85 | + |
| 86 | + // |
| 87 | + // Navigation list specific code |
| 88 | + // |
| 89 | + |
| 90 | + .govuk-service-navigation__toggle { |
| 91 | + @include govuk-font($size: 19, $weight: bold); |
| 92 | + display: inline-flex; |
| 93 | + margin: 0 0 govuk-spacing(2); |
| 94 | + padding: 0; |
| 95 | + border: 0; |
| 96 | + color: $govuk-service-navigation-link-colour; |
| 97 | + background: none; |
| 98 | + word-break: break-all; |
| 99 | + cursor: pointer; |
| 100 | + align-items: center; |
| 101 | + |
| 102 | + &:focus { |
| 103 | + @include govuk-focused-text; |
| 104 | + } |
| 105 | + |
| 106 | + &::after { |
| 107 | + @include govuk-shape-arrow($direction: down, $base: 10px, $display: inline-block); |
| 108 | + content: ""; |
| 109 | + margin-left: govuk-spacing(1); |
| 110 | + } |
| 111 | + |
| 112 | + &[aria-expanded="true"]::after { |
| 113 | + @include govuk-shape-arrow($direction: up, $base: 10px, $display: inline-block); |
| 114 | + } |
| 115 | + |
| 116 | + // Ensure the button stays hidden if the hidden attribute is present |
| 117 | + &[hidden] { |
| 118 | + display: none; |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + .govuk-service-navigation__list { |
| 123 | + @include govuk-font($size: 19); |
| 124 | + margin: 0; |
| 125 | + margin-bottom: govuk-spacing(3); |
| 126 | + padding: 0; |
| 127 | + list-style: none; |
| 128 | + |
| 129 | + // Make the navigation list a flexbox. Doing so resolves a couple of |
| 130 | + // accessibility problems caused by the list items being inline-blocks: |
| 131 | + // - Removes the extra whitespace from between each list item that screen |
| 132 | + // readers would pointlessly announce. |
| 133 | + // - Fixes an NVDA issue in Firefox and Chrome <= 124 where it would read |
| 134 | + // all of the links as a run-on sentence. |
| 135 | + @include govuk-media-query($from: tablet) { |
| 136 | + display: flex; |
| 137 | + flex-wrap: wrap; |
| 138 | + margin-bottom: 0; |
| 139 | + |
| 140 | + // However... IE11 totally trips over flexbox and doesn't wrap anything, |
| 141 | + // making all of the items into a single, horizontally scrolling row, |
| 142 | + // which is no good. This CSS hack removes the flexbox definition for |
| 143 | + // IE 10 & 11, reverting it to the flawed, but OK, non-flexbox version. |
| 144 | + // |
| 145 | + // CSS hack taken from https://stackoverflow.com/questions/11173106/apply-style-only-on-ie#answer-36448860 |
| 146 | + // which also includes an explanation of why this works |
| 147 | + @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { |
| 148 | + display: block; |
| 149 | + } |
| 150 | + } |
| 151 | + } |
| 152 | + |
| 153 | + // This is a <strong> element that is used as a fallback mechanism for |
| 154 | + // visually indicating the current page in scenarios where CSS isn't |
| 155 | + // available. We don't actually want it to be bold normally, so set it to |
| 156 | + // inherit the parent font-weight. |
| 157 | + .govuk-service-navigation__active-fallback { |
| 158 | + font-weight: inherit; |
| 159 | + } |
| 160 | +} |
0 commit comments