Class: Panda::Core::Admin::HeadingComponent

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

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

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

Instance Method Details

#button(**props) ⇒ Object



30
31
32
33
# File 'app/components/panda/core/admin/heading_component.rb', line 30

def button(**props)
  @buttons ||= []
  @buttons << Panda::Core::Admin::ButtonComponent.new(**props)
end

#view_template(&block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/panda/core/admin/heading_component.rb', line 12

def view_template(&block)
  # Capture any buttons defined via block
  instance_eval(&block) if block_given?

  case @level
  when 1
    h1(class: heading_classes) { render_content }
  when 2
    h2(class: heading_classes) { render_content }
  when 3
    h3(class: heading_classes) { render_content }
  when :panel
    h3(class: panel_heading_classes) { @text }
  else
    h2(class: heading_classes) { render_content }
  end
end