Class: GovukComponent::NotificationBannerComponent::Heading
- Inherits:
-
Base
- Object
- ViewComponent::Base
- Base
- GovukComponent::NotificationBannerComponent::Heading
- Defined in:
- app/components/govuk_component/notification_banner_component.rb
Instance Attribute Summary collapse
-
#link_href ⇒ Object
readonly
Returns the value of attribute link_href.
-
#link_text ⇒ Object
readonly
Returns the value of attribute link_text.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Base
Attributes included from Traits::CustomHtmlAttributes
Instance Method Summary collapse
- #call ⇒ Object
- #default_classes ⇒ Object
-
#initialize(text: nil, link_text: nil, link_href: nil, classes: [], html_attributes: {}) ⇒ Heading
constructor
A new instance of Heading.
- #link ⇒ Object
Methods included from Traits::CustomClasses
Methods included from Govuk::Components::Helpers::CssUtilities
Constructor Details
#initialize(text: nil, link_text: nil, link_href: nil, classes: [], html_attributes: {}) ⇒ Heading
Returns a new instance of Heading.
26 27 28 29 30 31 32 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 26 def initialize(text: nil, link_text: nil, link_href: nil, classes: [], html_attributes: {}) super(classes: classes, html_attributes: html_attributes) @text = text @link_text = link_text @link_href = link_href end |
Instance Attribute Details
#link_href ⇒ Object (readonly)
Returns the value of attribute link_href.
24 25 26 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 24 def link_href @link_href end |
#link_text ⇒ Object (readonly)
Returns the value of attribute link_text.
24 25 26 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 24 def link_text @link_text end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
24 25 26 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 24 def text @text end |
Instance Method Details
#call ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 34 def call tag.div(class: classes, **html_attributes) do if text.present? safe_join([text, link].compact, " ") else content end end end |
#default_classes ⇒ Object
48 49 50 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 48 def default_classes %w(govuk-notification-banner__heading) end |
#link ⇒ Object
44 45 46 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 44 def link link_to(link_text, link_href, class: 'govuk-notification-banner__link') if link_text.present? && link_href.present? end |