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

Allow component config set via data attributes to be passed when initialising the component in JavaScript #2808

Closed
36degrees opened this issue Aug 24, 2022 · 1 comment
Labels
epic Epics are used in planning project boards to group related stories javascript
Milestone

Comments

@36degrees
Copy link
Contributor

36degrees commented Aug 24, 2022

What

We have a few components that be configured using data attributes set at the component level (on the same HTML element that has the data-module attribute). This includes:

  • button (data-prevent-double-click)
  • character count (data-maxwords, data-maxlength and data-threshold)
  • error summary (data-disable-auto-focus)
  • notification banner (data-disable-auto-focus)

Update these components so that the same config can be set via config at the point of initialisation, for example:

var button = new Button($button).init({
  preventDoubleClick: true
})

This does not cover data attributes are used on elements ‘within’ a component, like the data-behaviour attribute used on individual checkboxes within the checkboxes component.

Relies on #2698.

Why

This aligns the general concept of 'component config' with the approach we're using for internationalisation.

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

@36degrees 36degrees added the awaiting triage Needs triaging by team label Aug 24, 2022
@36degrees 36degrees added epic Epics are used in planning project boards to group related stories javascript javascript squad and removed awaiting triage Needs triaging by team labels Sep 8, 2022
@36degrees 36degrees added this to the [NEXT] milestone Sep 13, 2022
36degrees added a commit that referenced this issue Sep 13, 2022
Update the notification banner to merge the config from the config object passed at the point of construction with any data attributes, following the conventions established as part of #2808.

Co-authored-by: Romaric Pascal <[email protected]>
@36degrees
Copy link
Contributor Author

I think this is done 🎉

querkmachine pushed a commit that referenced this issue Oct 17, 2022
Update the notification banner to merge the config from the config object passed at the point of construction with any data attributes, following the conventions established as part of #2808.

Co-authored-by: Romaric Pascal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epic Epics are used in planning project boards to group related stories javascript
Projects
Development

No branches or pull requests

1 participant