Class: PhlexyUI::Button

Inherits:
Base
  • Object
show all
Defined in:
lib/phlexy_ui/button.rb

Instance Method Summary collapse

Constructor Details

#initialize(as: :button, modal: nil) ⇒ Button

Returns a new instance of Button.



7
8
9
10
11
# File 'lib/phlexy_ui/button.rb', line 7

def initialize(*, as: :button, modal: nil, **)
  super(*, **)
  @as = as
  @modal = modal
end

Instance Method Details

#view_templateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/phlexy_ui/button.rb', line 13

def view_template(&)
  generate_classes!(
    component_html_class: :btn,
    modifiers_map: modifiers,
    base_modifiers:,
    options:
  ).then do |classes|
    if modal
      public_send(
        as,
        class: classes,
        onclick: safe("#{Phlex::Escape.html_escape(modal)}.showModal()"),
        **options,
        &
      )
    else
      public_send(as, class: classes, **options, &)
    end
  end
end