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

[Stretch] Create a ConfigurableComponent class to further encapsulate receiving a configuration #5466

Closed
2 tasks
Tracked by #5373
romaricpascal opened this issue Nov 4, 2024 · 1 comment

Comments

@romaricpascal
Copy link
Member

romaricpascal commented Nov 4, 2024

What

Create a GOVUKFrontendConfigurableComponent class that extends GOVUKFrontendComponent and encapsulate storing the configuration computed by getComponentConfiguration in this.config (similarly to how GOVUKFrontendComponent encapsulates storing the root of the component)

The constructor signature would be constructor(root, config).

Type wise, it’ll need to be a generic class, to allow components extending it to specify the type of the configuration object they work on: ConfigurableComponent<ConfigurationType, RootElementType> (configuration type first as it’s necessarily specified, while RootElementType is optional).

Update the components using getComponentConfiguration to use it.

Why

This would add further consistency to how components receive configuration, formalising the name of the variable storing the configuration and encapsulating a behaviour repeated by all components receiving configuration.

Who needs to work on this

Developers

Who needs to review this

Developers

Done when

  • We added the GOVUKFrontendConfigurableComponent class
  • We've updated our components to use it
@romaricpascal
Copy link
Member Author

Closing as #5456 has been updated to implement a class rather than a function.

@romaricpascal romaricpascal closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2024
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

No branches or pull requests

1 participant