Skip to content

Commit

Permalink
Merge pull request #192 from nationalarchives/govukfrontendv5
Browse files Browse the repository at this point in the history
GOV.UK frontend upgrade from version 4 to 5
  • Loading branch information
garethfoote authored Dec 11, 2024
2 parents 2592b10 + 4361706 commit b194f94
Show file tree
Hide file tree
Showing 14 changed files with 45 additions and 34 deletions.
8 changes: 4 additions & 4 deletions .storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ const config = {
loader: "sass-loader",
options: {
additionalData: `
@import "govuk-frontend/govuk/base";
@import "govuk-frontend/govuk/settings/all";
@import "govuk-frontend/govuk/tools/all";
@import "govuk-frontend/govuk/helpers/all";
@import "govuk-frontend/dist/govuk/base";
@import "govuk-frontend/dist/govuk/settings/all";
@import "govuk-frontend/dist/govuk/tools/all";
@import "govuk-frontend/dist/govuk/helpers/all";
`,
implementation: require("sass"),
},
Expand Down
9 changes: 9 additions & 0 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,13 @@ const preview = {
},
};

// Add the required GOV.UK Frontend classes to the body
if (typeof window !== 'undefined' && document.body) {
document.body.className +=
' js-enabled' +
('noModule' in HTMLScriptElement.prototype
? ' govuk-frontend-supported'
: '');
}

export default preview;
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
"yaml-loader": "^0.8.1"
},
"dependencies": {
"govuk-frontend": "^4.9.0"
"govuk-frontend": "^5.7.1"
}
}
2 changes: 1 addition & 1 deletion src/nationalarchives/all.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@import "overrides";
@import "govuk-frontend/govuk/all";
@import "govuk-frontend/dist/govuk/all";
@import "components";
8 changes: 4 additions & 4 deletions src/nationalarchives/components/alert/alert.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@import "govuk-frontend/govuk/settings/all";
@import "govuk-frontend/govuk/tools/all";
@import "govuk-frontend/govuk/helpers/all";
@import "govuk-frontend/govuk/components/inset-text";
@import "govuk-frontend/dist/govuk/settings/all";
@import "govuk-frontend/dist/govuk/tools/all";
@import "govuk-frontend/dist/govuk/helpers/all";
@import "govuk-frontend/dist/govuk/components/inset-text";
@import "index";
1 change: 0 additions & 1 deletion src/nationalarchives/components/alert/alert.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// import "govuk-frontend/govuk/components/inset-text";
import "../icon/_index.scss";
import "./_index.scss";
import iconStory from "../icon/icon.stories";
Expand Down
6 changes: 3 additions & 3 deletions src/nationalarchives/components/card/card.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "govuk-frontend/govuk/settings/all";
@import "govuk-frontend/govuk/tools/all";
@import "govuk-frontend/govuk/helpers/all";
@import "govuk-frontend/dist/govuk/settings/all";
@import "govuk-frontend/dist/govuk/tools/all";
@import "govuk-frontend/dist/govuk/helpers/all";
@import "index";
6 changes: 3 additions & 3 deletions src/nationalarchives/components/header/header.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "govuk-frontend/govuk/settings/all";
@import "govuk-frontend/govuk/tools/all";
@import "govuk-frontend/govuk/helpers/all";
@import "govuk-frontend/dist/govuk/settings/all";
@import "govuk-frontend/dist/govuk/tools/all";
@import "govuk-frontend/dist/govuk/helpers/all";
@import "index";
9 changes: 6 additions & 3 deletions src/nationalarchives/components/header/header.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ export default {
(storyFn) => {
// Create an element that centres element with margin.
const wrapper = document.createElement("div");
wrapper.classList.add("js-enabled");
const parser = new DOMParser();
const doc = parser.parseFromString(storyFn() as string, "text/html");
wrapper.append(...doc.body.children);

const header = wrapper.querySelector('[data-module="govuk-header"]');
if (header !== null) {
new Header(header).init();
// Necessary because of the order in which decorators are
// applied. If the timeout isn't present Header() will not
// find any navigation items.
setTimeout(() => {
new Header(header);
}, 0);
}

return wrapper;
Expand Down
6 changes: 3 additions & 3 deletions src/nationalarchives/components/icon/icon.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "govuk-frontend/govuk/settings/all";
@import "govuk-frontend/govuk/tools/all";
@import "govuk-frontend/govuk/helpers/all";
@import "govuk-frontend/dist/govuk/settings/all";
@import "govuk-frontend/dist/govuk/tools/all";
@import "govuk-frontend/dist/govuk/helpers/all";
@import "index";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "govuk-frontend/govuk/settings/all";
@import "govuk-frontend/govuk/tools/all";
@import "govuk-frontend/govuk/helpers/all";
@import "govuk-frontend/dist/govuk/settings/all";
@import "govuk-frontend/dist/govuk/tools/all";
@import "govuk-frontend/dist/govuk/helpers/all";
@import "index";
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "govuk-frontend/govuk/settings/all";
@import "govuk-frontend/govuk/tools/all";
@import "govuk-frontend/govuk/helpers/all";
@import "govuk-frontend/dist/govuk/settings/all";
@import "govuk-frontend/dist/govuk/tools/all";
@import "govuk-frontend/dist/govuk/helpers/all";
@import "index";
2 changes: 1 addition & 1 deletion src/nationalarchives/govuk.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@import "govuk-frontend/govuk/all";
@import "govuk-frontend/dist/govuk/all";
@import "overrides";

0 comments on commit b194f94

Please sign in to comment.