Class: GovukComponent::Base
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- GovukComponent::Base
- Defined in:
- app/components/govuk_component/base.rb
Direct Known Subclasses
AccordionComponent, AccordionComponent::SectionComponent, BackLinkComponent, BreadcrumbsComponent, CookieBannerComponent, CookieBannerComponent::MessageComponent, DetailsComponent, ExitThisPageComponent, FooterComponent, HeaderComponent, HeaderComponent::NavigationItem, HeaderComponent::ProductName, InsetTextComponent, NotificationBannerComponent, NotificationBannerComponent::Heading, PaginationComponent, PaginationComponent::AdjacentPage, PaginationComponent::Item, PanelComponent, PhaseBannerComponent, SectionBreakComponent, ServiceNavigationComponent, ServiceNavigationComponent::NavigationItemComponent, ServiceNavigationComponent::ServiceNameComponent, StartButtonComponent, SummaryListComponent, SummaryListComponent::ActionComponent, SummaryListComponent::CardComponent, SummaryListComponent::KeyComponent, SummaryListComponent::RowComponent, SummaryListComponent::ValueComponent, TabComponent, TabComponent::Tab, TableComponent, TableComponent::BodyComponent, TableComponent::CaptionComponent, TableComponent::CellComponent, TableComponent::ColGroupComponent, TableComponent::ColGroupComponent::ColComponent, TableComponent::FootComponent, TableComponent::HeadComponent, TableComponent::RowComponent, TagComponent, TaskListComponent, TaskListComponent::ItemComponent, TaskListComponent::StatusComponent, TaskListComponent::TitleComponent, WarningTextComponent
Instance Attribute Summary collapse
-
#html_attributes ⇒ Object
readonly
Returns the value of attribute html_attributes.
Instance Method Summary collapse
- #brand(override = nil) ⇒ Object
-
#class_prefix ⇒ Object
We want the main component and the subcomponents here so match on the second segment of the component class name.
-
#initialize(classes:, html_attributes:) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(classes:, html_attributes:) ⇒ Base
Returns a new instance of Base.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/govuk_component/base.rb', line 8 def initialize(classes:, html_attributes:) if classes.nil? Rails.logger.warn("classes is nil, if no custom classes are needed omit the param") classes = [] end # FIXME: remove first merge when we deprecate classes # # This step only needs to be here while we still accept classes:, now # we're using html_attributes_utils we can start to move towards # supporting html_attributes: { class: 'xyz' } over taking them # separately @html_attributes = default_attributes .deep_merge_html_attributes({ class: classes }) .deep_merge_html_attributes(html_attributes) .deep_tidy_html_attributes super end |
Instance Attribute Details
#html_attributes ⇒ Object (readonly)
Returns the value of attribute html_attributes.
4 5 6 |
# File 'app/components/govuk_component/base.rb', line 4 def html_attributes @html_attributes end |
Instance Method Details
#brand(override = nil) ⇒ Object
29 30 31 |
# File 'app/components/govuk_component/base.rb', line 29 def brand(override = nil) override || config.brand_overrides.fetch(class_prefix, config.brand) end |
#class_prefix ⇒ Object
We want the main component and the subcomponents here so match on the second segment of the component class name
35 36 37 38 |
# File 'app/components/govuk_component/base.rb', line 35 def class_prefix # FIXME: this looks a bit dodgy... self.class.name.match(/\w+::\w+/).to_s end |