Class: BetterUi::General::Modal::Component

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/better_ui/general/modal/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(close_on_backdrop: true, close_on_escape: true, lock_scroll: true, classes: nil, **html_options) ⇒ Component

Inizializzazione del wrapper component



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/components/better_ui/general/modal/component.rb', line 13

def initialize(
  close_on_backdrop: true,
  close_on_escape: true,
  lock_scroll: true,
  classes: nil,
  **html_options
)
  @close_on_backdrop = close_on_backdrop
  @close_on_escape = close_on_escape
  @lock_scroll = lock_scroll
  @classes = classes
  @html_options = html_options
end

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes.



8
9
10
# File 'app/components/better_ui/general/modal/component.rb', line 8

def classes
  @classes
end

#close_on_backdropObject (readonly)

Returns the value of attribute close_on_backdrop.



8
9
10
# File 'app/components/better_ui/general/modal/component.rb', line 8

def close_on_backdrop
  @close_on_backdrop
end

#close_on_escapeObject (readonly)

Returns the value of attribute close_on_escape.



8
9
10
# File 'app/components/better_ui/general/modal/component.rb', line 8

def close_on_escape
  @close_on_escape
end

#html_optionsObject (readonly)

Returns the value of attribute html_options.



8
9
10
# File 'app/components/better_ui/general/modal/component.rb', line 8

def html_options
  @html_options
end

#lock_scrollObject (readonly)

Returns the value of attribute lock_scroll.



8
9
10
# File 'app/components/better_ui/general/modal/component.rb', line 8

def lock_scroll
  @lock_scroll
end

Instance Method Details

#wrapper_attributesObject

Restituisce gli attributi per il wrapper principale (con controller Stimulus)



33
34
35
36
37
38
39
40
41
# File 'app/components/better_ui/general/modal/component.rb', line 33

def wrapper_attributes
  {
    class: wrapper_classes,
    'data-controller': 'bui-modal',
    'data-bui-modal-close-on-backdrop-value': close_on_backdrop,
    'data-bui-modal-close-on-escape-value': close_on_escape,
    'data-bui-modal-lock-scroll-value': lock_scroll
  }.merge(@html_options.except(:class))
end

#wrapper_classesObject

Combina tutte le classi per il wrapper



28
29
30
# File 'app/components/better_ui/general/modal/component.rb', line 28

def wrapper_classes
  [@classes, @html_options[:class]].compact.join(" ")
end