Class: Primrose::Components::Modal
- Defined in:
- lib/primrose/components/modal.rb
Constant Summary collapse
- TEMPLATE =
<<~ERB <% if @is_open %> <label for="modal-<%= @name %>"><%= @label %></label> <div class="modal <%= @style_class %>"> <div class="modal-content"> <%= @content %> </div> </div> <% end %> ERB
Instance Attribute Summary
Attributes inherited from Rose
#children, #event_handlers, #state
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(content:, is_open: false, name: nil, label: nil, style_class: nil) ⇒ Modal
constructor
A new instance of Modal.
- #open ⇒ Object
- #render ⇒ Object
Methods inherited from Rose
#add_child, #get_binding, #handle_error, #lifecycle, #on, #render_children, #trigger
Constructor Details
#initialize(content:, is_open: false, name: nil, label: nil, style_class: nil) ⇒ Modal
Returns a new instance of Modal.
17 18 19 20 21 22 23 24 |
# File 'lib/primrose/components/modal.rb', line 17 def initialize(content:, is_open: false, name: nil, label: nil, style_class: nil) @content = content @is_open = is_open @name = name @label = label @style_class = style_class super() end |
Instance Method Details
#close ⇒ Object
34 35 36 |
# File 'lib/primrose/components/modal.rb', line 34 def close @is_open = false end |
#open ⇒ Object
30 31 32 |
# File 'lib/primrose/components/modal.rb', line 30 def open @is_open = true end |