You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Design and document a public API to enable components outside of GOV.UK Frontend to receive a configuration in the same fashion the components from GOV.UK Frontend do.
This will allow further code sharing between code from GOV.UK Frontend and that of services or other Design Systems, leading less duplication in the compiled bundles sent to users, as well as avoiding to recreate a solution to the problem for services and other Design Systems.
This will also open the door to offering helpers for internationalising components, which we could start looking at as a stretch goal towards the end of the epic if time allows.
Not all components accept a configuration, so we need the feature to be composable rather than baked into the Component class that all components will inherit, and especially able to be tree-shaken if not used. If some steps in the feature are optional, it'd be neat if they can be tree-shaken when not used, as well. However, there'll be a balance to strike between something monolithic that encapsulates all steps, ensuring they run in the right order, and something more fragmented leaving it to the user to run each step but where unnecessary steps can be left out of the bundled code.
Some of our components do validations on the configuration they receive. We'll need to check how costly it would be to offer this as part of the public API as it could quickly spin into lots of Kbs that services can already use a 3rd party package to handle themselves (we have to implement ours to remain dependency free for now)
Most components do a straightforward merge of configuration options from their defaults, HTML dataset and constructor argument. The Character Count needs to do some overriding which we'll need to account for.
I think that's the only component with such shenanigans in GOV.UK Frontend, but it's worth a double check
Components outside GOV.UK Frontend may need a similar thing where the presence of one or multiple options in the constructor argument may mean some option(s) from the defaults or HTML dataset need clearing up.
as always, we'll be the first consumer of our feature, so it's good to look at the components in the Design System and see if any can be configured one way or another (the Cookie banner looks like it could)
Brief
Design and document a public API to enable components outside of GOV.UK Frontend to receive a configuration in the same fashion the components from GOV.UK Frontend do.
This will allow further code sharing between code from GOV.UK Frontend and that of services or other Design Systems, leading less duplication in the compiled bundles sent to users, as well as avoiding to recreate a solution to the problem for services and other Design Systems.
This will also open the door to offering helpers for internationalising components, which we could start looking at as a stretch goal towards the end of the epic if time allows.
Relevant links
mergeConfigs
helper that helps merging configuration from different sources (defaults, HTML Element attributes, JavaScript object)Epic lead
@romaricpascal
Driving role(s)
@seaemsi , @patrickpatrickpatrick, @Izabela-16
Further detail
Publish new API
GOVUKFrontendComponent
#5326Component
class govuk-design-system#4156Dev
Config
class if defined by child class ofGOVUKFrontendComponent
#5427Config
class if defined byGOVUKFrontendComponent
#5426Config
class if defined byGOVUKFrontendComponentConfigurable
#5430Accordion
to extend from aGOVUKFrontendConfigurableComponent
class #5456Button
to extend from aGOVUKFrontendConfigurableComponent
class #5457CharacterCount
to extend from aGOVUKFrontendConfigurableComponent
class #5458ErrorSummary
to extend from aGOVUKFrontendConfigurableComponent
class #5459ExitThisPage
to extend from aGOVUKFrontendConfigurableComponent
class #5460NotificationBanner
to extend from aGOVUKFrontendConfigurableComponent
class #5461PasswordInput
to extend from aGOVUKFrontendConfigurableComponent
class #5462GOVUKFrontendConfigurableComponent
as part of the public API #5463ConfigurableComponent
in the Design System's Cookie Banner govuk-design-system#4275GOVUKFrontend
prefix fromGOVUKFrontendComponent
class #5497config
instead ofdefaults
increateAll
to get the configuration type #5465ConfigurableComponent
class to further encapsulate receiving a configuration #5466ConfigurableComponent
as part of the public API #5468ConfigurableComponent
in the Design System's Cookie Banner govuk-design-system#4276Documentation
Community
The text was updated successfully, but these errors were encountered: