Class: Panda::Core::Admin::ButtonComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/button_component.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#after_template, #attrs, #before_template, #merge_attrs, #tailwind_merge_attrs

Instance Method Details

#default_attrsObject



27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/components/panda/core/admin/button_component.rb', line 27

def default_attrs
  base = {
    class: button_classes,
    id: @id
  }

  if @as_button
    base.merge(type: "button")
  else
    base.merge(href: @href)
  end
end

#view_templateObject



15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/panda/core/admin/button_component.rb', line 15

def view_template
  if @as_button
    button(**@attrs) do
      render_content
    end
  else
    a(**@attrs) do
      render_content
    end
  end
end