Class: Bulmacomp::MessageComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Bulmacomp::MessageComponent
- Defined in:
- app/components/bulmacomp/message_component.rb
Overview
Make an html structure for a bulma message
Instance Method Summary collapse
-
#call ⇒ Object
return [String] generated bulma message.
-
#header ⇒ Object
return [String] div.message-header if @title or @close is present.
-
#initialize(title: nil, close: false, close_option: {}, **opts) {|optional| ... } ⇒ MessageComponent
constructor
A new instance of MessageComponent.
Constructor Details
#initialize(title: nil, close: false, close_option: {}, **opts) {|optional| ... } ⇒ MessageComponent
Returns a new instance of MessageComponent.
42 43 44 45 46 47 48 |
# File 'app/components/bulmacomp/message_component.rb', line 42 def initialize(title: nil, close: false, close_option: {}, **opts) super @title = title @close = close @close_option = close_option @opts = { class: 'message' }.merge opts end |
Instance Method Details
#call ⇒ Object
return [String] generated bulma message
51 52 53 |
# File 'app/components/bulmacomp/message_component.rb', line 51 def call tag.article safe_join([header, tag.div(content, class: 'message-body')]), **@opts end |
#header ⇒ Object
return [String] div.message-header if @title or @close is present
56 57 58 59 60 61 |
# File 'app/components/bulmacomp/message_component.rb', line 56 def header ret = [] ret << tag.p(@title) if @title.present? ret << tag.(**{ class: 'delete', aria: { label: 'delete' } }.merge(@close_option)) if @close tag.div safe_join(ret), class: 'message-header' if ret.present? end |