|
| 1 | +//// |
| 2 | +/// @group components/generic-header |
| 3 | +//// |
| 4 | + |
| 5 | +@use "../../base"; |
| 6 | + |
| 7 | +/// Shared block header styles, with automatic background setting |
| 8 | +/// |
| 9 | +/// @param {String} $background - background colour of header |
| 10 | +/// @access private |
| 11 | +@mixin header-styles($background: base.govuk-colour("black")) { |
| 12 | + @include base.govuk-font($size: 16, $line-height: 1); |
| 13 | + |
| 14 | + // Add a transparent bottom border for forced-colour modes |
| 15 | + border-bottom: 1px solid transparent; |
| 16 | + color: base.govuk-colour("white"); |
| 17 | + background: $background; |
| 18 | + |
| 19 | + @media print { |
| 20 | + border-bottom-width: 0; |
| 21 | + color: base.govuk-colour("black"); |
| 22 | + background: transparent; |
| 23 | + } |
| 24 | +} |
| 25 | + |
| 26 | +/// Shared header logo container element styles, with automating padding setting |
| 27 | +/// |
| 28 | +/// @param {String} $padding-top - top padding of logo container |
| 29 | +/// @param {String} $padding-bottom - bottom padding of logo container |
| 30 | +/// @access private |
| 31 | +@mixin header-logo-styles($padding-top: base.govuk-spacing(3), $padding-bottom: base.govuk-spacing(3)) { |
| 32 | + box-sizing: border-box; |
| 33 | + padding-top: $padding-top; |
| 34 | + padding-bottom: $padding-bottom; |
| 35 | +} |
| 36 | + |
| 37 | +/// Shared header logo link element styles |
| 38 | +/// |
| 39 | +/// @access private |
| 40 | +@mixin header-link-styles { |
| 41 | + // Avoid using the `base.govuk-link-common` mixin because the links in the |
| 42 | + // header get a special treatment, because: |
| 43 | + // |
| 44 | + // - underlines are only visible on hover |
| 45 | + // - all links get a 3px underline regardless of text size, as there are |
| 46 | + // multiple grouped elements close to one another and having slightly |
| 47 | + // different underline widths looks unbalanced |
| 48 | + // |
| 49 | + // Font size needs to be set on the link so that the box sizing is correct |
| 50 | + // in Firefox |
| 51 | + display: inline; |
| 52 | + margin-right: base.govuk-spacing(2); |
| 53 | + font-size: 30px; // We don't have a mixin that produces 30px font size |
| 54 | + text-decoration: none; |
| 55 | + |
| 56 | + @include base.govuk-link-style-inverse; |
| 57 | + |
| 58 | + &:link, |
| 59 | + &:visited { |
| 60 | + text-decoration: none; |
| 61 | + } |
| 62 | + |
| 63 | + &:hover, |
| 64 | + &:active { |
| 65 | + // Negate the added border |
| 66 | + $link-underline-thickness: 3px; |
| 67 | + margin-bottom: $link-underline-thickness * -1; |
| 68 | + border-bottom: $link-underline-thickness solid; |
| 69 | + } |
| 70 | + |
| 71 | + &:focus { |
| 72 | + // Remove any borders that show when focused and hovered. |
| 73 | + margin-bottom: 0; |
| 74 | + border-bottom: 0; |
| 75 | + |
| 76 | + @include base.govuk-focused-text; |
| 77 | + } |
| 78 | + |
| 79 | + @media print { |
| 80 | + &:link, |
| 81 | + &:visited { |
| 82 | + color: base.govuk-colour("black"); |
| 83 | + } |
| 84 | + |
| 85 | + // Do not append link href to GOV.UK link when printing (e.g. '(/)') |
| 86 | + &::after { |
| 87 | + display: none; |
| 88 | + } |
| 89 | + } |
| 90 | +} |
| 91 | + |
| 92 | +/// @access private |
| 93 | +@mixin styles { |
| 94 | + .govuk-generic-header { |
| 95 | + @include header-styles; |
| 96 | + } |
| 97 | + |
| 98 | + .govuk-generic-header__container--full-width { |
| 99 | + padding: 0 base.govuk-spacing(3); |
| 100 | + } |
| 101 | + |
| 102 | + .govuk-generic-header__logo { |
| 103 | + @include header-logo-styles; |
| 104 | + } |
| 105 | + |
| 106 | + .govuk-generic-header__homepage-link { |
| 107 | + @include header-link-styles; |
| 108 | + } |
| 109 | +} |
0 commit comments