Skip to content

Commit

Permalink
Merge pull request #2976 from alphagov/v5-supported-check
Browse files Browse the repository at this point in the history
Preview v5: Skip initialisation when GOV.UK Frontend is not supported
  • Loading branch information
colinrotherham authored Aug 1, 2023
2 parents 4b8f25a + f5f35e4 commit 01bf8df
Show file tree
Hide file tree
Showing 13 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/javascripts/components/back-to-top.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class BackToTop {
* @param {Element} $module - HTML element
*/
constructor ($module) {
if (!($module instanceof HTMLElement)) {
if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) {
return this
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/cookie-banner.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CookieBanner {
* @param {Element} $module - HTML element
*/
constructor ($module) {
if (!($module instanceof HTMLElement)) {
if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) {
return this
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/cookies-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class CookiesPage {
* @param {Element} $module - HTML element
*/
constructor ($module) {
if (!($module instanceof HTMLElement)) {
if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) {
return this
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/copy.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Copy {
* @param {Element} $module - HTML element
*/
constructor ($module) {
if (!($module instanceof HTMLElement)) {
if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) {
return this
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/example-page.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class ExamplePage {
* @param {Document} $module - HTML document
*/
constructor ($module) {
if (!($module instanceof Document)) {
if (!($module instanceof Document) || !document.body.classList.contains('govuk-frontend-supported')) {
return this
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Example {
* @param {Element} $module - HTML element
*/
constructor ($module) {
if (!($module instanceof HTMLIFrameElement)) {
if (!($module instanceof HTMLIFrameElement) || !document.body.classList.contains('govuk-frontend-supported')) {
return
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/navigation.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Navigation {
* @param {Document} $module - HTML document
*/
constructor ($module) {
if (!($module instanceof Document)) {
if (!($module instanceof Document) || !document.body.classList.contains('govuk-frontend-supported')) {
return this
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/search.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Search {
* @param {Element} $module - HTML element
*/
constructor ($module) {
if (!($module instanceof HTMLElement)) {
if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) {
return this
}

Expand Down
2 changes: 1 addition & 1 deletion src/javascripts/components/tabs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class AppTabs {
* @param {Element} $module - HTML element
*/
constructor ($module) {
if (!($module instanceof HTMLElement)) {
if (!($module instanceof HTMLElement) || !document.body.classList.contains('govuk-frontend-supported')) {
return this
}

Expand Down
4 changes: 2 additions & 2 deletions src/stylesheets/components/_back-to-top.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
margin-bottom: govuk-spacing(8);
}

.js-enabled .app-back-to-top--fixed {
.govuk-frontend-supported .app-back-to-top--fixed {
position: fixed;
top: calc(100% - #{govuk-spacing(8)});
bottom: auto;
left: auto;
}

.js-enabled .app-back-to-top--hidden .app-back-to-top__link {
.govuk-frontend-supported .app-back-to-top--hidden .app-back-to-top__link {
@include govuk-visually-hidden-focusable;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/stylesheets/components/_navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@
list-style: none;
}

.js-enabled .app-navigation__subnav--active {
.govuk-frontend-supported .app-navigation__subnav--active {
display: block;
}

.app-navigation__subnav,
.js-enabled .app-navigation__subnav--active {
.govuk-frontend-supported .app-navigation__subnav--active {
@include govuk-media-query($from: tablet) {
display: none;
}
Expand Down
6 changes: 3 additions & 3 deletions src/stylesheets/components/_site-search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $icon-size: 40px;
margin-bottom: govuk-spacing(2);
float: left;

.js-enabled & {
.govuk-frontend-supported & {
display: block;
}

Expand All @@ -37,7 +37,7 @@ $icon-size: 40px;
float: right;
text-align: right;

.js-enabled & {
.govuk-frontend-supported & {
text-align: left;
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ $icon-size: 40px;
@include govuk-media-query($from: tablet) {
display: inline-block;

.js-enabled & {
.govuk-frontend-supported & {
display: none;
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ pre code {
outline: $govuk-focus-width solid $govuk-focus-colour;
}

.js-enabled [data-module="app-copy"] & {
.govuk-frontend-supported [data-module="app-copy"] & {
padding-top: 45px; // Allow extra space for the copy code button
}
}
Expand Down

0 comments on commit 01bf8df

Please sign in to comment.