Class: ElementComponent::Components::Modal
- Defined in:
- lib/element_component/components/modal.rb
Constant Summary collapse
- VALID_SIZES =
%i[sm lg xl].freeze
- VALID_FULLSCREEN =
%i[always sm md lg xl xxl].freeze
Instance Attribute Summary
Attributes inherited from Element
#attributes, #contents, #element, #html
Instance Method Summary collapse
-
#initialize(fade: true, static: false, scrollable: false, centered: false, size: nil, fullscreen: nil, **attributes, &block) ⇒ Modal
constructor
A new instance of Modal.
Methods inherited from Element
#add_attribute, #add_attribute!, #add_content, #add_content!, #new_element, #remove_attribute, #remove_attribute_value, #render, #reset_attributes!, #reset_contents!
Constructor Details
#initialize(fade: true, static: false, scrollable: false, centered: false, size: nil, fullscreen: nil, **attributes, &block) ⇒ Modal
Returns a new instance of Modal.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/element_component/components/modal.rb', line 16 def initialize(fade: true, static: false, scrollable: false, centered: false, size: nil, fullscreen: nil, **attributes, &block) super("div", &block) add_attribute(class: "modal") add_attribute(class: "fade") if fade add_attribute(tabindex: "-1") add_attribute("aria-hidden": "true") add_attribute("data-bs-backdrop": "static") if static add_attribute("data-bs-keyboard": "false") if static add_content(ModalDialog.new(scrollable: scrollable, centered: centered, size: size, fullscreen: fullscreen)) add_attribute(attributes) unless attributes.empty? end |