Class: PhlexyUI::Drawer

Inherits:
Base
  • Object
show all
Defined in:
lib/phlexy_ui/drawer.rb

Instance Method Summary collapse

Constructor Details

#initialize(id:, as: :section) ⇒ Drawer

Returns a new instance of Drawer.



5
6
7
8
9
# File 'lib/phlexy_ui/drawer.rb', line 5

def initialize(*, id:, as: :section, **)
  super(*, **)
  @as = as
  @id = id
end

Instance Method Details

#buttonObject



58
59
60
# File 'lib/phlexy_ui/drawer.rb', line 58

def button(*, **, &)
  render Button.new(*, as: :label, for: id, **, &)
end

#content(as: :div, **options) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/phlexy_ui/drawer.rb', line 31

def content(as: :div, **options, &)
  generate_classes!(
    component_html_class: :"drawer-content",
    options:
  ).then do |classes|
    public_send(as, class: classes, **options, &)
  end
end

#overlay(**options) ⇒ Object



49
50
51
52
53
54
55
56
# File 'lib/phlexy_ui/drawer.rb', line 49

def overlay(**options, &)
  generate_classes!(
    component_html_class: :"drawer-overlay",
    options:
  ).then do |classes|
    label(for: id, class: classes, **options, &)
  end
end

#side(as: :div, **options) ⇒ Object



40
41
42
43
44
45
46
47
# File 'lib/phlexy_ui/drawer.rb', line 40

def side(as: :div, **options, &)
  generate_classes!(
    component_html_class: :"drawer-side",
    options:
  ).then do |classes|
    public_send(as, class: classes, **options, &)
  end
end

#toggle(**options) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/phlexy_ui/drawer.rb', line 22

def toggle(**options, &)
  generate_classes!(
    component_html_class: :"drawer-toggle",
    options:
  ).then do |classes|
    input(id:, type: :checkbox, class: classes, **options, &)
  end
end

#view_templateObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/phlexy_ui/drawer.rb', line 11

def view_template(&)
  generate_classes!(
    component_html_class: :drawer,
    modifiers_map: modifiers,
    base_modifiers:,
    options:
  ).then do |classes|
    public_send(as, class: classes, **options, &)
  end
end