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

Instance Method Summary collapse

Methods inherited from Base

#brand, #class_prefix

Constructor Details

#initialize(title_text: nil, text: nil, role: nil, success: config.default_notification_title_success, title_heading_level: config.default_notification_title_heading_level, title_id: config.default_notification_banner_title_id, disable_auto_focus: config.default_notification_disable_auto_focus, classes: [], html_attributes: {}) ⇒ NotificationBannerComponent

Returns a new instance of NotificationBannerComponent.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/components/govuk_component/notification_banner_component.rb', line 7

def initialize(
  title_text: nil,
  text: nil,
  role: nil,
  success: config.default_notification_title_success,
  title_heading_level: config.default_notification_title_heading_level,
  title_id: config.default_notification_banner_title_id,
  disable_auto_focus: config.default_notification_disable_auto_focus,
  classes: [],
  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

  super(classes:, html_attributes:)
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)


29
30
31
# File 'app/components/govuk_component/notification_banner_component.rb', line 29

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