Class: BetterUi::General::Dropdown::DividerComponent

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

Constant Summary collapse

"border-t border-gray-100 my-1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(classes: nil, **html_options) ⇒ DividerComponent

Returns a new instance of DividerComponent.



12
13
14
15
# File 'app/components/better_ui/general/dropdown/divider_component.rb', line 12

def initialize(classes: nil, **html_options)
  @classes = classes
  @html_options = html_options
end

Instance Attribute Details

#classesObject (readonly)

Returns the value of attribute classes.



7
8
9
# File 'app/components/better_ui/general/dropdown/divider_component.rb', line 7

def classes
  @classes
end

#html_optionsObject (readonly)

Returns the value of attribute html_options.



7
8
9
# File 'app/components/better_ui/general/dropdown/divider_component.rb', line 7

def html_options
  @html_options
end

Instance Method Details

#divider_attributesObject

Restituisce gli attributi per il divisore



26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/components/better_ui/general/dropdown/divider_component.rb', line 26

def divider_attributes
  attrs = {
    class: divider_classes,
    role: "separator"
  }

  @html_options.except(:class).each do |key, value|
    attrs[key] = value
  end

  attrs
end

#divider_classesObject

Combina tutte le classi per il divisore



18
19
20
21
22
23
# File 'app/components/better_ui/general/dropdown/divider_component.rb', line 18

def divider_classes
  [
    DROPDOWN_DIVIDER_CLASSES,
    @classes
  ].compact.join(" ")
end