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, classes: [], html_attributes: {}) ⇒ CookieBannerComponent

Returns a new instance of CookieBannerComponent.



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

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

  @aria_label = aria_label
  @hidden     = hidden
end

Instance Attribute Details

#aria_labelObject

Returns the value of attribute aria_label.



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

def aria_label
  @aria_label
end

#hiddenObject

Returns the value of attribute hidden.



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

def hidden
  @hidden
end

Instance Method Details

#callObject



13
14
15
16
17
# File 'app/components/govuk_component/cookie_banner_component.rb', line 13

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