Class: GovukComponent::CookieBannerComponent::MessageComponent

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

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

Constructor Details

#initialize(heading_text: nil, text: nil, hidden: false, role: nil, classes: [], html_attributes: {}) ⇒ MessageComponent

Returns a new instance of MessageComponent.



7
8
9
10
11
12
13
14
# File 'app/components/govuk_component/cookie_banner_component/message_component.rb', line 7

def initialize(heading_text: nil, text: nil, hidden: false, role: nil, classes: [], html_attributes: {})
  @heading_text = heading_text
  @text         = text
  @hidden       = hidden
  @role         = role

  super(classes:, html_attributes:)
end

Instance Attribute Details

#heading_textObject (readonly)

Returns the value of attribute heading_text.



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

def heading_text
  @heading_text
end

#hiddenObject (readonly)

Returns the value of attribute hidden.



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

def hidden
  @hidden
end

#roleObject (readonly)

Returns the value of attribute role.



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

def role
  @role
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
# File 'app/components/govuk_component/cookie_banner_component/message_component.rb', line 16

def call
  tag.div(role:, hidden:, **html_attributes) do
    safe_join([
      tag.div(class: "#{brand}-grid-row") do
        tag.div(class: "#{brand}-grid-column-two-thirds") { safe_join([heading_element, message_element]) }
      end,
      actions_element
    ])
  end
end