Class: Collavre::PopupMenuComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Collavre::PopupMenuComponent
- Defined in:
- app/components/collavre/popup_menu_component.rb
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#button_attributes ⇒ Object
readonly
Returns the value of attribute button_attributes.
-
#button_classes ⇒ Object
readonly
Returns the value of attribute button_classes.
-
#button_content ⇒ Object
readonly
Returns the value of attribute button_content.
-
#menu_classes ⇒ Object
readonly
Returns the value of attribute menu_classes.
-
#menu_id ⇒ Object
readonly
Returns the value of attribute menu_id.
Instance Method Summary collapse
- #button_options ⇒ Object
-
#initialize(button_content:, button_classes: "", menu_classes: "", menu_id: nil, align: :left, button_attributes: {}) ⇒ PopupMenuComponent
constructor
A new instance of PopupMenuComponent.
Constructor Details
#initialize(button_content:, button_classes: "", menu_classes: "", menu_id: nil, align: :left, button_attributes: {}) ⇒ PopupMenuComponent
Returns a new instance of PopupMenuComponent.
3 4 5 6 7 8 9 10 |
# File 'app/components/collavre/popup_menu_component.rb', line 3 def initialize(button_content:, button_classes: "", menu_classes: "", menu_id: nil, align: :left, button_attributes: {}) @button_content = @button_classes = @menu_classes = @menu_id = || "popup-menu-#{SecureRandom.hex(4)}" @align = align @button_attributes = end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
12 13 14 |
# File 'app/components/collavre/popup_menu_component.rb', line 12 def align @align end |
#button_attributes ⇒ Object (readonly)
Returns the value of attribute button_attributes.
12 13 14 |
# File 'app/components/collavre/popup_menu_component.rb', line 12 def @button_attributes end |
#button_classes ⇒ Object (readonly)
Returns the value of attribute button_classes.
12 13 14 |
# File 'app/components/collavre/popup_menu_component.rb', line 12 def @button_classes end |
#button_content ⇒ Object (readonly)
Returns the value of attribute button_content.
12 13 14 |
# File 'app/components/collavre/popup_menu_component.rb', line 12 def @button_content end |
#menu_classes ⇒ Object (readonly)
Returns the value of attribute menu_classes.
12 13 14 |
# File 'app/components/collavre/popup_menu_component.rb', line 12 def @menu_classes end |
#menu_id ⇒ Object (readonly)
Returns the value of attribute menu_id.
12 13 14 |
# File 'app/components/collavre/popup_menu_component.rb', line 12 def @menu_id end |
Instance Method Details
#button_options ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/components/collavre/popup_menu_component.rb', line 14 def defaults = { type: "button", class: [ "popup-menu-toggle", .presence ].compact.join(" "), data: { action: "click->popup-menu#toggle", popup_menu_target: "button" } } return defaults if .blank? defaults.deep_merge() do |key, this_val, other_val| key == :class ? [ this_val, other_val ].compact.join(" ") : other_val end end |