Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates for GOV.UK Frontend v5.0.0 #2977

Merged
merged 66 commits into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
72ffbb1
Install GOV.UK Frontend v5.0.0 beta
colinrotherham Jul 27, 2023
d9c2c8c
Use GOV.UK Frontend ES modules snippet in Nunjucks previews
colinrotherham Jul 20, 2023
c3f30d6
Update website to use `<script type="module">`
colinrotherham Jul 20, 2023
5d89f45
Update Terser configs to remove ES5 restrictions
colinrotherham Jul 20, 2023
96f8c9c
Replace `nodeListForEach()` helper with `.forEach()`
colinrotherham Sep 27, 2023
f8eee4d
Remove options table `<details>` polyfill handling
colinrotherham Sep 28, 2023
2eccee9
Remove ESLint rule `'no-var'` for let/const support
colinrotherham Jul 20, 2023
9d46aca
Run `eslint --fix`
colinrotherham Jul 20, 2023
29e4dbf
Remove ESLint rule `'quote-props'` for ES5 property names
colinrotherham Jul 20, 2023
c8de51d
Run `eslint --fix`
colinrotherham Jul 20, 2023
6326c0e
Remove ESLint rule `'object-shorthand'` for ES6 property shorthand
colinrotherham Jul 20, 2023
bc6c882
Run `eslint --fix`
colinrotherham Jul 20, 2023
4ca177d
Add ESLint rules to auto fix concatenated strings
colinrotherham Jul 20, 2023
33917c3
Run `eslint --fix`
colinrotherham Aug 16, 2023
9a49cd6
Use arrow functions to preserve `this` in components
colinrotherham Sep 27, 2023
ccc4c62
Use arrow functions to preserve `this` in event listeners
colinrotherham Jul 20, 2023
59a30e4
Use arrow functions to preserve `this` in timers
colinrotherham Jul 20, 2023
108142c
Convert all components to ES2015 classes
colinrotherham Jul 20, 2023
34ae8a3
Enable ESLint JSDoc checks
colinrotherham Jul 20, 2023
7f8b0b5
Fix invalid or required JSDoc blocks
colinrotherham Sep 27, 2023
8181588
Fix invalid or required JSDoc blocks
colinrotherham Sep 27, 2023
9964e4c
Remove checks for matchMedia
colinrotherham Sep 28, 2023
5f33c18
Add TypeScript compiler config (with types)
colinrotherham Jul 20, 2023
c7b0ec1
Disable type checking for Google Analytics script
colinrotherham Aug 1, 2023
a191c5f
Fix compiler “Property 'toGMTString' does not exist on type 'Date'"
colinrotherham Jul 20, 2023
233733a
Fix compiler “Property does not exist on type 'Window & typeof global…
colinrotherham Aug 1, 2023
c91dcea
Fix compiler “Property does not exist on type 'ParentNode'"
colinrotherham Jul 20, 2023
670fa8c
Fix compiler “Argument of type 'boolean' is not assignable to paramet…
colinrotherham Jul 20, 2023
8efc629
Follow GOV.UK Frontend coding standards for element checks
colinrotherham Sep 27, 2023
2117708
Remove init method from all components
colinrotherham Sep 27, 2023
4fcfc2b
Remove init() method from initAll function and component example
colinrotherham Jul 27, 2023
84b678a
Replace `.js-enabled` with `.govuk-frontend-supported` in docs
colinrotherham Aug 1, 2023
db3738e
Add initial example
frankieroberto Oct 9, 2023
279ed8d
Move component `.js-enabled` styling to `.govuk-frontend-supported`
colinrotherham Jul 26, 2023
2cc3ded
Switch out image with HTML example
frankieroberto Oct 9, 2023
9e97a42
Skip initialisation when GOV.UK Frontend is not supported
colinrotherham Jul 27, 2023
bd2f5da
Update content and examples
frankieroberto Oct 9, 2023
50fac01
Remove link to prototype kit code
frankieroberto Oct 3, 2023
3350ff3
Remove suggestion of including a summary
frankieroberto Oct 3, 2023
38d38cd
Rename pattern to "Complete multiple tasks"
frankieroberto Oct 9, 2023
f0825e8
Move guidance to the pattern page
frankieroberto Oct 9, 2023
8fa4d51
Fix typo and remove scare quotes
paulrobertlloyd Oct 9, 2023
9189f03
Update the roadmap and upcoming components
colinrotherham Oct 9, 2023
1dc7209
Update Tag page to describe the changes to the design.
frankieroberto Apr 14, 2023
f4d9095
Archive task list pages pattern
colinrotherham Oct 9, 2023
087bf26
Improve screen reader compatibility for code copied announcement
querkmachine Aug 18, 2023
9f3cc6f
Code style fix
frankieroberto Sep 25, 2023
ea1c34c
Merge pull request #1994 from x-govuk/task-list-component
colinrotherham Oct 9, 2023
d273038
Merge pull request #2733 from frankieroberto/tag-changes
colinrotherham Oct 9, 2023
bab4191
Fix opening line on task list pattern page
frankieroberto Oct 13, 2023
15922b9
Merge pull request #3217 from x-govuk/fix-task-list-pattern-page-intro
colinrotherham Oct 13, 2023
21a897f
Avoid page template example `assetUrl` escaping
colinrotherham Oct 26, 2023
2b59475
Update research section on task list pattern
frankieroberto Nov 20, 2023
eb6cc3f
Update page template examples using `govuk-frontend.min.css`
colinrotherham Oct 26, 2023
5e80b52
Fix link
frankieroberto Nov 21, 2023
ac2cbdf
Show examples using `govuk-frontend.min.css`
colinrotherham Oct 26, 2023
5abfbff
Install govuk-frontend@5.0.0-beta.2
romaricpascal Nov 24, 2023
eb5fc31
Update content
frankieroberto Nov 21, 2023
0d056e1
Update the site header
romaricpascal Nov 24, 2023
7776c86
Update content
frankieroberto Nov 21, 2023
087845c
Copy manifest.json into site assets
romaricpascal Nov 24, 2023
a470c57
Merge pull request #3321 from x-govuk/update-research-on-task-list-co…
owenatgov Nov 24, 2023
9e95a53
Merge pull request #3325 from alphagov/update-v5.0.0-beta.2
romaricpascal Nov 24, 2023
f29730f
Update What’s New for v5.0.0
36degrees Dec 8, 2023
37572db
Update Roadmap
36degrees Dec 8, 2023
fe85a2e
Merge pull request #3358 from alphagov/update-whats-new-roadmap-v5
36degrees Dec 8, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 46 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
extends: [
'eslint:recommended',
'plugin:import/recommended',
'plugin:jsdoc/recommended-typescript-flavor',
'plugin:n/recommended',
'plugin:promise/recommended',
'prettier'
Expand All @@ -27,7 +28,7 @@ module.exports = {
parserOptions: {
ecmaVersion: 'latest'
},
plugins: ['import', 'n', 'promise'],
plugins: ['import', 'jsdoc', 'n', 'promise'],
rules: {
// Check import or require statements are A-Z ordered
'import/order': [
Expand All @@ -36,7 +37,50 @@ module.exports = {
alphabetize: { order: 'asc' },
'newlines-between': 'always'
}
]
],

// JSDoc blocks are optional by default
'jsdoc/require-jsdoc': 'off',

// Check for valid formatting
'jsdoc/check-line-alignment': [
'warn',
'never',
{
wrapIndent: ' '
}
],

// Add unknown @jest-environment tag name
'jsdoc/check-tag-names': [
'warn',
{
definedTags: ['jest-environment']
}
],

// Require hyphens before param description
// Aligns with TSDoc style: https://tsdoc.org/pages/tags/param/
'jsdoc/require-hyphen-before-param-description': 'warn',

// Maintain new line after description
'jsdoc/tag-lines': [
'warn',
'never',
{
startLines: 1
}
],

// Automatically use template strings
'no-useless-concat': 'error',
'prefer-template': 'error'
},
settings: {
jsdoc: {
// Allows us to use type declarations that exist in our dependencies
mode: 'typescript'
}
}
},
{
Expand Down
13 changes: 13 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ updates:
- 'standard'
- 'stylelint'
- 'stylelint-*'
- 'typescript'

metalsmith:
patterns:
Expand All @@ -41,10 +42,22 @@ updates:
test:
patterns:
- '@axe-core/*'
- '@jest/*'
- '@types/jest'
- '@types/jest-*'
- 'jest'
- 'jest-*'
- 'puppeteer'

types:
patterns:
- '@types/*'

# Exclude packages in other groups
exclude-patterns:
- '@types/jest'
- '@types/jest-*'

reviewers:
- alphagov/design-system-developers

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ jobs:
run: npm run lint:prettier
continue-on-error: true

- description: TypeScript compiler
run: npm run lint:types -- --pretty

- description: JavaScript tests
run: npx jest --color --maxWorkers=2

Expand Down
4 changes: 2 additions & 2 deletions __tests__/component-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('Component page', () => {
await goTo(page, '/components/back-link/#options-back-link-example')

// Check if example's macro options details element is open
await page.waitForSelector('#options-back-link-example-details[open=open]')
await page.waitForSelector('#options-back-link-example-details[open]')

// Check if the example has been scrolled into the viewport
const $example = await page.$('#options-back-link-example-details')
Expand All @@ -91,7 +91,7 @@ describe('Component page', () => {
)

// Check if example's macro options details element is open
await page.waitForSelector('#options-text-input-example-details[open=open]')
await page.waitForSelector('#options-text-input-example-details[open]')

// Check if the example has been scrolled into the viewport
const $example = await page.$('#options-text-input-example--label')
Expand Down
8 changes: 2 additions & 6 deletions __tests__/cookie-functions.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ describe('Cookie settings', () => {
const cookies = document.cookie.split(';')
cookies.forEach(function (cookie) {
const name = cookie.split('=')[0]
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/'
document.cookie =
name +
'=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=' +
window.location.hostname +
';path=/'
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/`
document.cookie = `${name}=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=${window.location.hostname};path=/`
})
})

Expand Down
5 changes: 2 additions & 3 deletions lib/colours.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function getColourFromSass(sass, variableName) {
* Extracts the colour palette from the $govuk-colours map defined in
* settings/_colours-palette.scss in GOV.UK Frontend
*
* @return Object mapping colour names to their hexadecimal values
* @returns Object mapping colour names to their hexadecimal values
*/

const palette = function () {
Expand Down Expand Up @@ -63,9 +63,8 @@ const palette = function () {
* }
* ```
*
* @return Object containing 'groups' of colours
* @returns {{ [color: string]: { name: string, notes?: string }[] }} Groups of colours
*/

const applied = function () {
const data = require('../data/colours.json')
const sass = parseSCSS('_colours-applied.scss')
Expand Down
1 change: 0 additions & 1 deletion lib/extract-page-headings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const { slugify } = require('../nunjucks/filters')
/**
* Metalsmith extract headings plugin
*
* @param {string[]} config.pattern - File match glob patterns
* @returns {import('metalsmith').Plugin} Metalsmith plugin
*/
const extractPageHeadings = () => (files, metalsmith, done) => {
Expand Down
1 change: 1 addition & 0 deletions lib/fingerprints/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const hashAssets = (config) => (files, metalsmith, done) => {
*
* @param {import('metalsmith').Files} files - Metalsmith files
* @param {import('metalsmith')} metalsmith - Metalsmith builder
* @returns {(pathAsset: string) => { path: string; hash: string; }} File hasher
*/
const hashAsset = (files, metalsmith) => {
const metadata = metalsmith.metadata()
Expand Down
17 changes: 9 additions & 8 deletions lib/generate-sitemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,19 @@ const removeEmptyKeys = (obj) => {
/**
* Plugin to generate a sitemap
*
* See Sitemaps XML format for more information
* {@link https://www.sitemaps.org/protocol.html}
*
* @param {object} opts - Sitemap options
* @param {string} opts.hostname
* @param {string} [opts.changefreq]
* @param {string} [opts.lastmod]
* @param {string} [opts.priority]
* @param {string} [opts.filename]
* @param {string} [opts.pattern]
* @param {string} opts.hostname - Parent URL for each entry
* @param {'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly'} [opts.changefreq] - Default change frequency for each entry
* @param {string} [opts.lastmod] - Default last modified date in ISO format
* @param {string} [opts.priority] - Default priority for each entry between 0-1
* @param {string} [opts.filename] - Sitemap filename, e.g. sitemap.xml
* @param {string | string[]} [opts.pattern] - Minimatch pattern
* @returns {import('metalsmith').Plugin} Metalsmith plugin
*/
const plugin = (opts) => {
opts = opts || {}

if (!opts.hostname) {
throw new Error('"hostname" is required')
}
Expand Down
7 changes: 6 additions & 1 deletion lib/get-macro-options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const marked = new DesignSystemMarked().use({
/**
* Render paragraphs without `<p>` wrappers
* for macro options in `<td>` table cells
*
* @param {import('marked').Tokens.Paragraph} token - Paragraph token
* @returns {string} Rendered paragraph
*/
renderer(token) {
return this.parser.parseInline(token.tokens)
Expand Down Expand Up @@ -189,7 +192,9 @@ function getAdditionalComponentOptions(options, parent) {
* }
* ```
*
* */
* @param {string} componentName - Component name
* @returns {{ name: string, id: string, options: unknown[] }} Macro options
*/
function getMacroOptions(componentName) {
// The design system uses a different name for the input component.
if (componentName === 'text-input') {
Expand Down
4 changes: 3 additions & 1 deletion lib/marked/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* (for example, HTML code inside Markdown)
*
* @param {TokenCode} token - Marked code token
* @returns {string} Code block
*/
exports.code = function (token) {
if (!token.lang) {
Expand All @@ -18,12 +19,13 @@ exports.code = function (token) {
* Render single images without `<p>` wrappers
*
* @param {TokenText | TokenParagraph} token - Marked paragraph token
* @returns {string | false} Rendered image or false
*/
exports.image = function (token) {
const { tokens } = token

return tokens?.length === 1 && tokens[0].type === 'image'
? this.parser.parseInline(tokens) + '\n'
? `${this.parser.parseInline(tokens)}\n`
: false // Fall back to default renderer
}

Expand Down
8 changes: 3 additions & 5 deletions lib/metalsmith-title-checker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* Metalsmith plugin to check each page has a unique title.
* Which is required to make sure users of assistive technologies can navigate easily.
*
* @return {Function}
*/

function groupFilesByTitle(filenames, files) {
Expand Down Expand Up @@ -76,9 +74,9 @@ module.exports = function titleChecker() {

if (filesWithoutTitles.length) {
throw Error(
'The following file(s) do not have titles:\n\n' +
filesWithoutTitles.map((file) => `- ${file}`).join('\n') +
'\n'
`The following file(s) do not have titles:\n\n${filesWithoutTitles
.map((file) => `- ${file}`)
.join('\n')}\n`
)
}
done()
Expand Down
12 changes: 11 additions & 1 deletion lib/metalsmith.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module.exports = metalsmith
.use(extractPageHeadings())

// ignore files from build
.ignore(['.DS_Store', '.eslintrc.js'])
.ignore(['.DS_Store', '.eslintrc.js', 'tsconfig.json'])

// convert *.scss files to *.css
.use(
Expand Down Expand Up @@ -137,6 +137,16 @@ module.exports = metalsmith
copyAssets('{fonts,images}/*', {
cwd: join(dirname(require.resolve('govuk-frontend')), 'assets'),
dest: 'assets'
}),

copyAssets('manifest.json', {
cwd: join(dirname(require.resolve('govuk-frontend')), 'assets'),
dest: 'assets'
}),

copyAssets('govuk-frontend.min.css?(.map)', {
cwd: dirname(require.resolve('govuk-frontend')),
dest: 'stylesheets'
})
])

Expand Down
22 changes: 16 additions & 6 deletions lib/nunjucks/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ nunjucks.configure(join(paths.views, 'layouts'))
/**
* This helper function takes a path of a *.md.njk file and
* returns the Nunjucks syntax inside that file without markdown data and imports
*
* @param {string} path - Path to Nunjucks file
* @returns {string} Nunjucks code for the file
*/
exports.getNunjucksCode = function (path) {
const { content } = matter(readFileSync(path, 'utf-8'))
Expand All @@ -27,20 +30,26 @@ exports.getNunjucksCode = function (path) {
/**
* This helper function takes a path of a *.md.njk file and
* returns the frontmatter as an object
*
* @param {string} path - Path to Nunjucks file
* @returns {{ [key: string]: unknown }} Frontmatter object
*/
exports.getFrontmatter = function (path) {
return matter(readFileSync(path, 'utf-8')).data
}

/**
* Get 'fingerprinted' version of a given asset file
*
* @param {string} file - Relative path to asset
* @returns {string} Relative path to asset with added hash fingerprint
*/
exports.getFingerprint = function (file) {
file = normalize(file)

// Skip fingerprints in development for Browsersync inject (without reload)
if (process.env.NODE_ENV === 'development') {
return '/' + slash(file)
return `/${slash(file)}`
}

// Grab fingerprint array from the template context
Expand All @@ -65,23 +74,24 @@ exports.getFingerprint = function (file) {
}

// Look for a fingerprinted asset at this path relative to the site root
return '/' + slash(fingerprints[file].path)
return `/${slash(fingerprints[file].path)}`
}

/**
* This helper function takes a path of a *.md.njk file and
* returns the HTML rendered by Nunjucks without markdown data
*
* @param {string} path - Path to Nunjucks file
* @returns {string} HTML rendered by the file
*/
exports.getHTMLCode = function (path) {
const { content } = matter(readFileSync(path, 'utf-8'))

let html = ''
try {
html = nunjucks.renderString(content).trim()
} catch (err) {
if (err) {
console.log('Could not get HTML code from ' + path)
}
} catch (error) {
console.log(`Could not get HTML code from ${path}`)
}

const options = beautify.html.defaultOptions()
Expand Down
Loading
Loading