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
Discovery: Allowing components to be extended/inherited #1879
Comments
I'll add use cases here as I think of them. Defeat variations that we don't want to supportOne that has come up is that the USWDS Button currently offers accent color variations that we do not, at the moment, intend to expose to VA. When we get va-button as usa-button from USWDS, how do we defeat those variations (which I'd imagine they will add)? Defeat properties we don't want to supportOne theoretical use case is if USWDS wants a property on a component that we do not want. While I think we all agreed that we won't allow for disabling form fields, let's just use that as an example. Say there was a property that disabled a component and we didn't want to offer that property. How would we defeat it? Add and/or alter properties we do want to supportEssentially the reverse of the above. Let's say we wanted to add inert as our preferred method of disabling a field. We might even want to use the same property name but have it do a different thing. How would we add a property and how might we alter a property to behave differently? |
This will carry over because of unexpected PTO. |
The Stencil LimitationOur initial thought was that we could
What are the options then?
If one component is some kind of special case of another more generic component (e.g. MyWelcomeDialog and MyDialog), then you could let the "special" component render the "generic" component and configure it with properties. This would mean that the "generic" component would need to be modified directly (additional props) to allow for customization, or, we would need to create small generic components that could be reused (composed) into a larger more specialized component. It would essentially be "Nesting existing components in a parent/child way". For example:
It seems that it's possible to create an This approach might be more useful when needing to bring together multiple types of components to create a single combined component. Creating something like But for one-off forks of individual components, it's clunky and creates a lot of overhead to manage.
The most straight forward approach might be to use the
This might be how we could consume back from USWDS if/when they build web components. This also might be useful for the VA Clinician Design System as a way to jump start their customization of VA components without us having to rebuild what we've already done. Other ThoughtsNeither composition or component nesting seem to entirely meet our expectations or needs. I also don't think it will fully solve for any of these scenarios either:
But if a team did want a jumping off point to build from our components, a possible workflow would be:
|
@humancompanion-usds assigning to you to review. |
One strategy I thought of for 'defeating' properties or variations we didn't want to support would be to capture them and return our preferred 'default' instead. For example, if we wanted to prevent big buttons, we could do something like:
And it would be used as |
Description
We have started some discussion about how the component library could be used by other design system teams so that they can extend web component functionality and styles for their own use (USWDS and the VA Clinician Design System specifically).
We are using Stencil to build our web components which uses classes that theoretically should be able to be extended using inheritance but this is something that the Stencil library has intentionally decided not to support. It was recommended instead to use composition.
Ideally, the goal here is to find a way to "inherit/import" (i.e. not copy and paste) a component and then add/remove a property even with that limitation.
There are a couple of different approaches we want to explore related to composition:
Some questions to answer:
Tasks
The text was updated successfully, but these errors were encountered: