Class: PhlexKit::DrawerContent
- Inherits:
-
BaseComponent
- Object
- Phlex::HTML
- BaseComponent
- PhlexKit::DrawerContent
- Defined in:
- app/components/phlex_kit/drawer/drawer_content.rb
Overview
holding the drawer overlay + panel (cloned into on open,
like SheetContent). side: picks the attached edge — :bottom (default),
:top, :left or :right, matching shadcn's direction prop. See drawer.rb.
Constant Summary collapse
- SIDES =
{ bottom: "bottom", top: "top", left: "left", right: "right" }.freeze
Instance Method Summary collapse
-
#initialize(side: :bottom, **attrs) ⇒ DrawerContent
constructor
A new instance of DrawerContent.
- #view_template(&block) ⇒ Object
Methods inherited from BaseComponent
Constructor Details
#initialize(side: :bottom, **attrs) ⇒ DrawerContent
Returns a new instance of DrawerContent.
8 9 10 11 |
# File 'app/components/phlex_kit/drawer/drawer_content.rb', line 8 def initialize(side: :bottom, **attrs) @side = side.to_sym @attrs = attrs end |
Instance Method Details
#view_template(&block) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/phlex_kit/drawer/drawer_content.rb', line 13 def view_template(&block) template(data: { phlex_kit__sheet_target: "content" }) do div(data: { controller: "phlex-kit--sheet-content", action: "keydown->phlex-kit--sheet-content#keydown" }) do div(class: "pk-drawer-overlay", data: { action: "click->phlex-kit--sheet-content#close" }) div(**mix({ class: "pk-drawer #{fetch_option(SIDES, @side, :side)}", role: "dialog", aria: { modal: "true" }, tabindex: "-1", data: { phlex_kit__sheet_content_target: "panel" } }, @attrs)) do div(class: "pk-drawer-handle", aria: { hidden: "true" }) yield if block end end end end |