diff --git a/eleventy.config.js b/eleventy.config.js index fba39fe..916bfd7 100644 --- a/eleventy.config.js +++ b/eleventy.config.js @@ -9,10 +9,13 @@ module.exports = function (eleventyConfig) { fontFamily: 'system-ui, sans-serif', icons: { mask: 'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-mask-icon.svg?raw=true', - shortcut: 'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-favicon.ico', - touch: 'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-apple-touch-icon.png' + shortcut: + 'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-favicon.ico', + touch: + 'https://raw.githubusercontent.com/x-govuk/logo/main/images/x-govuk-apple-touch-icon.png' }, - opengraphImageUrl: 'https://x-govuk.github.io/govuk-prototype-components/assets/opengraph-image.png', + opengraphImageUrl: + 'https://x-govuk.github.io/govuk-prototype-components/assets/opengraph-image.png', homeKey: 'GOV.UK Prototype Components', parentSite: { url: 'https://x-govuk.github.io/#projects', @@ -21,9 +24,7 @@ module.exports = function (eleventyConfig) { url: process.env.GITHUB_ACTIONS ? 'https://x-govuk.github.io/govuk-prototype-components/' : '/', - stylesheets: [ - '/styles/application.css' - ], + stylesheets: ['/styles/application.css'], header: { organisationLogo: 'x-govuk', organisationName: 'X-GOVUK', @@ -65,21 +66,24 @@ module.exports = function (eleventyConfig) { }) // Collections - eleventyConfig.addCollection('homepage', collection => - collection.getFilteredByGlob([ - 'docs/autocomplete.md', - 'docs/masthead.md', - 'docs/primary-navigation.md', - 'docs/sub-navigation.md', - 'docs/related-navigation.md', - 'docs/data-attributes.md' - ]).sort((a, b) => (a.data.order || 0) - (b.data.order || 0)) + eleventyConfig.addCollection('homepage', (collection) => + collection + .getFilteredByGlob([ + 'docs/autocomplete.md', + 'docs/masthead.md', + 'docs/primary-navigation.md', + 'docs/sub-navigation.md', + 'docs/related-navigation.md', + 'docs/data-attributes.md' + ]) + .sort((a, b) => (a.data.order || 0) - (b.data.order || 0)) ) // Passthrough eleventyConfig.addPassthroughCopy('./docs/assets') eleventyConfig.addPassthroughCopy({ - './node_modules/@x-govuk/govuk-prototype-components/x-govuk/*.js': './assets/x-govuk' + './node_modules/@x-govuk/govuk-prototype-components/x-govuk/*.js': + './assets/x-govuk' }) eleventyConfig.addPassthroughCopy({ './node_modules/iframe-resizer/js/*.js': './assets' @@ -94,8 +98,6 @@ module.exports = function (eleventyConfig) { layouts: '_layouts', includes: '_components' }, - pathPrefix: process.env.GITHUB_ACTIONS - ? '/govuk-prototype-components' - : '/' + pathPrefix: process.env.GITHUB_ACTIONS ? '/govuk-prototype-components' : '/' } } diff --git a/govuk-prototype-kit/init.js b/govuk-prototype-kit/init.js index 8577093..e2981cf 100644 --- a/govuk-prototype-kit/init.js +++ b/govuk-prototype-kit/init.js @@ -1,6 +1,8 @@ -if (window.GOVUKPrototypeKit && +if ( + window.GOVUKPrototypeKit && window.GOVUKPrototypeKit.documentReady && - window.GOVUKPrototypeKit.majorVersion >= 13) { + window.GOVUKPrototypeKit.majorVersion >= 13 +) { window.GOVUKPrototypeKit.documentReady(function () { window.GOVUKPrototypeComponents.initAll() }) diff --git a/rollup.config.mjs b/rollup.config.mjs index 26baec3..298a994 100644 --- a/rollup.config.mjs +++ b/rollup.config.mjs @@ -1,17 +1,14 @@ import commonJs from '@rollup/plugin-commonjs' import { nodeResolve } from '@rollup/plugin-node-resolve' -export default [{ - input: [ - 'x-govuk/all.mjs' - ], - output: { - dir: 'x-govuk', - format: 'umd', - name: 'GOVUKPrototypeComponents' - }, - plugins: [ - nodeResolve(), - commonJs() - ] -}] +export default [ + { + input: ['x-govuk/all.mjs'], + output: { + dir: 'x-govuk', + format: 'umd', + name: 'GOVUKPrototypeComponents' + }, + plugins: [nodeResolve(), commonJs()] + } +] diff --git a/x-govuk/all.mjs b/x-govuk/all.mjs index 01b87fe..d2c2ead 100644 --- a/x-govuk/all.mjs +++ b/x-govuk/all.mjs @@ -2,7 +2,7 @@ import Autocomplete from './components/autocomplete/autocomplete.js' import Edge from './components/edge/edge.js' import WarnOnUnsavedChanges from './components/warn-on-unsaved-changes/warn-on-unsaved-changes.js' -function initAll (options) { +function initAll(options) { // Set the options to an empty object by default if no options are passed. options = typeof options !== 'undefined' ? options : {} @@ -20,15 +20,12 @@ function initAll (options) { new Edge($edge).init() }) - const $forms = scope.querySelectorAll('[data-module="warn-on-unsaved-changes"]') + const $forms = scope.querySelectorAll( + '[data-module="warn-on-unsaved-changes"]' + ) $forms.forEach(function ($form) { new WarnOnUnsavedChanges($form).init() }) } -export { - initAll, - Autocomplete, - Edge, - WarnOnUnsavedChanges -} +export { initAll, Autocomplete, Edge, WarnOnUnsavedChanges } diff --git a/x-govuk/components/edge/edge.js b/x-govuk/components/edge/edge.js index e58b44e..12c4592 100644 --- a/x-govuk/components/edge/edge.js +++ b/x-govuk/components/edge/edge.js @@ -7,11 +7,14 @@ export default function ($module) { } const nodes = $module.querySelectorAll('a[href="#"]') - nodes.forEach(node => { events.on('click', node, alertUser) }) + nodes.forEach((node) => { + events.on('click', node, alertUser) + }) - function alertUser (event) { + function alertUser(event) { event.preventDefault() - const message = event.target.dataset.message || 'Sorry, this hasn’t been built yet' + const message = + event.target.dataset.message || 'Sorry, this hasn’t been built yet' window.alert(message) }