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

Attributes included from Traits::CustomHtmlAttributes

#html_attributes

Instance Method Summary collapse

Methods included from Traits::CustomClasses

#classes

Methods included from Govuk::Components::Helpers::CssUtilities

#combine_classes

Constructor Details

#initialize(aria_label: "Cookie banner", hidden: false, hide_in_print: true, classes: [], html_attributes: {}) ⇒ CookieBannerComponent

Returns a new instance of CookieBannerComponent.



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

def initialize(aria_label: "Cookie banner", hidden: false, hide_in_print: true, classes: [], html_attributes: {})
  super(classes: classes, html_attributes: html_attributes)

  @aria_label    = aria_label
  @hidden        = hidden
  @hide_in_print = hide_in_print
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



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

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