govuk_publishing_components 44.1.0 → 44.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js +336 -225
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs +334 -226
- data/node_modules/govuk-frontend/dist/govuk/all.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/all.mjs +3 -0
- data/node_modules/govuk-frontend/dist/govuk/all.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.svg +1 -0
- data/node_modules/govuk-frontend/dist/govuk/common/govuk-frontend-version.mjs +1 -1
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs +21 -1
- data/node_modules/govuk-frontend/dist/govuk/common/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js +92 -26
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs +92 -26
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs +12 -21
- data/node_modules/govuk-frontend/dist/govuk/components/accordion/accordion.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/button/button.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs +10 -19
- data/node_modules/govuk-frontend/dist/govuk/components/character-count/character-count.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/checkboxes/checkboxes.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss +7 -2
- data/node_modules/govuk-frontend/dist/govuk/components/details/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/error-summary/error-summary.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/exit-this-page/exit-this-page.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss +8 -10
- data/node_modules/govuk-frontend/dist/govuk/components/footer/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss +8 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/fixtures.json +12 -0
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs +87 -21
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/header/header.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/header/template-with-full-width-border.html +24 -0
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs +86 -20
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs +6 -16
- data/node_modules/govuk-frontend/dist/govuk/components/notification-banner/notification-banner.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs +89 -23
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs +9 -18
- data/node_modules/govuk-frontend/dist/govuk/components/password-input/password-input.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs +113 -47
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs +7 -16
- data/node_modules/govuk-frontend/dist/govuk/components/radios/radios.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/README.md +15 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss +168 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_index.scss.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss +4 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/_service-navigation.scss.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/fixtures.json +464 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro-options.json +138 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/macro.njk +3 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js +249 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.js.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs +241 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.bundle.mjs.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs +85 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/service-navigation.mjs.map +1 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-default.html +57 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-html-navigation-items.html +49 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-large-navigation.html +153 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-long-service-name.html +20 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-a-current-item.html +58 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-navigation-with-an-active-item.html +58 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-non-link-navigation-items.html +49 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-link.html +20 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name-and-navigation.html +63 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template-with-service-name.html +18 -0
- data/node_modules/govuk-frontend/dist/govuk/components/service-navigation/template.njk +102 -0
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js +93 -26
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs +93 -26
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs +13 -21
- data/node_modules/govuk-frontend/dist/govuk/components/skip-link/skip-link.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js +93 -27
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs +93 -27
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.bundle.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs +13 -22
- data/node_modules/govuk-frontend/dist/govuk/components/tabs/tabs.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss +4 -3
- data/node_modules/govuk-frontend/dist/govuk/components/warning-text/_index.scss.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/core/_govuk-frontend-properties.scss +1 -1
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs +16 -3
- data/node_modules/govuk-frontend/dist/govuk/errors/index.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs +49 -5
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend-component.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css +2 -2
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.css.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js +1 -1
- data/node_modules/govuk-frontend/dist/govuk/govuk-frontend.min.js.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/init.mjs +72 -10
- data/node_modules/govuk-frontend/dist/govuk/init.mjs.map +1 -1
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss +3 -0
- data/node_modules/govuk-frontend/dist/govuk/settings/_colours-organisations.scss.map +1 -1
- data/node_modules/govuk-frontend/govuk-prototype-kit.config.json +5 -1
- data/node_modules/govuk-frontend/package.json +8 -8
- metadata +29 -4
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest-2x.png +0 -0
- data/node_modules/govuk-frontend/dist/govuk/assets/images/govuk-crest.png +0 -0
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/govuk/components/footer/_index.scss"],"names":[],"mappings":"AAAA;EACE,yDAAyD;EACzD,0CAA0C;EAC1C,sCAAsC;;EAEtC,
|
1
|
+
{"version":3,"sources":["../../../../src/govuk/components/footer/_index.scss"],"names":[],"mappings":"AAAA;EACE,yDAAyD;EACzD,0CAA0C;EAC1C,sCAAsC;;EAEtC,6BAA6B;EAC7B,sCAAsC;EACtC,uCAAuC;;EAEvC;IACE,mEAAmE;IACnE,2CAA2C;IAC3C,8CAA8C;;IAE9C,0CAA0C;IAC1C,yBAAyB;IACzB,oCAAoC;EACtC;;EAEA;IACE,0BAA0B;IAC1B,8BAA8B;EAChC;;EAEA;IACE,SAAS,EAAE,8BAA8B;IACzC,6CAA6C;IAC7C,SAAS,EAAE,8BAA8B;IACzC,6CAA6C;EAC/C;;EAEA;IACE,aAAa,EAAE,kBAAkB;IACjC,iCAAiC;IACjC,gCAAgC;IAChC,eAAe,EAAE,kBAAkB;IACnC,qBAAqB,EAAE,kBAAkB;IACzC,uBAAuB,EAAE,kBAAkB;EAC7C;;EAEA;IACE,gCAAgC;IAChC,+BAA+B;IAC/B,+BAA+B;EACjC;;EAEA;IACE,OAAO,EAAE,kBAAkB;IAC3B;MACE,iBAAiB,EAAE,kBAAkB;IACvC;EACF;;EAEA;IACE,qBAAqB;IACrB,8BAA8B;IAC9B;MACE,+BAA+B;IACjC;IACA,mBAAmB;IACnB,wEAAwE;IACxE,mDAAmD;IACnD,yBAAyB;EAC3B;;EAEA;IACE,qFAAqF;IACrF,qBAAqB;IACrB,+EAA+E;IAC/E,uCAAuC;IACvC,kBAAkB;EACpB;;EAEA;IACE,qBAAqB;IACrB,0CAA0C;IAC1C,kEAAkE;IAClE,oDAAoD;IACpD,4BAA4B;IAC5B,2BAA2B;IAC3B,iFAAiF;IACjF,kBAAkB;IAClB,mBAAmB;EACrB;;EAEA;IACE,aAAa;IACb,+BAA+B;IAC/B,UAAU;EACZ;;EAEA;IACE,+BAA+B;EACjC;;EAEA;IACE,qBAAqB;IACrB,8BAA8B;IAC9B,+BAA+B;EACjC;;EAEA;IACE,+BAA+B;IAC/B,gCAAgC;;IAEhC;MACE,gCAAgC;IAClC;IACA,6CAA6C;EAC/C;;EAEA;IACE,uBAAuB;IACvB,iCAAiC;IACjC,gCAAgC;EAClC;;EAEA;IACE,qBAAqB;IACrB,4BAA4B;IAC5B,mBAAmB;EACrB;;EAEA;IACE,SAAS;IACT,UAAU;IACV,gBAAgB;IAChB,yBAAyB,EAAE,kBAAkB;EAC/C;;EAEA;IACE;MACE,eAAe,EAAE,kBAAkB;IACrC;;IAEA;MACE,eAAe,EAAE,kBAAkB;IACrC;EACF;;EAEA;IACE,6CAA6C;EAC/C;;EAEA;IACE,gBAAgB;EAClB;AACF","file":"_index.scss","sourcesContent":["@include govuk-exports(\"govuk/component/footer\") {\n $govuk-footer-background: $govuk-canvas-background-colour;\n $govuk-footer-border: $govuk-border-colour;\n $govuk-footer-text: $govuk-text-colour;\n\n // Royal Arms image dimensions\n $govuk-footer-crest-image-width: 125px;\n $govuk-footer-crest-image-height: 102px;\n\n .govuk-footer {\n @include govuk-font($size: if($govuk-new-typography-scale, 19, 16));\n @include govuk-responsive-padding(7, \"top\");\n @include govuk-responsive-padding(5, \"bottom\");\n\n border-top: 1px solid $govuk-footer-border;\n color: $govuk-footer-text;\n background: $govuk-footer-background;\n }\n\n .govuk-footer__link {\n @include govuk-link-common;\n @include govuk-link-style-text;\n }\n\n .govuk-footer__section-break {\n margin: 0; // Reset `<hr>` default margins\n @include govuk-responsive-margin(8, \"bottom\");\n border: 0; // Reset `<hr>` default borders\n border-bottom: 1px solid $govuk-footer-border;\n }\n\n .govuk-footer__meta {\n display: flex; // Support: Flexbox\n margin-right: -$govuk-gutter-half;\n margin-left: -$govuk-gutter-half;\n flex-wrap: wrap; // Support: Flexbox\n align-items: flex-end; // Support: Flexbox\n justify-content: center; // Support: Flexbox\n }\n\n .govuk-footer__meta-item {\n margin-right: $govuk-gutter-half;\n margin-bottom: govuk-spacing(5);\n margin-left: $govuk-gutter-half;\n }\n\n .govuk-footer__meta-item--grow {\n flex: 1; // Support: Flexbox\n @include govuk-media-query($until: tablet) {\n flex-basis: 320px; // Support: Flexbox\n }\n }\n\n .govuk-footer__licence-logo {\n display: inline-block;\n margin-right: govuk-spacing(2);\n @include govuk-media-query($until: desktop) {\n margin-bottom: govuk-spacing(3);\n }\n vertical-align: top;\n // Work around SVGs not inheriting color from parent in forced color mode\n // (https://github.com/w3c/csswg-drafts/issues/6310)\n forced-color-adjust: auto;\n }\n\n .govuk-footer__licence-description {\n // This makes the license description reflow under the logo when space gets too narrow\n display: inline-block;\n // This prevents the description from having orphans when space is narrow enough\n // and makes the text reflow more nicely\n text-wrap: balance;\n }\n\n .govuk-footer__copyright-logo {\n display: inline-block;\n min-width: $govuk-footer-crest-image-width;\n padding-top: ($govuk-footer-crest-image-height + govuk-spacing(2));\n background-image: govuk-image-url(\"govuk-crest.svg\");\n background-repeat: no-repeat;\n background-position: 50% 0%;\n background-size: $govuk-footer-crest-image-width $govuk-footer-crest-image-height;\n text-align: center;\n white-space: nowrap;\n }\n\n .govuk-footer__inline-list {\n margin-top: 0;\n margin-bottom: govuk-spacing(3);\n padding: 0;\n }\n\n .govuk-footer__meta-custom {\n margin-bottom: govuk-spacing(4);\n }\n\n .govuk-footer__inline-list-item {\n display: inline-block;\n margin-right: govuk-spacing(3);\n margin-bottom: govuk-spacing(1);\n }\n\n .govuk-footer__heading {\n margin-bottom: govuk-spacing(6);\n padding-bottom: govuk-spacing(4);\n\n @include govuk-media-query($until: tablet) {\n padding-bottom: govuk-spacing(2);\n }\n border-bottom: 1px solid $govuk-footer-border;\n }\n\n .govuk-footer__navigation {\n @include govuk-clearfix;\n margin-right: -$govuk-gutter-half;\n margin-left: -$govuk-gutter-half;\n }\n\n .govuk-footer__section {\n display: inline-block;\n margin-bottom: $govuk-gutter;\n vertical-align: top;\n }\n\n .govuk-footer__list {\n margin: 0;\n padding: 0;\n list-style: none;\n column-gap: $govuk-gutter; // Support: Columns\n }\n\n @include govuk-media-query($from: desktop) {\n .govuk-footer__list--columns-2 {\n column-count: 2; // Support: Columns\n }\n\n .govuk-footer__list--columns-3 {\n column-count: 3; // Support: Columns\n }\n }\n\n .govuk-footer__list-item {\n @include govuk-responsive-margin(4, \"bottom\");\n }\n\n .govuk-footer__list-item:last-child {\n margin-bottom: 0;\n }\n}\n"]}
|
@@ -38,6 +38,14 @@
|
|
38
38
|
border-bottom: $govuk-header-border-width solid $govuk-header-border-color;
|
39
39
|
}
|
40
40
|
|
41
|
+
.govuk-header--full-width-border {
|
42
|
+
border-bottom-color: $govuk-header-border-color;
|
43
|
+
|
44
|
+
.govuk-header__container {
|
45
|
+
border-bottom-color: transparent;
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
41
49
|
.govuk-header__logotype {
|
42
50
|
display: inline-block;
|
43
51
|
position: relative;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/govuk/components/header/_index.scss"],"names":[],"mappings":"AAAA;EACE,+CAA+C;EAC/C,+CAA+C;EAC/C,4CAA4C;EAC5C,yCAAyC;EACzC,kCAAkC;EAClC,4CAA4C;EAC5C,2CAA2C;EAC3C,uCAAuC;EACvC,8EAA8E;EAC9E,kFAAkF;EAClF,gCAAgC;EAChC,sCAAsC;EACtC,qCAAqC;;EAErC;IACE,+CAA+C;;IAE/C,2DAA2D;IAC3D,yBAAyB;IACzB,oCAAoC;EACtC;;EAEA;IACE,2BAA2B;IAC3B,wCAAwC;;IAExC;MACE,uBAAuB;IACzB;EACF;;EAEA;IACE,uBAAuB;IACvB,kBAAkB;IAClB,0CAA0C;IAC1C,gEAAgE;IAChE,0EAA0E;EAC5E;;EAEA;IACE,qBAAqB;IACrB,kBAAkB;IAClB,SAAS;;IAET,wEAAwE;IACxE,sDAAsD;IACtD,8BAA8B;IAC9B,kBAAkB;IAClB,mBAAmB;;IAEnB,wEAAwE;IACxE,eAAe;IACf;MACE,yBAAyB;MACzB,eAAe;IACjB;;IA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BAA8B;IAC9B,kBAAkB;IAClB,0BAA0B;IAC1B,yEAAyE;IACzE,mCAAmC;IACnC,kEAAkE;IAClE,kDAAkD;IAClD;4CACwC;IACxC,QAAQ;IACR,0CAA0C;IAC1C,4CAA4C;IAC5C,SAAS;IACT,UAAU;IACV,SAAS;IACT,4BAA4B;IAC5B,gBAAgB;IAChB,qBAAqB;IACrB,eAAe;;IAEf;MACE,+EAAuE;cAAvE,uEAAuE;;MAEvE;QACE,mDAAmD;MACrD;IACF;;IAEA;MACE,2BAA2B;IAC7B;;IAEA;MACE,iFAAiF;MACjF,WAAW;MACX,6BAA6B;IAC/B;;IAEA;MACE,+EAA+E;IACjF;;IAEA;MACE,qBAAqB;IACvB;;IAEA;MACE,cAAc;IAChB;;IAEA;;MAEE,aAAa;IACf;EACF;;EAEA;IACE;MACE,+BAA+B;IACjC;EACF;;EAEA;IACE,sCAAsC;IACtC,SAAS;IACT,UAAU;IACV,gBAAgB;;IAEhB;MACE,aAAa;IACf;EACF;;EAEA;IACE;MACE,SAAS;MACT,2BAA2B;MAC3B,iBAAiB;IACnB;EACF;;EAEA;IACE,2BAA2B;IAC3B,4DAA4D;;IAE5D;MACE,qBAAqB;MACrB,8BAA8B;MAC9B,2BAA2B;MAC3B,SAAS;IACX;;IAEA;MACE,mCAAmC;MACnC,qCAAqC;MACrC,mBAAmB;IACrB;EACF;;EAEA;IACE;MACE;;;QAGE,gCAAgC;MAClC;;MAEA,sEAAsE;MACtE,uBAAuB;MACvB;QACE,0BAA0B;MAC5B;;MAEA,yEAAyE;MACzE,8BAA8B;MAC9B;QACE,+BAA+B;MACjC;IACF;EACF;;EAEA;IACE,eAAe;IACf,gBAAgB;EAClB;;EAEA;IACE;MACE,sBAAsB;MACtB,4BAA4B;MAC5B,uBAAuB;IACzB;;IAEA;MACE;;QAEE,4BAA4B;MAC9B;;MAEA,mEAAmE;MACnE;QACE,aAAa;MACf;IACF;EACF;AACF","file":"_index.scss","sourcesContent":["@include govuk-exports(\"govuk/component/header\") {\n $govuk-header-background: govuk-colour(\"black\");\n $govuk-header-border-color: $govuk-brand-colour;\n $govuk-header-border-width: govuk-spacing(2);\n $govuk-header-text: govuk-colour(\"white\");\n $govuk-header-link-active: #1d8feb;\n $govuk-header-nav-item-border-color: #2e3133;\n $govuk-header-link-underline-thickness: 3px;\n $govuk-header-vertical-spacing-value: 2;\n // This crown height is only used to calculate top offset of mobile menu button\n // as the crown svg height is the only thing that controls the height of the header\n $govuk-header-crown-height: 30px;\n $govuk-header-menu-button-height: 24px;\n $govuk-header-menu-button-width: 80px;\n\n .govuk-header {\n @include govuk-font($size: 16, $line-height: 1);\n\n border-bottom: govuk-spacing(2) solid govuk-colour(\"white\");\n color: $govuk-header-text;\n background: $govuk-header-background;\n }\n\n .govuk-header__container--full-width {\n padding: 0 govuk-spacing(3);\n border-color: $govuk-header-border-color;\n\n .govuk-header__menu-button {\n right: govuk-spacing(3);\n }\n }\n\n .govuk-header__container {\n @include govuk-clearfix;\n position: relative;\n margin-bottom: -$govuk-header-border-width;\n padding-top: govuk-spacing($govuk-header-vertical-spacing-value);\n border-bottom: $govuk-header-border-width solid $govuk-header-border-color;\n }\n\n .govuk-header__logotype {\n display: inline-block;\n position: relative;\n top: -3px;\n\n // Add a gap after the logo in case it's followed by a product name. This\n // gets removed later if the logotype is a :last-child.\n margin-right: govuk-spacing(1);\n fill: currentcolor;\n vertical-align: top;\n\n // Prevent readability backplate from obscuring underline in Windows High\n // Contrast Mode\n @media (forced-colors: active) {\n forced-color-adjust: none;\n color: linktext;\n }\n\n // Remove the gap after the logo if there's no product name to keep hover\n // and focus states neat\n &:last-child {\n margin-right: 0;\n }\n }\n\n .govuk-header__product-name {\n $product-name-offset: if($govuk-new-typography-scale, 7px, 10px);\n $product-name-offset-tablet: 5px;\n\n @include govuk-font-size($size: 24, $line-height: 1);\n @include govuk-typography-weight-regular;\n display: inline-table;\n\n // Maintain space below logo when wrapped\n margin-top: $product-name-offset;\n\n // Firefox places the GOV.UK logo one pixel higher, due to how it rounds\n // subpixels, so nudge the product name in FF to still be aligned.\n @-moz-document url-prefix() {\n margin-top: $product-name-offset - 0.5px;\n }\n\n // Align vertically with logo when not wrapped\n vertical-align: top;\n\n @include govuk-media-query($from: tablet) {\n margin-top: $product-name-offset-tablet;\n @-moz-document url-prefix() {\n margin-top: $product-name-offset-tablet - 0.5px;\n }\n }\n }\n\n .govuk-header__link {\n // Avoid using the `govuk-link-common` mixin because the links in the header\n // get a special treatment, because:\n //\n // - underlines are only visible on hover\n // - all links get a 3px underline regardless of text size, as there are\n // multiple grouped elements close to one another and having slightly\n // different underline widths looks unbalanced\n @include govuk-link-style-inverse;\n\n text-decoration: none;\n\n &:hover {\n text-decoration: underline;\n text-decoration-thickness: $govuk-header-link-underline-thickness;\n\n @if $govuk-link-underline-offset {\n text-underline-offset: $govuk-link-underline-offset;\n }\n }\n\n &:focus {\n @include govuk-focused-text;\n }\n }\n\n .govuk-header__link--homepage {\n // Font size needs to be set on the link so that the box sizing is correct\n // in Firefox\n display: inline-block;\n margin-right: govuk-spacing(2);\n font-size: 30px; // We don't have a mixin that produces 30px font size\n\n @include govuk-media-query($from: desktop) {\n display: inline;\n\n &:focus {\n // Replicate the focus box shadow but without the -2px y-offset of the first yellow shadow\n // This is to stop the logo getting cut off by the box shadow when focused on above a product name\n box-shadow: 0 0 $govuk-focus-colour;\n }\n }\n\n &:link,\n &:visited {\n text-decoration: none;\n }\n\n &:hover,\n &:active {\n // Negate the added border\n margin-bottom: $govuk-header-link-underline-thickness * -1;\n border-bottom: $govuk-header-link-underline-thickness solid;\n }\n\n // Remove any borders that show when focused and hovered.\n &:focus {\n margin-bottom: 0;\n border-bottom: 0;\n }\n }\n\n .govuk-header__service-name {\n display: inline-block;\n margin-bottom: govuk-spacing(2);\n @include govuk-font-size($size: 24);\n @include govuk-typography-weight-bold;\n }\n\n .govuk-header__logo,\n .govuk-header__content {\n box-sizing: border-box;\n }\n\n .govuk-header__logo {\n @include govuk-responsive-margin($govuk-header-vertical-spacing-value, \"bottom\");\n // Protect the absolute positioned menu button from overlapping with the\n // logo with right padding using the button's width\n padding-right: $govuk-header-menu-button-width;\n\n @include govuk-media-query($from: desktop) {\n width: 33.33%;\n padding-right: $govuk-gutter-half;\n float: left;\n vertical-align: top;\n\n // Reset float when logo is the last child, without a navigation\n &:last-child {\n width: auto;\n padding-right: 0;\n float: none;\n }\n }\n }\n\n .govuk-header__content {\n @include govuk-media-query($from: desktop) {\n width: 66.66%;\n padding-left: $govuk-gutter-half;\n float: left;\n }\n }\n\n .govuk-header__menu-button {\n @include govuk-font($size: 16);\n position: absolute;\n // calculate top offset by:\n // - getting the vertical spacing for the top and the bottom of the header\n // - adding that to the crown height\n // - dividing it by 2 so you have the vertical centre of the header\n // - subtracting half the height of the menu button\n top: (((govuk-spacing($govuk-header-vertical-spacing-value) * 2) + $govuk-header-crown-height) / 2) -\n ($govuk-header-menu-button-height / 2);\n right: 0;\n max-width: $govuk-header-menu-button-width;\n min-height: $govuk-header-menu-button-height;\n margin: 0;\n padding: 0;\n border: 0;\n color: govuk-colour(\"white\");\n background: none;\n word-break: break-all;\n cursor: pointer;\n\n &:hover {\n text-decoration: solid underline $govuk-header-link-underline-thickness;\n\n @if $govuk-link-underline-offset {\n text-underline-offset: $govuk-link-underline-offset;\n }\n }\n\n &:focus {\n @include govuk-focused-text;\n }\n\n &::after {\n @include govuk-shape-arrow($direction: down, $base: 10px, $display: inline-block);\n content: \"\";\n margin-left: govuk-spacing(1);\n }\n\n &[aria-expanded=\"true\"]::after {\n @include govuk-shape-arrow($direction: up, $base: 10px, $display: inline-block);\n }\n\n @include govuk-media-query($from: tablet) {\n top: govuk-spacing(3);\n }\n\n .govuk-frontend-supported & {\n display: block;\n }\n\n &[hidden],\n .govuk-frontend-supported &[hidden] {\n display: none;\n }\n }\n\n .govuk-header__navigation {\n @include govuk-media-query($from: desktop) {\n margin-bottom: govuk-spacing(2);\n }\n }\n\n .govuk-header__navigation-list {\n // Reset user-agent default list styles\n margin: 0;\n padding: 0;\n list-style: none;\n\n &[hidden] {\n display: none;\n }\n }\n\n .govuk-header__navigation--end {\n @include govuk-media-query($from: desktop) {\n margin: 0;\n padding: govuk-spacing(1) 0;\n text-align: right;\n }\n }\n\n .govuk-header__navigation-item {\n padding: govuk-spacing(2) 0;\n border-bottom: 1px solid $govuk-header-nav-item-border-color;\n\n @include govuk-media-query($from: desktop) {\n display: inline-block;\n margin-right: govuk-spacing(3);\n padding: govuk-spacing(1) 0;\n border: 0;\n }\n\n a {\n @include govuk-font-size($size: 16);\n @include govuk-typography-weight-bold;\n white-space: nowrap;\n }\n }\n\n .govuk-header__navigation-item--active {\n a {\n &:link,\n &:hover,\n &:visited {\n color: $govuk-header-link-active;\n }\n\n // When printing, use the normal blue as this contrasts better with the\n // white printing header\n @include govuk-media-query($media-type: print) {\n color: $govuk-brand-colour;\n }\n\n // When focussed, the text colour needs to be darker to ensure that colour\n // contrast is still acceptable\n &:focus {\n color: $govuk-focus-text-colour;\n }\n }\n }\n\n .govuk-header__navigation-item:last-child {\n margin-right: 0;\n border-bottom: 0;\n }\n\n @include govuk-media-query($media-type: print) {\n .govuk-header {\n border-bottom-width: 0;\n color: govuk-colour(\"black\");\n background: transparent;\n }\n\n .govuk-header__link {\n &:link,\n &:visited {\n color: govuk-colour(\"black\");\n }\n\n // Do not append link href to GOV.UK link when printing (e.g. '(/)')\n &::after {\n display: none;\n }\n }\n }\n}\n"]}
|
1
|
+
{"version":3,"sources":["../../../../src/govuk/components/header/_index.scss"],"names":[],"mappings":"AAAA;EACE,+CAA+C;EAC/C,+CAA+C;EAC/C,4CAA4C;EAC5C,yCAAyC;EACzC,kCAAkC;EAClC,4CAA4C;EAC5C,2CAA2C;EAC3C,uCAAuC;EACvC,8EAA8E;EAC9E,kFAAkF;EAClF,gCAAgC;EAChC,sCAAsC;EACtC,qCAAqC;;EAErC;IACE,+CAA+C;;IAE/C,2DAA2D;IAC3D,yBAAyB;IACzB,oCAAoC;EACtC;;EA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rB;EACF;;EAEA;IACE;MACE;;;QAGE,gCAAgC;MAClC;;MAEA,sEAAsE;MACtE,uBAAuB;MACvB;QACE,0BAA0B;MAC5B;;MAEA,yEAAyE;MACzE,8BAA8B;MAC9B;QACE,+BAA+B;MACjC;IACF;EACF;;EAEA;IACE,eAAe;IACf,gBAAgB;EAClB;;EAEA;IACE;MACE,sBAAsB;MACtB,4BAA4B;MAC5B,uBAAuB;IACzB;;IAEA;MACE;;QAEE,4BAA4B;MAC9B;;MAEA,mEAAmE;MACnE;QACE,aAAa;MACf;IACF;EACF;AACF","file":"_index.scss","sourcesContent":["@include govuk-exports(\"govuk/component/header\") {\n $govuk-header-background: govuk-colour(\"black\");\n $govuk-header-border-color: $govuk-brand-colour;\n $govuk-header-border-width: govuk-spacing(2);\n $govuk-header-text: govuk-colour(\"white\");\n $govuk-header-link-active: #1d8feb;\n $govuk-header-nav-item-border-color: #2e3133;\n $govuk-header-link-underline-thickness: 3px;\n $govuk-header-vertical-spacing-value: 2;\n // This crown height is only used to calculate top offset of mobile menu button\n // as the crown svg height is the only thing that controls the height of the header\n $govuk-header-crown-height: 30px;\n $govuk-header-menu-button-height: 24px;\n $govuk-header-menu-button-width: 80px;\n\n .govuk-header {\n @include govuk-font($size: 16, $line-height: 1);\n\n border-bottom: govuk-spacing(2) solid govuk-colour(\"white\");\n color: $govuk-header-text;\n background: $govuk-header-background;\n }\n\n .govuk-header__container--full-width {\n padding: 0 govuk-spacing(3);\n border-color: $govuk-header-border-color;\n\n .govuk-header__menu-button {\n right: govuk-spacing(3);\n }\n }\n\n .govuk-header__container {\n @include govuk-clearfix;\n position: relative;\n margin-bottom: -$govuk-header-border-width;\n padding-top: govuk-spacing($govuk-header-vertical-spacing-value);\n border-bottom: $govuk-header-border-width solid $govuk-header-border-color;\n }\n\n .govuk-header--full-width-border {\n border-bottom-color: $govuk-header-border-color;\n\n .govuk-header__container {\n border-bottom-color: transparent;\n }\n }\n\n .govuk-header__logotype {\n display: inline-block;\n position: relative;\n top: -3px;\n\n // Add a gap after the logo in case it's followed by a product name. This\n // gets removed later if the logotype is a :last-child.\n margin-right: govuk-spacing(1);\n fill: currentcolor;\n vertical-align: top;\n\n // Prevent readability backplate from obscuring underline in Windows High\n // Contrast Mode\n @media (forced-colors: active) {\n forced-color-adjust: none;\n color: linktext;\n }\n\n // Remove the gap after the logo if there's no product name to keep hover\n // and focus states neat\n &:last-child {\n margin-right: 0;\n }\n }\n\n .govuk-header__product-name {\n $product-name-offset: if($govuk-new-typography-scale, 7px, 10px);\n $product-name-offset-tablet: 5px;\n\n @include govuk-font-size($size: 24, $line-height: 1);\n @include govuk-typography-weight-regular;\n display: inline-table;\n\n // Maintain space below logo when wrapped\n margin-top: $product-name-offset;\n\n // Firefox places the GOV.UK logo one pixel higher, due to how it rounds\n // subpixels, so nudge the product name in FF to still be aligned.\n @-moz-document url-prefix() {\n margin-top: $product-name-offset - 0.5px;\n }\n\n // Align vertically with logo when not wrapped\n vertical-align: top;\n\n @include govuk-media-query($from: tablet) {\n margin-top: $product-name-offset-tablet;\n @-moz-document url-prefix() {\n margin-top: $product-name-offset-tablet - 0.5px;\n }\n }\n }\n\n .govuk-header__link {\n // Avoid using the `govuk-link-common` mixin because the links in the header\n // get a special treatment, because:\n //\n // - underlines are only visible on hover\n // - all links get a 3px underline regardless of text size, as there are\n // multiple grouped elements close to one another and having slightly\n // different underline widths looks unbalanced\n @include govuk-link-style-inverse;\n\n text-decoration: none;\n\n &:hover {\n text-decoration: underline;\n text-decoration-thickness: $govuk-header-link-underline-thickness;\n\n @if $govuk-link-underline-offset {\n text-underline-offset: $govuk-link-underline-offset;\n }\n }\n\n &:focus {\n @include govuk-focused-text;\n }\n }\n\n .govuk-header__link--homepage {\n // Font size needs to be set on the link so that the box sizing is correct\n // in Firefox\n display: inline-block;\n margin-right: govuk-spacing(2);\n font-size: 30px; // We don't have a mixin that produces 30px font size\n\n @include govuk-media-query($from: desktop) {\n display: inline;\n\n &:focus {\n // Replicate the focus box shadow but without the -2px y-offset of the first yellow shadow\n // This is to stop the logo getting cut off by the box shadow when focused on above a product name\n box-shadow: 0 0 $govuk-focus-colour;\n }\n }\n\n &:link,\n &:visited {\n text-decoration: none;\n }\n\n &:hover,\n &:active {\n // Negate the added border\n margin-bottom: $govuk-header-link-underline-thickness * -1;\n border-bottom: $govuk-header-link-underline-thickness solid;\n }\n\n // Remove any borders that show when focused and hovered.\n &:focus {\n margin-bottom: 0;\n border-bottom: 0;\n }\n }\n\n .govuk-header__service-name {\n display: inline-block;\n margin-bottom: govuk-spacing(2);\n @include govuk-font-size($size: 24);\n @include govuk-typography-weight-bold;\n }\n\n .govuk-header__logo,\n .govuk-header__content {\n box-sizing: border-box;\n }\n\n .govuk-header__logo {\n @include govuk-responsive-margin($govuk-header-vertical-spacing-value, \"bottom\");\n // Protect the absolute positioned menu button from overlapping with the\n // logo with right padding using the button's width\n padding-right: $govuk-header-menu-button-width;\n\n @include govuk-media-query($from: desktop) {\n width: 33.33%;\n padding-right: $govuk-gutter-half;\n float: left;\n vertical-align: top;\n\n // Reset float when logo is the last child, without a navigation\n &:last-child {\n width: auto;\n padding-right: 0;\n float: none;\n }\n }\n }\n\n .govuk-header__content {\n @include govuk-media-query($from: desktop) {\n width: 66.66%;\n padding-left: $govuk-gutter-half;\n float: left;\n }\n }\n\n .govuk-header__menu-button {\n @include govuk-font($size: 16);\n position: absolute;\n // calculate top offset by:\n // - getting the vertical spacing for the top and the bottom of the header\n // - adding that to the crown height\n // - dividing it by 2 so you have the vertical centre of the header\n // - subtracting half the height of the menu button\n top: (((govuk-spacing($govuk-header-vertical-spacing-value) * 2) + $govuk-header-crown-height) / 2) -\n ($govuk-header-menu-button-height / 2);\n right: 0;\n max-width: $govuk-header-menu-button-width;\n min-height: $govuk-header-menu-button-height;\n margin: 0;\n padding: 0;\n border: 0;\n color: govuk-colour(\"white\");\n background: none;\n word-break: break-all;\n cursor: pointer;\n\n &:hover {\n text-decoration: solid underline $govuk-header-link-underline-thickness;\n\n @if $govuk-link-underline-offset {\n text-underline-offset: $govuk-link-underline-offset;\n }\n }\n\n &:focus {\n @include govuk-focused-text;\n }\n\n &::after {\n @include govuk-shape-arrow($direction: down, $base: 10px, $display: inline-block);\n content: \"\";\n margin-left: govuk-spacing(1);\n }\n\n &[aria-expanded=\"true\"]::after {\n @include govuk-shape-arrow($direction: up, $base: 10px, $display: inline-block);\n }\n\n @include govuk-media-query($from: tablet) {\n top: govuk-spacing(3);\n }\n\n .govuk-frontend-supported & {\n display: block;\n }\n\n &[hidden],\n .govuk-frontend-supported &[hidden] {\n display: none;\n }\n }\n\n .govuk-header__navigation {\n @include govuk-media-query($from: desktop) {\n margin-bottom: govuk-spacing(2);\n }\n }\n\n .govuk-header__navigation-list {\n // Reset user-agent default list styles\n margin: 0;\n padding: 0;\n list-style: none;\n\n &[hidden] {\n display: none;\n }\n }\n\n .govuk-header__navigation--end {\n @include govuk-media-query($from: desktop) {\n margin: 0;\n padding: govuk-spacing(1) 0;\n text-align: right;\n }\n }\n\n .govuk-header__navigation-item {\n padding: govuk-spacing(2) 0;\n border-bottom: 1px solid $govuk-header-nav-item-border-color;\n\n @include govuk-media-query($from: desktop) {\n display: inline-block;\n margin-right: govuk-spacing(3);\n padding: govuk-spacing(1) 0;\n border: 0;\n }\n\n a {\n @include govuk-font-size($size: 16);\n @include govuk-typography-weight-bold;\n white-space: nowrap;\n }\n }\n\n .govuk-header__navigation-item--active {\n a {\n &:link,\n &:hover,\n &:visited {\n color: $govuk-header-link-active;\n }\n\n // When printing, use the normal blue as this contrasts better with the\n // white printing header\n @include govuk-media-query($media-type: print) {\n color: $govuk-brand-colour;\n }\n\n // When focussed, the text colour needs to be darker to ensure that colour\n // contrast is still acceptable\n &:focus {\n color: $govuk-focus-text-colour;\n }\n }\n }\n\n .govuk-header__navigation-item:last-child {\n margin-right: 0;\n border-bottom: 0;\n }\n\n @include govuk-media-query($media-type: print) {\n .govuk-header {\n border-bottom-width: 0;\n color: govuk-colour(\"black\");\n background: transparent;\n }\n\n .govuk-header__link {\n &:link,\n &:visited {\n color: govuk-colour(\"black\");\n }\n\n // Do not append link href to GOV.UK link when printing (e.g. '(/)')\n &::after {\n display: none;\n }\n }\n }\n}\n"]}
|
@@ -323,6 +323,18 @@
|
|
323
323
|
"screenshot": false,
|
324
324
|
"html": "<header class=\"govuk-header\" data-module=\"govuk-header\">\n <div class=\"govuk-header__container govuk-header__container--full-width\">\n <div class=\"govuk-header__logo\">\n <a href=\"/\" class=\"govuk-header__link govuk-header__link--homepage\">\n <svg\n focusable=\"false\"\n role=\"img\"\n class=\"govuk-header__logotype\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 148 30\"\n height=\"30\"\n width=\"148\"\n aria-label=\"GOV.UK\"\n >\n <title>GOV.UK</title>\n <path d=\"M22.6 10.4c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m-5.9 6.7c-.9.4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m10.8-3.7c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s0 2-1 2.4m3.3 4.8c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4M17 4.7l2.3 1.2V2.5l-2.3.7-.2-.2.9-3h-3.4l.9 3-.2.2c-.1.1-2.3-.7-2.3-.7v3.4L15 4.7c.1.1.1.2.2.2l-1.3 4c-.1.2-.1.4-.1.6 0 1.1.8 2 1.9 2.2h.7c1-.2 1.9-1.1 1.9-2.1 0-.2 0-.4-.1-.6l-1.3-4c-.1-.2 0-.2.1-.3m-7.6 5.7c.9.4 2-.1 2.4-1 .4-.9-.1-2-1-2.4-.9-.4-2 .1-2.4 1s0 2 1 2.4m-5 3c.9.4 2-.1 2.4-1 .4-.9-.1-2-1-2.4-.9-.4-2 .1-2.4 1s.1 2 1 2.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 1.1 1.7 1.4.6.3 1.4.5 2.4.5zM88.9 28 83 7h4.7l4 15.7h.1l4-15.7h4.7l-5.9 21h-5.7zm28.8-3.6c.6 0 1.2-.1 1.7-.3.5-.2 1-.4 1.4-.8.4-.4.7-.8.9-1.4.2-.6.3-1.2.3-2v-13h4.1v13.6c0 1.2-.2 2.2-.6 3.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L148 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z\"></path>\n </svg>\n <span class=\"govuk-header__product-name\">\n Product Name\n </span>\n </a>\n </div>\n <div class=\"govuk-header__content\">\n <nav aria-label=\"Menu\" class=\"govuk-header__navigation govuk-header__navigation--end\">\n <button type=\"button\" class=\"govuk-header__menu-button govuk-js-header-toggle\" aria-controls=\"navigation\" hidden>\n Menu\n </button>\n\n <ul id=\"navigation\" class=\"govuk-header__navigation-list\">\n <li class=\"govuk-header__navigation-item govuk-header__navigation-item--active\">\n <a class=\"govuk-header__link\" href=\"#1\">\n Navigation item 1\n </a>\n </li>\n <li class=\"govuk-header__navigation-item\">\n <a class=\"govuk-header__link\" href=\"#2\">\n Navigation item 2\n </a>\n </li>\n <li class=\"govuk-header__navigation-item\">\n <a class=\"govuk-header__link\" href=\"#3\">\n Navigation item 3\n </a>\n </li>\n </ul>\n </nav>\n </div>\n </div>\n</header>"
|
325
325
|
},
|
326
|
+
{
|
327
|
+
"name": "with full width border",
|
328
|
+
"options": {
|
329
|
+
"classes": "govuk-header--full-width-border",
|
330
|
+
"productName": "Product Name"
|
331
|
+
},
|
332
|
+
"hidden": false,
|
333
|
+
"description": "Makes the header's bottom border full width without affecting the header's content.",
|
334
|
+
"previewLayoutModifiers": [],
|
335
|
+
"screenshot": false,
|
336
|
+
"html": "<header class=\"govuk-header govuk-header--full-width-border\" data-module=\"govuk-header\">\n <div class=\"govuk-header__container govuk-width-container\">\n <div class=\"govuk-header__logo\">\n <a href=\"/\" class=\"govuk-header__link govuk-header__link--homepage\">\n <svg\n focusable=\"false\"\n role=\"img\"\n class=\"govuk-header__logotype\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 148 30\"\n height=\"30\"\n width=\"148\"\n aria-label=\"GOV.UK\"\n >\n <title>GOV.UK</title>\n <path d=\"M22.6 10.4c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m-5.9 6.7c-.9.4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4m10.8-3.7c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s0 2-1 2.4m3.3 4.8c-1 .4-2-.1-2.4-1-.4-.9.1-2 1-2.4.9-.4 2 .1 2.4 1s-.1 2-1 2.4M17 4.7l2.3 1.2V2.5l-2.3.7-.2-.2.9-3h-3.4l.9 3-.2.2c-.1.1-2.3-.7-2.3-.7v3.4L15 4.7c.1.1.1.2.2.2l-1.3 4c-.1.2-.1.4-.1.6 0 1.1.8 2 1.9 2.2h.7c1-.2 1.9-1.1 1.9-2.1 0-.2 0-.4-.1-.6l-1.3-4c-.1-.2 0-.2.1-.3m-7.6 5.7c.9.4 2-.1 2.4-1 .4-.9-.1-2-1-2.4-.9-.4-2 .1-2.4 1s0 2 1 2.4m-5 3c.9.4 2-.1 2.4-1 .4-.9-.1-2-1-2.4-.9-.4-2 .1-2.4 1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.2.5.6 1.1 1.1 1.7 1.4.6.3 1.4.5 2.4.5zM88.9 28 83 7h4.7l4 15.7h.1l4-15.7h4.7l-5.9 21h-5.7zm28.8-3.6c.6 0 1.2-.1 1.7-.3.5-.2 1-.4 1.4-.8.4-.4.7-.8.9-1.4.2-.6.3-1.2.3-2v-13h4.1v13.6c0 1.2-.2 2.2-.6 3.1s-1 1.7-1.8 2.4c-.7.7-1.6 1.2-2.7 1.5-1 .4-2.2.5-3.4.5-1.2 0-2.4-.2-3.4-.5-1-.4-1.9-.9-2.7-1.5-.8-.7-1.3-1.5-1.8-2.4-.4-.9-.6-2-.6-3.1V6.9h4.2v13c0 .8.1 1.4.3 2 .2.6.5 1 .9 1.4.4.4.8.6 1.4.8.6.2 1.1.3 1.8.3zm13-17.4h4.2v9.1l7.4-9.1h5.2l-7.2 8.4L148 28h-4.9l-5.5-9.4-2.7 3V28h-4.2V7zm-27.6 16.1c-1.5 0-2.7 1.2-2.7 2.7s1.2 2.7 2.7 2.7 2.7-1.2 2.7-2.7-1.2-2.7-2.7-2.7z\"></path>\n </svg>\n <span class=\"govuk-header__product-name\">\n Product Name\n </span>\n </a>\n </div>\n </div>\n</header>"
|
337
|
+
},
|
326
338
|
{
|
327
339
|
"name": "navigation item with html",
|
328
340
|
"options": {
|
@@ -12,12 +12,28 @@
|
|
12
12
|
value: value || undefined
|
13
13
|
};
|
14
14
|
}
|
15
|
+
function isInitialised($root, moduleName) {
|
16
|
+
return $root instanceof HTMLElement && $root.hasAttribute(`data-${moduleName}-init`);
|
17
|
+
}
|
18
|
+
|
19
|
+
/**
|
20
|
+
* Checks if GOV.UK Frontend is supported on this page
|
21
|
+
*
|
22
|
+
* Some browsers will load and run our JavaScript but GOV.UK Frontend
|
23
|
+
* won't be supported.
|
24
|
+
*
|
25
|
+
* @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support
|
26
|
+
* @returns {boolean} Whether GOV.UK Frontend is supported on this page
|
27
|
+
*/
|
15
28
|
function isSupported($scope = document.body) {
|
16
29
|
if (!$scope) {
|
17
30
|
return false;
|
18
31
|
}
|
19
32
|
return $scope.classList.contains('govuk-frontend-supported');
|
20
33
|
}
|
34
|
+
function formatErrorMessage(Component, message) {
|
35
|
+
return `${Component.moduleName}: ${message}`;
|
36
|
+
}
|
21
37
|
|
22
38
|
/**
|
23
39
|
* Schema for component config
|
@@ -41,6 +57,10 @@
|
|
41
57
|
* @property {string[]} required - List of required config fields
|
42
58
|
* @property {string} errorMessage - Error message when required config fields not provided
|
43
59
|
*/
|
60
|
+
/**
|
61
|
+
* @typedef ComponentWithModuleName
|
62
|
+
* @property {string} moduleName - Name of the component
|
63
|
+
*/
|
44
64
|
|
45
65
|
class GOVUKFrontendError extends Error {
|
46
66
|
constructor(...args) {
|
@@ -65,30 +85,85 @@
|
|
65
85
|
let message = typeof messageOrOptions === 'string' ? messageOrOptions : '';
|
66
86
|
if (typeof messageOrOptions === 'object') {
|
67
87
|
const {
|
68
|
-
|
88
|
+
component,
|
69
89
|
identifier,
|
70
90
|
element,
|
71
91
|
expectedType
|
72
92
|
} = messageOrOptions;
|
73
|
-
message =
|
93
|
+
message = identifier;
|
74
94
|
message += element ? ` is not of type ${expectedType != null ? expectedType : 'HTMLElement'}` : ' not found';
|
95
|
+
message = formatErrorMessage(component, message);
|
75
96
|
}
|
76
97
|
super(message);
|
77
98
|
this.name = 'ElementError';
|
78
99
|
}
|
79
100
|
}
|
101
|
+
class InitError extends GOVUKFrontendError {
|
102
|
+
constructor(componentOrMessage) {
|
103
|
+
const message = typeof componentOrMessage === 'string' ? componentOrMessage : formatErrorMessage(componentOrMessage, `Root element (\`$root\`) already initialised`);
|
104
|
+
super(message);
|
105
|
+
this.name = 'InitError';
|
106
|
+
}
|
107
|
+
}
|
108
|
+
/**
|
109
|
+
* @typedef {import('../common/index.mjs').ComponentWithModuleName} ComponentWithModuleName
|
110
|
+
*/
|
80
111
|
|
81
112
|
class GOVUKFrontendComponent {
|
82
|
-
|
83
|
-
|
113
|
+
/**
|
114
|
+
* Returns the root element of the component
|
115
|
+
*
|
116
|
+
* @protected
|
117
|
+
* @returns {RootElementType} - the root element of component
|
118
|
+
*/
|
119
|
+
get $root() {
|
120
|
+
return this._$root;
|
84
121
|
}
|
85
|
-
|
122
|
+
constructor($root) {
|
123
|
+
this._$root = void 0;
|
124
|
+
const childConstructor = this.constructor;
|
125
|
+
if (typeof childConstructor.moduleName !== 'string') {
|
126
|
+
throw new InitError(`\`moduleName\` not defined in component`);
|
127
|
+
}
|
128
|
+
if (!($root instanceof childConstructor.elementType)) {
|
129
|
+
throw new ElementError({
|
130
|
+
element: $root,
|
131
|
+
component: childConstructor,
|
132
|
+
identifier: 'Root element (`$root`)',
|
133
|
+
expectedType: childConstructor.elementType.name
|
134
|
+
});
|
135
|
+
} else {
|
136
|
+
this._$root = $root;
|
137
|
+
}
|
138
|
+
childConstructor.checkSupport();
|
139
|
+
this.checkInitialised();
|
140
|
+
const moduleName = childConstructor.moduleName;
|
141
|
+
this.$root.setAttribute(`data-${moduleName}-init`, '');
|
142
|
+
}
|
143
|
+
checkInitialised() {
|
144
|
+
const constructor = this.constructor;
|
145
|
+
const moduleName = constructor.moduleName;
|
146
|
+
if (moduleName && isInitialised(this.$root, moduleName)) {
|
147
|
+
throw new InitError(constructor);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
static checkSupport() {
|
86
151
|
if (!isSupported()) {
|
87
152
|
throw new SupportError();
|
88
153
|
}
|
89
154
|
}
|
90
155
|
}
|
91
156
|
|
157
|
+
/**
|
158
|
+
* @typedef ChildClass
|
159
|
+
* @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component
|
160
|
+
*/
|
161
|
+
|
162
|
+
/**
|
163
|
+
* @typedef {typeof GOVUKFrontendComponent & ChildClass} ChildClassConstructor
|
164
|
+
*/
|
165
|
+
GOVUKFrontendComponent.elementType = HTMLElement;
|
166
|
+
|
92
167
|
/**
|
93
168
|
* Header component
|
94
169
|
*
|
@@ -99,38 +174,29 @@
|
|
99
174
|
* Apply a matchMedia for desktop which will trigger a state sync if the
|
100
175
|
* browser viewport moves between states.
|
101
176
|
*
|
102
|
-
* @param {Element | null} $
|
177
|
+
* @param {Element | null} $root - HTML element to use for header
|
103
178
|
*/
|
104
|
-
constructor($
|
105
|
-
super();
|
106
|
-
this.$module = void 0;
|
179
|
+
constructor($root) {
|
180
|
+
super($root);
|
107
181
|
this.$menuButton = void 0;
|
108
182
|
this.$menu = void 0;
|
109
183
|
this.menuIsOpen = false;
|
110
184
|
this.mql = null;
|
111
|
-
|
112
|
-
throw new ElementError({
|
113
|
-
componentName: 'Header',
|
114
|
-
element: $module,
|
115
|
-
identifier: 'Root element (`$module`)'
|
116
|
-
});
|
117
|
-
}
|
118
|
-
this.$module = $module;
|
119
|
-
const $menuButton = $module.querySelector('.govuk-js-header-toggle');
|
185
|
+
const $menuButton = this.$root.querySelector('.govuk-js-header-toggle');
|
120
186
|
if (!$menuButton) {
|
121
187
|
return this;
|
122
188
|
}
|
123
189
|
const menuId = $menuButton.getAttribute('aria-controls');
|
124
190
|
if (!menuId) {
|
125
191
|
throw new ElementError({
|
126
|
-
|
192
|
+
component: Header,
|
127
193
|
identifier: 'Navigation button (`<button class="govuk-js-header-toggle">`) attribute (`aria-controls`)'
|
128
194
|
});
|
129
195
|
}
|
130
196
|
const $menu = document.getElementById(menuId);
|
131
197
|
if (!$menu) {
|
132
198
|
throw new ElementError({
|
133
|
-
|
199
|
+
component: Header,
|
134
200
|
element: $menu,
|
135
201
|
identifier: `Navigation (\`<ul id="${menuId}">\`)`
|
136
202
|
});
|
@@ -144,7 +210,7 @@
|
|
144
210
|
const breakpoint = getBreakpoint('desktop');
|
145
211
|
if (!breakpoint.value) {
|
146
212
|
throw new ElementError({
|
147
|
-
|
213
|
+
component: Header,
|
148
214
|
identifier: `CSS custom property (\`${breakpoint.property}\`) on pseudo-class \`:root\``
|
149
215
|
});
|
150
216
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"header.bundle.js","sources":["../../../../src/govuk/common/index.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/header/header.mjs"],"sourcesContent":["import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @internal\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n","/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @abstract\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { componentName, identifier, element, expectedType } =\n messageOrOptions\n\n // Add prefix and identifier\n message = `${componentName}: ${identifier}`\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n }\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} componentName - The name of the component throwing the error\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n */\n","import { isSupported } from './common/index.mjs'\nimport { SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @internal\n * @abstract\n */\nexport class GOVUKFrontendComponent {\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n */\n constructor() {\n this.checkSupport()\n }\n\n /**\n * Validates whether GOV.UK Frontend is supported\n *\n * @private\n * @throws {SupportError} when GOV.UK Frontend is not supported\n */\n checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n","import { getBreakpoint } from '../../common/index.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Header component\n *\n * @preserve\n */\nexport class Header extends GOVUKFrontendComponent {\n /** @private */\n $module\n\n /** @private */\n $menuButton\n\n /** @private */\n $menu\n\n /**\n * Save the opened/closed state for the nav in memory so that we can\n * accurately maintain state when the screen is changed from small to big and\n * back to small\n *\n * @private\n */\n menuIsOpen = false\n\n /**\n * A global const for storing a matchMedia instance which we'll use to detect\n * when a screen size change happens. We rely on it being null if the feature\n * isn't available to initially apply hidden attributes\n *\n * @private\n * @type {MediaQueryList | null}\n */\n mql = null\n\n /**\n * Apply a matchMedia for desktop which will trigger a state sync if the\n * browser viewport moves between states.\n *\n * @param {Element | null} $module - HTML element to use for header\n */\n constructor($module) {\n super()\n\n if (!$module) {\n throw new ElementError({\n componentName: 'Header',\n element: $module,\n identifier: 'Root element (`$module`)'\n })\n }\n\n this.$module = $module\n const $menuButton = $module.querySelector('.govuk-js-header-toggle')\n\n // Headers don't necessarily have a navigation. When they don't, the menu\n // toggle won't be rendered by our macro (or may be omitted when writing\n // plain HTML)\n if (!$menuButton) {\n return this\n }\n\n const menuId = $menuButton.getAttribute('aria-controls')\n if (!menuId) {\n throw new ElementError({\n componentName: 'Header',\n identifier:\n 'Navigation button (`<button class=\"govuk-js-header-toggle\">`) attribute (`aria-controls`)'\n })\n }\n\n const $menu = document.getElementById(menuId)\n if (!$menu) {\n throw new ElementError({\n componentName: 'Header',\n element: $menu,\n identifier: `Navigation (\\`<ul id=\"${menuId}\">\\`)`\n })\n }\n\n this.$menu = $menu\n this.$menuButton = $menuButton\n\n this.setupResponsiveChecks()\n\n this.$menuButton.addEventListener('click', () =>\n this.handleMenuButtonClick()\n )\n }\n\n /**\n * Setup viewport resize check\n *\n * @private\n */\n setupResponsiveChecks() {\n const breakpoint = getBreakpoint('desktop')\n\n if (!breakpoint.value) {\n throw new ElementError({\n componentName: 'Header',\n identifier: `CSS custom property (\\`${breakpoint.property}\\`) on pseudo-class \\`:root\\``\n })\n }\n\n // Media query list for GOV.UK Frontend desktop breakpoint\n this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)\n\n // MediaQueryList.addEventListener isn't supported by Safari < 14 so we need\n // to be able to fall back to the deprecated MediaQueryList.addListener\n if ('addEventListener' in this.mql) {\n this.mql.addEventListener('change', () => this.checkMode())\n } else {\n // @ts-expect-error Property 'addListener' does not exist\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.mql.addListener(() => this.checkMode())\n }\n\n this.checkMode()\n }\n\n /**\n * Sync menu state\n *\n * Uses the global variable menuIsOpen to correctly set the accessible and\n * visual states of the menu and the menu button.\n * Additionally will force the menu to be visible and the menu button to be\n * hidden if the matchMedia is triggered to desktop.\n *\n * @private\n */\n checkMode() {\n if (!this.mql || !this.$menu || !this.$menuButton) {\n return\n }\n\n if (this.mql.matches) {\n this.$menu.removeAttribute('hidden')\n this.$menuButton.setAttribute('hidden', '')\n } else {\n this.$menuButton.removeAttribute('hidden')\n this.$menuButton.setAttribute('aria-expanded', this.menuIsOpen.toString())\n\n if (this.menuIsOpen) {\n this.$menu.removeAttribute('hidden')\n } else {\n this.$menu.setAttribute('hidden', '')\n }\n }\n }\n\n /**\n * Handle menu button click\n *\n * When the menu button is clicked, change the visibility of the menu and then\n * sync the accessibility state and menu button state\n *\n * @private\n */\n handleMenuButtonClick() {\n this.menuIsOpen = !this.menuIsOpen\n this.checkMode()\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-header'\n}\n"],"names":["getBreakpoint","name","property","value","window","getComputedStyle","document","documentElement","getPropertyValue","undefined","isSupported","$scope","body","classList","contains","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","message","componentName","identifier","element","expectedType","GOVUKFrontendComponent","checkSupport","Header","$module","$menuButton","$menu","menuIsOpen","mql","querySelector","menuId","getAttribute","getElementById","setupResponsiveChecks","addEventListener","handleMenuButtonClick","breakpoint","matchMedia","checkMode","addListener","matches","removeAttribute","setAttribute","toString","moduleName"],"mappings":";;;;;;EAkIO,SAASA,aAAaA,CAACC,IAAI,EAAE;EAClC,EAAA,MAAMC,QAAQ,GAAG,CAA+BD,4BAAAA,EAAAA,IAAI,CAAE,CAAA,CAAA;EAGtD,EAAA,MAAME,KAAK,GAAGC,MAAM,CAC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CAACgB,QAAQ,EAAE,CAAC,CAAA;QAE1E,IAAI,IAAI,CAAChB,UAAU,EAAE;EACnB,QAAA,IAAI,CAACD,KAAK,CAACe,eAAe,CAAC,QAAQ,CAAC,CAAA;EACtC,OAAC,MAAM;UACL,IAAI,CAACf,KAAK,CAACgB,YAAY,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAA;EACvC,OAAA;EACF,KAAA;EACF,GAAA;EAUAP,EAAAA,qBAAqBA,GAAG;EACtB,IAAA,IAAI,CAACR,UAAU,GAAG,CAAC,IAAI,CAACA,UAAU,CAAA;MAClC,IAAI,CAACW,SAAS,EAAE,CAAA;EAClB,GAAA;EAMF,CAAA;EAlKaf,MAAM,CAiKVqB,UAAU,GAAG,cAAc;;;;;;;;"}
|
1
|
+
{"version":3,"file":"header.bundle.js","sources":["../../../../src/govuk/common/index.mjs","../../../../src/govuk/errors/index.mjs","../../../../src/govuk/govuk-frontend-component.mjs","../../../../src/govuk/components/header/header.mjs"],"sourcesContent":["import { normaliseString } from './normalise-string.mjs'\n\n/**\n * Common helpers which do not require polyfill.\n *\n * IMPORTANT: If a helper require a polyfill, please isolate it in its own module\n * so that the polyfill can be properly tree-shaken and does not burden\n * the components that do not need that helper\n */\n\n/**\n * Config merging function\n *\n * Takes any number of objects and combines them together, with\n * greatest priority on the LAST item passed in.\n *\n * @internal\n * @param {...{ [key: string]: unknown }} configObjects - Config objects to merge\n * @returns {{ [key: string]: unknown }} A merged config object\n */\nexport function mergeConfigs(...configObjects) {\n // Start with an empty object as our base\n /** @type {{ [key: string]: unknown }} */\n const formattedConfigObject = {}\n\n // Loop through each of the passed objects\n for (const configObject of configObjects) {\n for (const key of Object.keys(configObject)) {\n const option = formattedConfigObject[key]\n const override = configObject[key]\n\n // Push their keys one-by-one into formattedConfigObject. Any duplicate\n // keys with object values will be merged, otherwise the new value will\n // override the existing value.\n if (isObject(option) && isObject(override)) {\n // @ts-expect-error Index signature for type 'string' is missing\n formattedConfigObject[key] = mergeConfigs(option, override)\n } else {\n // Apply override\n formattedConfigObject[key] = override\n }\n }\n }\n\n return formattedConfigObject\n}\n\n/**\n * Extracts keys starting with a particular namespace from dataset ('data-*')\n * object, removing the namespace in the process, normalising all values\n *\n * @internal\n * @param {{ schema: Schema }} Component - Component class\n * @param {DOMStringMap} dataset - The object to extract key-value pairs from\n * @param {string} namespace - The namespace to filter keys with\n * @returns {ObjectNested | undefined} Nested object with dot-separated key namespace removed\n */\nexport function extractConfigByNamespace(Component, dataset, namespace) {\n const property = Component.schema.properties[namespace]\n\n // Only extract configs for object schema properties\n if (property?.type !== 'object') {\n return\n }\n\n // Add default empty config\n const newObject = {\n [namespace]: /** @type {ObjectNested} */ ({})\n }\n\n for (const [key, value] of Object.entries(dataset)) {\n /** @type {ObjectNested | ObjectNested[NestedKey]} */\n let current = newObject\n\n // Split the key into parts, using . as our namespace separator\n const keyParts = key.split('.')\n\n /**\n * Create new level per part\n *\n * e.g. 'i18n.textareaDescription.other' becomes\n * `{ i18n: { textareaDescription: { other } } }`\n */\n for (const [index, name] of keyParts.entries()) {\n if (typeof current === 'object') {\n // Drop down to nested object until the last part\n if (index < keyParts.length - 1) {\n // New nested object (optionally) replaces existing value\n if (!isObject(current[name])) {\n current[name] = {}\n }\n\n // Drop down into new or existing nested object\n current = current[name]\n } else if (key !== namespace) {\n // Normalised value (optionally) replaces existing value\n current[name] = normaliseString(value)\n }\n }\n }\n }\n\n return newObject[namespace]\n}\n\n/**\n * Get hash fragment from URL\n *\n * Extract the hash fragment (everything after the hash) from a URL,\n * but not including the hash symbol\n *\n * @private\n * @param {string} url - URL\n * @returns {string | undefined} Fragment from URL, without the hash\n */\nexport function getFragmentFromUrl(url) {\n if (!url.includes('#')) {\n return undefined\n }\n\n return url.split('#').pop()\n}\n\n/**\n * Get GOV.UK Frontend breakpoint value from CSS custom property\n *\n * @private\n * @param {string} name - Breakpoint name\n * @returns {{ property: string, value?: string }} Breakpoint object\n */\nexport function getBreakpoint(name) {\n const property = `--govuk-frontend-breakpoint-${name}`\n\n // Get value from `<html>` with breakpoints on CSS :root\n const value = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(property)\n\n return {\n property,\n value: value || undefined\n }\n}\n\n/**\n * Move focus to element\n *\n * Sets tabindex to -1 to make the element programmatically focusable,\n * but removes it on blur as the element doesn't need to be focused again.\n *\n * @private\n * @template {HTMLElement} FocusElement\n * @param {FocusElement} $element - HTML element\n * @param {object} [options] - Handler options\n * @param {function(this: FocusElement): void} [options.onBeforeFocus] - Callback before focus\n * @param {function(this: FocusElement): void} [options.onBlur] - Callback on blur\n */\nexport function setFocus($element, options = {}) {\n const isFocusable = $element.getAttribute('tabindex')\n\n if (!isFocusable) {\n $element.setAttribute('tabindex', '-1')\n }\n\n /**\n * Handle element focus\n */\n function onFocus() {\n $element.addEventListener('blur', onBlur, { once: true })\n }\n\n /**\n * Handle element blur\n */\n function onBlur() {\n options.onBlur?.call($element)\n\n if (!isFocusable) {\n $element.removeAttribute('tabindex')\n }\n }\n\n // Add listener to reset element on blur, after focus\n $element.addEventListener('focus', onFocus, { once: true })\n\n // Focus element\n options.onBeforeFocus?.call($element)\n $element.focus()\n}\n\n/**\n * Checks if component is already initialised\n *\n * @internal\n * @param {Element} $root - HTML element to be checked\n * @param {string} moduleName - name of component module\n * @returns {boolean} Whether component is already initialised\n */\nexport function isInitialised($root, moduleName) {\n return (\n $root instanceof HTMLElement &&\n $root.hasAttribute(`data-${moduleName}-init`)\n )\n}\n\n/**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * Some browsers will load and run our JavaScript but GOV.UK Frontend\n * won't be supported.\n *\n * @param {HTMLElement | null} [$scope] - (internal) `<body>` HTML element checked for browser support\n * @returns {boolean} Whether GOV.UK Frontend is supported on this page\n */\nexport function isSupported($scope = document.body) {\n if (!$scope) {\n return false\n }\n\n return $scope.classList.contains('govuk-frontend-supported')\n}\n\n/**\n * Validate component config by schema\n *\n * Follows limited examples in JSON schema for wider support in future\n *\n * {@link https://ajv.js.org/json-schema.html#compound-keywords}\n * {@link https://ajv.js.org/packages/ajv-errors.html#single-message}\n *\n * @internal\n * @param {Schema} schema - Config schema\n * @param {{ [key: string]: unknown }} config - Component config\n * @returns {string[]} List of validation errors\n */\nexport function validateConfig(schema, config) {\n const validationErrors = []\n\n // Check errors for each schema\n for (const [name, conditions] of Object.entries(schema)) {\n const errors = []\n\n // Check errors for each schema condition\n if (Array.isArray(conditions)) {\n for (const { required, errorMessage } of conditions) {\n if (!required.every((key) => !!config[key])) {\n errors.push(errorMessage) // Missing config key value\n }\n }\n\n // Check one condition passes or add errors\n if (name === 'anyOf' && !(conditions.length - errors.length >= 1)) {\n validationErrors.push(...errors)\n }\n }\n }\n\n return validationErrors\n}\n\n/**\n * Check for an array\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an array\n */\nfunction isArray(option) {\n return Array.isArray(option)\n}\n\n/**\n * Check for an object\n *\n * @internal\n * @param {unknown} option - Option to check\n * @returns {boolean} Whether the option is an object\n */\nfunction isObject(option) {\n return !!option && typeof option === 'object' && !isArray(option)\n}\n\n/**\n * Format error message\n *\n * @internal\n * @param {ComponentWithModuleName} Component - Component that threw the error\n * @param {string} message - Error message\n * @returns {string} - Formatted error message\n */\nexport function formatErrorMessage(Component, message) {\n return `${Component.moduleName}: ${message}`\n}\n\n/**\n * Schema for component config\n *\n * @typedef {object} Schema\n * @property {{ [field: string]: SchemaProperty | undefined }} properties - Schema properties\n * @property {SchemaCondition[]} [anyOf] - List of schema conditions\n */\n\n/**\n * Schema property for component config\n *\n * @typedef {object} SchemaProperty\n * @property {'string' | 'boolean' | 'number' | 'object'} type - Property type\n */\n\n/**\n * Schema condition for component config\n *\n * @typedef {object} SchemaCondition\n * @property {string[]} required - List of required config fields\n * @property {string} errorMessage - Error message when required config fields not provided\n */\n\n/**\n * @internal\n * @typedef {keyof ObjectNested} NestedKey\n * @typedef {{ [key: string]: string | boolean | number | ObjectNested | undefined }} ObjectNested\n */\n\n/* eslint-disable jsdoc/valid-types --\n * `{new(...args: any[] ): object}` is not recognised as valid\n * https://github.com/gajus/eslint-plugin-jsdoc/issues/145#issuecomment-1308722878\n * https://github.com/jsdoc-type-pratt-parser/jsdoc-type-pratt-parser/issues/131\n **/\n\n/**\n * @typedef ComponentWithModuleName\n * @property {string} moduleName - Name of the component\n */\n\n/* eslint-enable jsdoc/valid-types */\n","import { formatErrorMessage } from '../common/index.mjs'\n\n/**\n * GOV.UK Frontend error\n *\n * A base class for `Error`s thrown by GOV.UK Frontend.\n *\n * It is meant to be extended into specific types of errors\n * to be thrown by our code.\n *\n * @example\n * ```js\n * class MissingRootError extends GOVUKFrontendError {\n * // Setting an explicit name is important as extending the class will not\n * // set a new `name` on the subclass. The `name` property is important\n * // to ensure intelligible error names even if the class name gets\n * // mangled by a minifier\n * name = \"MissingRootError\"\n * }\n * ```\n * @virtual\n */\nexport class GOVUKFrontendError extends Error {\n name = 'GOVUKFrontendError'\n}\n\n/**\n * Indicates that GOV.UK Frontend is not supported\n */\nexport class SupportError extends GOVUKFrontendError {\n name = 'SupportError'\n\n /**\n * Checks if GOV.UK Frontend is supported on this page\n *\n * @param {HTMLElement | null} [$scope] - HTML element `<body>` checked for browser support\n */\n constructor($scope = document.body) {\n const supportMessage =\n 'noModule' in HTMLScriptElement.prototype\n ? 'GOV.UK Frontend initialised without `<body class=\"govuk-frontend-supported\">` from template `<script>` snippet'\n : 'GOV.UK Frontend is not supported in this browser'\n\n super(\n $scope\n ? supportMessage\n : 'GOV.UK Frontend initialised without `<script type=\"module\">`'\n )\n }\n}\n\n/**\n * Indicates that a component has received an illegal configuration\n */\nexport class ConfigError extends GOVUKFrontendError {\n name = 'ConfigError'\n}\n\n/**\n * Indicates an issue with an element (possibly `null` or `undefined`)\n */\nexport class ElementError extends GOVUKFrontendError {\n name = 'ElementError'\n\n /**\n * @internal\n * @overload\n * @param {string} message - Element error message\n */\n\n /**\n * @internal\n * @overload\n * @param {ElementErrorOptions} options - Element error options\n */\n\n /**\n * @internal\n * @param {string | ElementErrorOptions} messageOrOptions - Element error message or options\n */\n constructor(messageOrOptions) {\n let message = typeof messageOrOptions === 'string' ? messageOrOptions : ''\n\n // Build message from options\n if (typeof messageOrOptions === 'object') {\n const { component, identifier, element, expectedType } = messageOrOptions\n\n message = identifier\n\n // Append reason\n message += element\n ? ` is not of type ${expectedType ?? 'HTMLElement'}`\n : ' not found'\n\n message = formatErrorMessage(component, message)\n }\n\n super(message)\n }\n}\n\n/**\n * Indicates that a component is already initialised\n */\nexport class InitError extends GOVUKFrontendError {\n name = 'InitError'\n\n /**\n * @internal\n * @param {ComponentWithModuleName | string} componentOrMessage - name of the component module\n */\n constructor(componentOrMessage) {\n const message =\n typeof componentOrMessage === 'string'\n ? componentOrMessage\n : formatErrorMessage(\n componentOrMessage,\n `Root element (\\`$root\\`) already initialised`\n )\n\n super(message)\n }\n}\n\n/**\n * Element error options\n *\n * @internal\n * @typedef {object} ElementErrorOptions\n * @property {string} identifier - An identifier that'll let the user understand which element has an error. This is whatever makes the most sense\n * @property {Element | null} [element] - The element in error\n * @property {string} [expectedType] - The type that was expected for the identifier\n * @property {ComponentWithModuleName} component - Component throwing the error\n */\n\n/**\n * @typedef {import('../common/index.mjs').ComponentWithModuleName} ComponentWithModuleName\n */\n","import { isInitialised, isSupported } from './common/index.mjs'\nimport { ElementError, InitError, SupportError } from './errors/index.mjs'\n\n/**\n * Base Component class\n *\n * Centralises the behaviours shared by our components\n *\n * @virtual\n * @template {Element} [RootElementType=HTMLElement]\n */\nexport class GOVUKFrontendComponent {\n /**\n * @type {typeof Element}\n */\n static elementType = HTMLElement\n\n // allows Typescript user to work around the lack of types\n // in GOVUKFrontend package, Typescript is not aware of $root\n // in components that extend GOVUKFrontendComponent\n /**\n * Returns the root element of the component\n *\n * @protected\n * @returns {RootElementType} - the root element of component\n */\n get $root() {\n return this._$root\n }\n\n /**\n * @protected\n * @type {RootElementType}\n */\n _$root\n\n /**\n * Constructs a new component, validating that GOV.UK Frontend is supported\n *\n * @internal\n * @param {Element | null} [$root] - HTML element to use for component\n */\n constructor($root) {\n const childConstructor = /** @type {ChildClassConstructor} */ (\n this.constructor\n )\n\n // TypeScript does not enforce that inheriting classes will define a `moduleName`\n // (even if we add a `@virtual` `static moduleName` property to this class).\n // While we trust users to do this correctly, we do a little check to provide them\n // a helpful error message.\n //\n // After this, we'll be sure that `childConstructor` has a `moduleName`\n // as expected of the `ChildClassConstructor` we've cast `this.constructor` to.\n if (typeof childConstructor.moduleName !== 'string') {\n throw new InitError(`\\`moduleName\\` not defined in component`)\n }\n\n if (!($root instanceof childConstructor.elementType)) {\n throw new ElementError({\n element: $root,\n component: childConstructor,\n identifier: 'Root element (`$root`)',\n expectedType: childConstructor.elementType.name\n })\n } else {\n this._$root = /** @type {RootElementType} */ ($root)\n }\n\n childConstructor.checkSupport()\n\n this.checkInitialised()\n\n const moduleName = childConstructor.moduleName\n\n this.$root.setAttribute(`data-${moduleName}-init`, '')\n }\n\n /**\n * Validates whether component is already initialised\n *\n * @private\n * @throws {InitError} when component is already initialised\n */\n checkInitialised() {\n const constructor = /** @type {ChildClassConstructor} */ (this.constructor)\n const moduleName = constructor.moduleName\n\n if (moduleName && isInitialised(this.$root, moduleName)) {\n throw new InitError(constructor)\n }\n }\n\n /**\n * Validates whether components are supported\n *\n * @throws {SupportError} when the components are not supported\n */\n static checkSupport() {\n if (!isSupported()) {\n throw new SupportError()\n }\n }\n}\n\n/**\n * @typedef ChildClass\n * @property {string} moduleName - The module name that'll be looked for in the DOM when initialising the component\n */\n\n/**\n * @typedef {typeof GOVUKFrontendComponent & ChildClass} ChildClassConstructor\n */\n","import { getBreakpoint } from '../../common/index.mjs'\nimport { ElementError } from '../../errors/index.mjs'\nimport { GOVUKFrontendComponent } from '../../govuk-frontend-component.mjs'\n\n/**\n * Header component\n *\n * @preserve\n */\nexport class Header extends GOVUKFrontendComponent {\n /** @private */\n $menuButton\n\n /** @private */\n $menu\n\n /**\n * Save the opened/closed state for the nav in memory so that we can\n * accurately maintain state when the screen is changed from small to big and\n * back to small\n *\n * @private\n */\n menuIsOpen = false\n\n /**\n * A global const for storing a matchMedia instance which we'll use to detect\n * when a screen size change happens. We rely on it being null if the feature\n * isn't available to initially apply hidden attributes\n *\n * @private\n * @type {MediaQueryList | null}\n */\n mql = null\n\n /**\n * Apply a matchMedia for desktop which will trigger a state sync if the\n * browser viewport moves between states.\n *\n * @param {Element | null} $root - HTML element to use for header\n */\n constructor($root) {\n super($root)\n\n const $menuButton = this.$root.querySelector('.govuk-js-header-toggle')\n\n // Headers don't necessarily have a navigation. When they don't, the menu\n // toggle won't be rendered by our macro (or may be omitted when writing\n // plain HTML)\n if (!$menuButton) {\n return this\n }\n\n const menuId = $menuButton.getAttribute('aria-controls')\n if (!menuId) {\n throw new ElementError({\n component: Header,\n identifier:\n 'Navigation button (`<button class=\"govuk-js-header-toggle\">`) attribute (`aria-controls`)'\n })\n }\n\n const $menu = document.getElementById(menuId)\n if (!$menu) {\n throw new ElementError({\n component: Header,\n element: $menu,\n identifier: `Navigation (\\`<ul id=\"${menuId}\">\\`)`\n })\n }\n\n this.$menu = $menu\n this.$menuButton = $menuButton\n\n this.setupResponsiveChecks()\n\n this.$menuButton.addEventListener('click', () =>\n this.handleMenuButtonClick()\n )\n }\n\n /**\n * Setup viewport resize check\n *\n * @private\n */\n setupResponsiveChecks() {\n const breakpoint = getBreakpoint('desktop')\n\n if (!breakpoint.value) {\n throw new ElementError({\n component: Header,\n identifier: `CSS custom property (\\`${breakpoint.property}\\`) on pseudo-class \\`:root\\``\n })\n }\n\n // Media query list for GOV.UK Frontend desktop breakpoint\n this.mql = window.matchMedia(`(min-width: ${breakpoint.value})`)\n\n // MediaQueryList.addEventListener isn't supported by Safari < 14 so we need\n // to be able to fall back to the deprecated MediaQueryList.addListener\n if ('addEventListener' in this.mql) {\n this.mql.addEventListener('change', () => this.checkMode())\n } else {\n // @ts-expect-error Property 'addListener' does not exist\n // eslint-disable-next-line @typescript-eslint/no-unsafe-call\n this.mql.addListener(() => this.checkMode())\n }\n\n this.checkMode()\n }\n\n /**\n * Sync menu state\n *\n * Uses the global variable menuIsOpen to correctly set the accessible and\n * visual states of the menu and the menu button.\n * Additionally will force the menu to be visible and the menu button to be\n * hidden if the matchMedia is triggered to desktop.\n *\n * @private\n */\n checkMode() {\n if (!this.mql || !this.$menu || !this.$menuButton) {\n return\n }\n\n if (this.mql.matches) {\n this.$menu.removeAttribute('hidden')\n this.$menuButton.setAttribute('hidden', '')\n } else {\n this.$menuButton.removeAttribute('hidden')\n this.$menuButton.setAttribute('aria-expanded', this.menuIsOpen.toString())\n\n if (this.menuIsOpen) {\n this.$menu.removeAttribute('hidden')\n } else {\n this.$menu.setAttribute('hidden', '')\n }\n }\n }\n\n /**\n * Handle menu button click\n *\n * When the menu button is clicked, change the visibility of the menu and then\n * sync the accessibility state and menu button state\n *\n * @private\n */\n handleMenuButtonClick() {\n this.menuIsOpen = !this.menuIsOpen\n this.checkMode()\n }\n\n /**\n * Name for the component used when initialising using data-module attributes.\n */\n static moduleName = 'govuk-header'\n}\n"],"names":["getBreakpoint","name","property","value","window","getComputedStyle","document","documentElement","getPropertyValue","undefined","isInitialised","$root","moduleName","HTMLElement","hasAttribute","isSupported","$scope","body","classList","contains","formatErrorMessage","Component","message","GOVUKFrontendError","Error","constructor","args","SupportError","supportMessage","HTMLScriptElement","prototype","ElementError","messageOrOptions","component","identifier","element","expectedType","InitError","componentOrMessage","GOVUKFrontendComponent","_$root","childConstructor","elementType","checkSupport","checkInitialised","setAttribute","Header","$menuButton","$menu","menuIsOpen","mql","querySelector","menuId","getAttribute","getElementById","setupResponsiveChecks","addEventListener","handleMenuButtonClick","breakpoint","matchMedia","checkMode","addListener","matches","removeAttribute","toString"],"mappings":";;;;;;EAkIO,SAASA,aAAaA,CAACC,IAAI,EAAE;EAClC,EAAA,MAAMC,QAAQ,GAAG,CAA+BD,4BAAAA,EAAAA,IAAI,CAAE,CAAA,CAAA;EAGtD,EAAA,M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