Class: GovukComponent::CookieBannerComponent

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

Defined Under Namespace

Classes: MessageComponent

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Instance Method Summary collapse

Methods inherited from Base

#brand

Constructor Details

#initialize(aria_label: config.default_cookie_banner_aria_label, hidden: false, hide_in_print: config.default_cookie_banner_hide_in_print, classes: [], html_attributes: {}) ⇒ CookieBannerComponent

Returns a new instance of CookieBannerComponent.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/components/govuk_component/cookie_banner_component.rb', line 7

def initialize(
  aria_label: config.default_cookie_banner_aria_label,
  hidden: false,
  hide_in_print: config.default_cookie_banner_hide_in_print,
  classes: [],
  html_attributes: {}
)
  @aria_label    = aria_label
  @hidden        = hidden
  @hide_in_print = hide_in_print

  super(classes:, html_attributes:)
end

Instance Attribute Details

#aria_labelObject

Returns the value of attribute aria_label.



5
6
7
# File 'app/components/govuk_component/cookie_banner_component.rb', line 5

def aria_label
  @aria_label
end

#hiddenObject

Returns the value of attribute hidden.



5
6
7
# File 'app/components/govuk_component/cookie_banner_component.rb', line 5

def hidden
  @hidden
end

#hide_in_printObject

Returns the value of attribute hide_in_print.



5
6
7
# File 'app/components/govuk_component/cookie_banner_component.rb', line 5

def hide_in_print
  @hide_in_print
end

Instance Method Details

#callObject



21
22
23
24
25
# File 'app/components/govuk_component/cookie_banner_component.rb', line 21

def call
  tag.div(role: "region", aria: { label: aria_label }, data: { nosnippet: true }, hidden:, **html_attributes) do
    safe_join(messages)
  end
end