Class: Bs5::ToastComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bs5::ToastComponent
- Includes:
- ComponentsHelper, ViewComponent::SlotableV2
- Defined in:
- app/components/bs5/toast_component.rb
Constant Summary
Constants included from ComponentsHelper
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
Instance Method Summary collapse
- #component_attributes ⇒ Object
- #header? ⇒ Boolean
-
#initialize(options = {}) ⇒ ToastComponent
constructor
A new instance of ToastComponent.
- #white_text? ⇒ Boolean
Methods included from ComponentsHelper
#bs5_collapse, #bs5_popover, #bs5_tooltip
Constructor Details
#initialize(options = {}) ⇒ ToastComponent
Returns a new instance of ToastComponent.
14 15 16 17 18 19 |
# File 'app/components/bs5/toast_component.rb', line 14 def initialize( = {}) = .symbolize_keys @color = .delete(:color) = .fetch(:close_button, true) = .extract!(:animation, :autohide, :delay) end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
9 10 11 |
# File 'app/components/bs5/toast_component.rb', line 9 def color @color end |
Instance Method Details
#component_attributes ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/components/bs5/toast_component.rb', line 25 def component_attributes = { role: :alert, aria: { live: 'assertive', atomic: true }, data: } [:class] = component_class .merge() end |
#header? ⇒ Boolean
21 22 23 |
# File 'app/components/bs5/toast_component.rb', line 21 def header? !!header end |
#white_text? ⇒ Boolean
37 38 39 |
# File 'app/components/bs5/toast_component.rb', line 37 def white_text? color? && color.in?(i[primary secondary success danger dark]) end |