Class: Railsboot::ModalComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/railsboot/modal_component.rb

Overview

ViewComponent: renders the modal block.

Constant Summary collapse

SIZES =

Sizes.

["", "xl", "lg", "sm"].freeze
DEFAULT_SIZE =

Default size.

"".freeze

Instance Method Summary collapse

Constructor Details

#initialize(size: DEFAULT_SIZE, fade: true, dialog_class: nil, **html_attributes) ⇒ ModalComponent

Returns a new instance of ModalComponent.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/components/railsboot/modal_component.rb', line 13

def initialize(size: DEFAULT_SIZE, fade: true, dialog_class: nil, **html_attributes)
  @size = fetch_or_fallback(size, SIZES, DEFAULT_SIZE)
  @fade = fade
  @dialog_class = dialog_class
  @html_attributes = html_attributes.dup

  @html_attributes[:class] = class_names(
    "modal",
    { "fade" => @fade.present? },
    @html_attributes.delete(:class)
  )
end