Closed
Description
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
- Configure components on the GOV.UK Frontend docs
mergeConfigs
helper that helps merging configuration from different sources (defaults, HTML Element attributes, JavaScript object)- A spike from Ollie proposing a way to implement the configuration as a class (note that there's been some changes to how the merging of configuration works since).
Epic lead
Driving role(s)
@seaemsi , @patrickpatrickpatrick, @Izabela-16
Further detail
Publish new API
- Refactor the check for the type of the root element in
GOVUKFrontendComponent
#5326 - Refactor existing components to use the new
Component
class govuk-design-system#4156 - Add new 'Building your own components' page govuk-frontend-docs#467
- Merge
public-js-api
tomain
- Check no further refactoring of
$module
to$root
are necessary (Rename$module
to$root
across the project #5322) - Release
- Close Investigate components being initialised more than once #1127
- Fix typos in the new 'Building your own components' page govuk-frontend-docs#472
- Update workaround for TypeScript
Dev
- Spike into
Config
class if defined by child class ofGOVUKFrontendComponent
#5427 - Spike into
Config
class if defined byGOVUKFrontendComponent
#5426 - Spike into
Config
class if defined byGOVUKFrontendComponentConfigurable
#5430 - Refactor
Accordion
to extend from aGOVUKFrontendConfigurableComponent
class #5456 - Refactor
Button
to extend from aGOVUKFrontendConfigurableComponent
class #5457 - Refactor
CharacterCount
to extend from aGOVUKFrontendConfigurableComponent
class #5458 - Refactor
ErrorSummary
to extend from aGOVUKFrontendConfigurableComponent
class #5459 - Refactor
ExitThisPage
to extend from aGOVUKFrontendConfigurableComponent
class #5460 - Refactor
NotificationBanner
to extend from aGOVUKFrontendConfigurableComponent
class #5461 - Refactor
PasswordInput
to extend from aGOVUKFrontendConfigurableComponent
class #5462 - Export
GOVUKFrontendConfigurableComponent
as part of the public API #5463 - Use
ConfigurableComponent
in the Design System's Cookie Banner govuk-design-system#4275 - Remove
GOVUKFrontend
prefix fromGOVUKFrontendComponent
class #5497 - [Stretch] Review the overlap of the different types representing a component class in our code #5469
- [Stretch] Investigate if we can use
config
instead ofdefaults
increateAll
to get the configuration type #5465 - [Stretch] Create a
ConfigurableComponent
class to further encapsulate receiving a configuration #5466 - [Stretch] Export
ConfigurableComponent
as part of the public API #5468 - [Stretch] Use the
ConfigurableComponent
in the Design System's Cookie Banner govuk-design-system#4276
Documentation
- Draft documentation for the configuration features of the public JavaScript API govuk-frontend-docs#482
- Iterate documentation draft until it's ready for review govuk-frontend-docs#483
- Make drafted documentation for 'Building configurable components' go through review process #5502
- Update internal docs on configuration options #5501
- Add 'Building configurable components' section to the Frontend Docs govuk-frontend-docs#486
- Merge the content to the main branch of the Frontend docs