Class: Ui::Drawer

Inherits:
Components::ApplicationComponent
  • Object
show all
Defined in:
app/views/rails_devtools/components/ui/drawer.rb

Instance Method Summary collapse

Constructor Details

#initialize(id:, direction: "left", classes: "") ⇒ Drawer

Returns a new instance of Drawer.



6
7
8
9
10
# File 'app/views/rails_devtools/components/ui/drawer.rb', line 6

def initialize(id:, direction: "left", classes: "")
  @id = id
  @direction = direction
  @classes = classes
end

Instance Method Details

#contentObject



19
20
21
# File 'app/views/rails_devtools/components/ui/drawer.rb', line 19

def content(&)
  div(class: "drawer-content flex flex-col", &)
end

#drawer_side(&block) ⇒ Object



23
24
25
26
27
28
29
30
31
32
# File 'app/views/rails_devtools/components/ui/drawer.rb', line 23

def drawer_side(&block)
  div(class: "drawer-side") do
    label(
      for: @id,
      aria_label: "close sidebar",
      class: "drawer-overlay"
    )
    block.call
  end
end

#view_template(&block) ⇒ Object



12
13
14
15
16
17
# File 'app/views/rails_devtools/components/ui/drawer.rb', line 12

def view_template(&block)
  div(class: drawer_classes, data_controller: "checkbox") do
    input(id: @id, type: "checkbox", class: "drawer-toggle", data_checkbox_target: "checkbox")
    block.call
  end
end