Class: SdrViewComponents::Elements::BannerComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::Elements::BannerComponent
- Defined in:
- app/components/sdr_view_components/elements/banner_component.rb
Overview
Banner component for displaying messages, welcomes, etc.
Constant Summary collapse
- ICONS =
{ note: 'bi bi-exclamation-circle-fill', success: 'bi bi-check-circle-fill', warning: 'bi bi-exclamation-triangle-fill', info: 'bi bi-info-circle-fill', danger: 'bi bi-exclamation-triangle-fill' }.freeze
Instance Attribute Summary collapse
-
#aria_label ⇒ Object
readonly
Returns the value of attribute aria_label.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#variant ⇒ Object
readonly
Returns the value of attribute variant.
Instance Method Summary collapse
- #classes ⇒ Object
- #icon_classes ⇒ Object
-
#initialize(title: nil, variant: :note, classes: [], role: 'banner', aria_label: nil) ⇒ BannerComponent
constructor
A new instance of BannerComponent.
Methods inherited from BaseComponent
#args_for, #merge_actions, #merge_classes
Constructor Details
#initialize(title: nil, variant: :note, classes: [], role: 'banner', aria_label: nil) ⇒ BannerComponent
Returns a new instance of BannerComponent.
18 19 20 21 22 23 24 25 26 27 |
# File 'app/components/sdr_view_components/elements/banner_component.rb', line 18 def initialize(title: nil, variant: :note, classes: [], role: 'banner', aria_label: nil) @title = title @variant = variant.to_sym @classes = classes @role = role @aria_label = aria_label raise ArgumentError, "Unknown variant: #{variant}" unless ICONS.key?(variant) super() end |
Instance Attribute Details
#aria_label ⇒ Object (readonly)
Returns the value of attribute aria_label.
29 30 31 |
# File 'app/components/sdr_view_components/elements/banner_component.rb', line 29 def aria_label @aria_label end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
29 30 31 |
# File 'app/components/sdr_view_components/elements/banner_component.rb', line 29 def role @role end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
29 30 31 |
# File 'app/components/sdr_view_components/elements/banner_component.rb', line 29 def title @title end |
#variant ⇒ Object (readonly)
Returns the value of attribute variant.
29 30 31 |
# File 'app/components/sdr_view_components/elements/banner_component.rb', line 29 def variant @variant end |
Instance Method Details
#classes ⇒ Object
35 36 37 38 |
# File 'app/components/sdr_view_components/elements/banner_component.rb', line 35 def classes merge_classes('alert banner d-flex shadow-sm align-items-center p-3 mb-3 border-start', "alert-#{variant}", @classes) end |
#icon_classes ⇒ Object
31 32 33 |
# File 'app/components/sdr_view_components/elements/banner_component.rb', line 31 def icon_classes merge_classes('fs-3 me-3 align-self-center d-flex justify-content-center', ICONS[variant]) end |