Class: DesignSystem::BaseComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- DesignSystem::BaseComponent
- Includes:
- BrandDerivable, Helpers::CssHelper
- Defined in:
- app/components/design_system/base_component.rb
Overview
Base class for all design-system view components. Provides the brand derivation and shared CSS helpers.
On the inheritance pattern (Brand::FooComponent < Generic::FooComponent):
ViewComponent's docs recommend avoiding inheritance, but that guidance is
aimed at typical application components, not multi-brand design systems.
Here, Govuk::PanelComponent really is a specialization of the same
conceptual panel as Nhsuk's, and ViewComponent's ancestor-walking template
resolution lets Generic own the markup while brand classes override only
what they need (e.g. an extra CSS modifier). The alternatives we weighed —
one component with a brand: param, or sharing via a Concern — each trade
more than they save: the param approach buries brand-specific behaviour in
conditionals, and Concerns fight ViewComponent's sidecar-template model.
We accept the occasional empty subclass in exchange for a uniform,
predictable structure across the library.
Direct Known Subclasses
Generic::ActionLinkComponent, Generic::AlertComponent, Generic::BreadcrumbsComponent, Generic::ButtonComponent, Generic::CalloutComponent, Generic::DetailsComponent, Generic::GridComponent, Generic::HeadingComponent, Generic::InsetTextComponent, Generic::LinkComponent, Generic::ListComponent, Generic::NotificationComponent, Generic::PanelComponent, Generic::ParagraphComponent, Generic::StartButtonComponent, Generic::SummaryCardComponent, Generic::SummaryListComponent, Generic::TabComponent, Generic::TableComponent