Class: GovukComponent::PanelComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/govuk_component/panel_component.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Constructor Details

#initialize(title_text: nil, text: nil, heading_level: 1, id: nil, classes: [], html_attributes: {}) ⇒ PanelComponent

Returns a new instance of PanelComponent.



6
7
8
9
10
11
12
13
# File 'app/components/govuk_component/panel_component.rb', line 6

def initialize(title_text: nil, text: nil, heading_level: 1, id: nil, classes: [], html_attributes: {})
  @heading_level = heading_level
  @title_text    = title_text
  @text          = text
  @id            = id

  super(classes: classes, html_attributes: html_attributes)
end

Instance Attribute Details

#heading_levelObject (readonly)

Returns the value of attribute heading_level.



2
3
4
# File 'app/components/govuk_component/panel_component.rb', line 2

def heading_level
  @heading_level
end

#idObject (readonly)

Returns the value of attribute id.



2
3
4
# File 'app/components/govuk_component/panel_component.rb', line 2

def id
  @id
end

#textObject (readonly)

Returns the value of attribute text.



2
3
4
# File 'app/components/govuk_component/panel_component.rb', line 2

def text
  @text
end

#title_textObject (readonly)

Returns the value of attribute title_text.



2
3
4
# File 'app/components/govuk_component/panel_component.rb', line 2

def title_text
  @title_text
end

Instance Method Details

#callObject



15
16
17
18
19
# File 'app/components/govuk_component/panel_component.rb', line 15

def call
  tag.div(id: id, **html_attributes) do
    safe_join([panel_title, panel_body].compact)
  end
end