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
22
23
# 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
          svg(width: "15", height: "15", viewbox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg") do |s|
      s.path(fill_rule: "evenodd", clip_rule: "evenodd", fill: "currentColor", d: "M11.7816 4.03157C12.0062 3.80702 12.0062 3.44295 11.7816 3.2184C11.5571 2.99385 11.193 2.99385 10.9685 3.2184L7.50005 6.68682L4.03164 3.2184C3.80708 2.99385 3.44301 2.99385 3.21846 3.2184C2.99391 3.44295 2.99391 3.80702 3.21846 4.03157L6.68688 7.49999L3.21846 10.9684C2.99391 11.193 2.99391 11.557 3.21846 11.7816C3.44301 12.0061 3.80708 12.0061 4.03164 11.7816L7.50005 8.31316L10.9685 11.7816C11.193 12.0061 11.5571 12.0061 11.7816 11.7816C12.0062 11.557 12.0062 11.193 11.7816 10.9684L8.31322 7.49999L11.7816 4.03157Z")
    end
          span(class: "pk-sr-only") { "Close" }
        end
      end
    end
  end
end