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

Use createAll to initialise components in the Design System site #4053

Merged
merged 10 commits into from
Aug 20, 2024

Conversation

romaricpascal
Copy link
Member

As using createAll requires component to hold a static moduleName property, this PR updates the build process to add transpilation of the JavaScript with Babel (rather than relying on code being authored to match JavaScript features, linted by es-x).

It then uses createAll to instantiate components that were previously looked up using document.querySelector[All] in application.js.

Components not updated

  • OptionsTable works based on the hash, rather than specific elements on the page. It could actually be refactored as a function rather than a class.
  • Navigation doesn't really have a 'root' element as it looks things up in the document. It could be broken down into two components with root elements, one for the menu itself and the other for the subnav collapsing, but that's a different refactoring.

Fixes #3812

Copy link

netlify bot commented Aug 19, 2024

You can preview this change here:

Name Link
🔨 Latest commit 5ee912a
🔍 Latest deploy log https://app.netlify.com/sites/govuk-design-system-preview/deploys/66c372ee220c0d000820ff1c
😎 Deploy Preview https://deploy-preview-4053--govuk-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Comment on lines +37 to +38
this.$module.prepend(this.$status)
this.$module.prepend(this.$button)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note $module is no longer the <pre> element containing the code, but the <div> wrapping it, which simplifies the insertion of the button and hidden status for assistive technology.

@romaricpascal romaricpascal marked this pull request as ready for review August 19, 2024 16:33
Copy link
Contributor

@patrickpatrickpatrick patrickpatrickpatrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this all looks good to me! nice work!

@romaricpascal romaricpascal merged commit a8fbe02 into main Aug 20, 2024
15 checks passed
@romaricpascal romaricpascal deleted the use-create-all branch August 20, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update JavaScript components of the Design System website so they can be used with the createAll function
2 participants