Class: DesignSystem::Generic::HeadingComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- DesignSystem::Generic::HeadingComponent
- Defined in:
- app/components/design_system/generic/heading_component.rb
Overview
Generic page heading. Brand subclasses inherit unchanged.
Direct Known Subclasses
DesignSystem::Govuk::HeadingComponent, Nhsuk::HeadingComponent
Constant Summary collapse
- SIZE_MAPPING =
{ 1 => 'xl', 2 => 'l', 3 => 'm', 4 => 's', 5 => 'xs', 6 => 'xs' }.freeze
Instance Attribute Summary collapse
-
#level ⇒ Object
readonly
Returns the value of attribute level.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(text, level: 2, **options) ⇒ HeadingComponent
constructor
A new instance of HeadingComponent.
Methods included from Helpers::CssHelper
Methods included from BrandDerivable
Constructor Details
#initialize(text, level: 2, **options) ⇒ HeadingComponent
Returns a new instance of HeadingComponent.
14 15 16 17 18 19 20 |
# File 'app/components/design_system/generic/heading_component.rb', line 14 def initialize(text, level: 2, **) super() @text = text @level = level.to_i @options = validate_level! end |
Instance Attribute Details
#level ⇒ Object (readonly)
Returns the value of attribute level.
22 23 24 |
# File 'app/components/design_system/generic/heading_component.rb', line 22 def level @level end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
22 23 24 |
# File 'app/components/design_system/generic/heading_component.rb', line 22 def @options end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
22 23 24 |
# File 'app/components/design_system/generic/heading_component.rb', line 22 def text @text end |
Instance Method Details
#call ⇒ Object
24 25 26 |
# File 'app/components/design_system/generic/heading_component.rb', line 24 def call content_tag("h#{level}", text, class: heading_class, **) end |