Class: Panda::Core::Admin::SlideoverComponent

Inherits:
Base
  • Object
show all
Defined in:
app/components/panda/core/admin/slideover_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

#view_template(&block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'app/components/panda/core/admin/slideover_component.rb', line 10

def view_template(&block)
  # Capture block content
  if block_given?
    if defined?(view_context) && view_context
      @content_html = view_context.capture(&block)
    else
      @content_block = block
    end
  end

  div(
    **default_attrs,
    data: {
      toggle_target: "toggleable",
      transition_enter: "transform transition ease-in-out duration-500",
      transition_enter_from: "translate-x-full",
      transition_enter_to: "translate-x-0",
      transition_leave: "transform transition ease-in-out duration-500",
      transition_leave_from: "translate-x-0",
      transition_leave_to: "translate-x-full"
    }
  ) do
    # Header with title and close button
    div(class: "py-3 px-4 mb-4 bg-black") do
      div(class: "flex justify-between items-center") do
        h2(class: "text-base font-semibold leading-6 text-white", id: "slideover-title") do
          i(class: "mr-2 fa-light fa-gear")
          plain " #{@title}"
        end
        button(
          type: "button",
          data: {action: "click->toggle#toggle touch->toggle#toggle"},
          class: "text-white hover:text-gray-300 transition"
        ) do
          i(class: "font-bold fa-regular fa-xmark right")
        end
      end
    end

    # Content area
    div(class: "overflow-y-auto px-4 pb-6 space-y-6") do
      if @content_html
        raw(@content_html)
      elsif @content_block
        instance_eval(&@content_block)
      end
    end
  end
end