Class: GovukComponent::NotificationBanner
- Includes:
- ViewComponent::Slotable
- Defined in:
- app/components/govuk_component/notification_banner.rb
Defined Under Namespace
Classes: Heading
Instance Attribute Summary collapse
-
#disable_auto_focus ⇒ Object
readonly
Returns the value of attribute disable_auto_focus.
-
#success ⇒ Object
readonly
Returns the value of attribute success.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#title_heading_level ⇒ Object
readonly
Returns the value of attribute title_heading_level.
-
#title_id ⇒ Object
readonly
Returns the value of attribute title_id.
Attributes included from Traits::CustomHtmlAttributes
Instance Method Summary collapse
-
#initialize(title:, success: false, title_heading_level: 2, title_id: "govuk-notification-banner-title", disable_auto_focus: nil, classes: [], html_attributes: {}) ⇒ NotificationBanner
constructor
A new instance of NotificationBanner.
- #render? ⇒ Boolean
- #success? ⇒ Boolean
- #success_class ⇒ Object
- #title_tag ⇒ Object
Methods inherited from Base
Methods included from Traits::CustomClasses
Constructor Details
#initialize(title:, success: false, title_heading_level: 2, title_id: "govuk-notification-banner-title", disable_auto_focus: nil, classes: [], html_attributes: {}) ⇒ NotificationBanner
Returns a new instance of NotificationBanner.
8 9 10 11 12 13 14 15 16 |
# File 'app/components/govuk_component/notification_banner.rb', line 8 def initialize(title:, 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 = title @title_id = title_id @success = success @title_heading_level = title_heading_level @disable_auto_focus = disable_auto_focus end |
Instance Attribute Details
#disable_auto_focus ⇒ Object (readonly)
Returns the value of attribute disable_auto_focus.
2 3 4 |
# File 'app/components/govuk_component/notification_banner.rb', line 2 def disable_auto_focus @disable_auto_focus end |
#success ⇒ Object (readonly)
Returns the value of attribute success.
2 3 4 |
# File 'app/components/govuk_component/notification_banner.rb', line 2 def success @success end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
2 3 4 |
# File 'app/components/govuk_component/notification_banner.rb', line 2 def title @title end |
#title_heading_level ⇒ Object (readonly)
Returns the value of attribute title_heading_level.
2 3 4 |
# File 'app/components/govuk_component/notification_banner.rb', line 2 def title_heading_level @title_heading_level end |
#title_id ⇒ Object (readonly)
Returns the value of attribute title_id.
2 3 4 |
# File 'app/components/govuk_component/notification_banner.rb', line 2 def title_id @title_id end |
Instance Method Details
#render? ⇒ Boolean
26 27 28 |
# File 'app/components/govuk_component/notification_banner.rb', line 26 def render? headings.any? end |
#success? ⇒ Boolean
22 23 24 |
# File 'app/components/govuk_component/notification_banner.rb', line 22 def success? @success end |
#success_class ⇒ Object
18 19 20 |
# File 'app/components/govuk_component/notification_banner.rb', line 18 def success_class %(govuk-notification-banner--success) if success? end |
#title_tag ⇒ Object
30 31 32 33 34 |
# File 'app/components/govuk_component/notification_banner.rb', line 30 def title_tag fail "title_heading_level must be a number between 1 and 6" unless title_heading_level.is_a?(Integer) && title_heading_level.in?(1..6) "h#{title_heading_level}" end |