Class: DesignSystem::Generic::HeadingComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/design_system/generic/heading_component.rb

Overview

Generic page heading. Brand subclasses inherit unchanged.

Constant Summary collapse

SIZE_MAPPING =
{
  1 => 'xl',
  2 => 'l',
  3 => 'm',
  4 => 's',
  5 => 'xs',
  6 => 'xs'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::CssHelper

#css_class_options_merge

Methods included from BrandDerivable

#brand

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, **options)
  super()
  @text = text
  @level = level.to_i
  @options = options
  validate_level!
end

Instance Attribute Details

#levelObject (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

#optionsObject (readonly)

Returns the value of attribute options.



22
23
24
# File 'app/components/design_system/generic/heading_component.rb', line 22

def options
  @options
end

#textObject (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

#callObject



24
25
26
# File 'app/components/design_system/generic/heading_component.rb', line 24

def call
  ("h#{level}", text, class: heading_class, **options)
end