Class: GovukComponent::NotificationBannerComponent

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

Defined Under Namespace

Classes: Heading

Instance Attribute Summary collapse

Attributes inherited from Base

#html_attributes

Attributes included from Traits::CustomHtmlAttributes

#html_attributes

Instance Method Summary collapse

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

#combine_classes

Constructor Details

#initialize(title_text: nil, text: nil, role: nil, success: false, title_heading_level: 2, title_id: "govuk-notification-banner-title", disable_auto_focus: nil, classes: [], html_attributes: {}) ⇒ NotificationBannerComponent

Returns a new instance of NotificationBannerComponent.



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

def initialize(title_text: nil, text: nil, role: nil, success: false, title_heading_level: 2, title_id: "govuk-notification-banner-title", disable_auto_focus: nil, classes: [], html_attributes: {})
  super(classes: classes, html_attributes: html_attributes)

  @title_text          = title_text
  @title_id            = title_id
  @text                = text
  @success             = success
  @role                = role || default_role
  @title_heading_level = title_heading_level
  @disable_auto_focus  = disable_auto_focus
end

Instance Attribute Details

#disable_auto_focusObject (readonly)

Returns the value of attribute disable_auto_focus.



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

def disable_auto_focus
  @disable_auto_focus
end

#roleObject (readonly)

Returns the value of attribute role.



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

def role
  @role
end

#successObject (readonly)

Returns the value of attribute success.



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

def success
  @success
end

#textObject (readonly)

Returns the value of attribute text.



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

def text
  @text
end

#title_heading_levelObject (readonly)

Returns the value of attribute title_heading_level.



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

def title_heading_level
  @title_heading_level
end

#title_idObject (readonly)

Returns the value of attribute title_id.



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

def title_id
  @title_id
end

#title_textObject (readonly)

Returns the value of attribute title_text.



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

def title_text
  @title_text
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'app/components/govuk_component/notification_banner_component.rb', line 19

def render?
  headings.any? || text.present? || content.present?
end