Class: PhlexKit::SheetContent

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/sheet/sheet_content.rb

Constant Summary collapse

SIDES =
{ top: "top", right: "right", bottom: "bottom", left: "left" }.freeze

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(side: :right, **attrs) ⇒ SheetContent

Returns a new instance of SheetContent.



4
5
6
7
# File 'app/components/phlex_kit/sheet/sheet_content.rb', line 4

def initialize(side: :right, **attrs)
  @side = side.to_sym
  @attrs = attrs
end

Instance Method Details

#view_template(&block) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/components/phlex_kit/sheet/sheet_content.rb', line 8

def view_template(&block)
  template(data: { phlex_kit__sheet_target: "content" }) do
    div(data: { controller: "phlex-kit--sheet-content" }) do
      div(class: "pk-sheet-backdrop", data: { action: "click->phlex-kit--sheet-content#close" })
      div(**mix({ class: ["pk-sheet-content", SIDES.fetch(@side)].join(" ") }, @attrs)) do
        block&.call
        button(type: "button", class: "pk-overlay-close", data: { action: "click->phlex-kit--sheet-content#close" }) do
          render Icon.new(:x, size: 15)
          span(class: "pk-sr-only") { "Close" }
        end
      end
    end
  end
end