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.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Attributes inherited from Base
Instance Method Summary collapse
- #call ⇒ Object
- #default_attributes ⇒ Object
-
#initialize(text: nil, link_text: nil, link_href: nil, tag: 'p', classes: [], html_attributes: {}) ⇒ Heading
constructor
A new instance of Heading.
- #link ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(text: nil, link_text: nil, link_href: nil, tag: 'p', classes: [], html_attributes: {}) ⇒ Heading
Returns a new instance of Heading.
36 37 38 39 40 41 42 43 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 36 def initialize(text: nil, link_text: nil, link_href: nil, tag: 'p', classes: [], html_attributes: {}) @text = text @link_text = link_text @link_href = link_href @tag = tag super(classes:, html_attributes:) end |
Instance Attribute Details
#link_href ⇒ Object (readonly)
Returns the value of attribute link_href.
34 35 36 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 34 def link_href @link_href end |
#link_text ⇒ Object (readonly)
Returns the value of attribute link_text.
34 35 36 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 34 def link_text @link_text end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
34 35 36 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 34 def tag @tag end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
34 35 36 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 34 def text @text end |
Instance Method Details
#call ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 45 def call content_tag(tag, **html_attributes) do if text.present? safe_join([text, link].compact, " ") else content end end end |
#default_attributes ⇒ Object
59 60 61 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 59 def default_attributes { class: ["#{brand}-notification-banner__heading"] } end |
#link ⇒ Object
55 56 57 |
# File 'app/components/govuk_component/notification_banner_component.rb', line 55 def link link_to(link_text, link_href, class: "#{brand}-notification-banner__link") if link_text.present? && link_href.present? end |