Class: Bulmacomp::ModalComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/bulmacomp/modal_component.rb

Overview

Make an html structure for a bulma breadcrumb

Examples:

Empty modal:

= render Bulmacomp::PanelComponent.new()

<div class="modal">
  <div class="modal-background"></div>
  <div class="modal-content"></div>
  <button class="modal-close is-large" aria-label="close"></button>
</div>

Modal with content:

= render Bulmacomp::PanelComponent.new() do
  %p some content

<div class="modal">
  <div class="modal-background"></div>
  <div class="modal-content"><p>Some content</p></div>
  <button class="modal-close is-large" aria-label="close"></button>
</div>

Instance Method Summary collapse

Constructor Details

#initialize(**opts) {|optional| ... } ⇒ ModalComponent

Returns a new instance of ModalComponent.

Parameters:

  • opts (Hash)

    options to generate content

Options Hash (**opts):

  • :* (String)

    each key going as tag option, default is class: ‘modal’

Yields:

  • (optional)

    modal content



28
29
30
31
# File 'app/components/bulmacomp/modal_component.rb', line 28

def initialize(**opts)
  super
  @opts = { class: 'modal' }.merge opts
end

Instance Method Details

#callObject

return [String] html_safe generated bulma modal



34
35
36
37
38
39
40
# File 'app/components/bulmacomp/modal_component.rb', line 34

def call
   :div, safe_join([
                                tag.div(class: 'modal-background'),
                                tag.div(content, class: 'modal-content'),
                                tag.button(class: 'modal-close is-large', aria_label: 'close')
                              ]), **@opts
end