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.

Parameters:

  • size (String) (defaults to: DEFAULT_SIZE)

    the size option

  • fade (Boolean) (defaults to: true)

    the fade option

  • dialog_class (Object, nil) (defaults to: nil)

    the dialog class option

  • html_attributes (Hash)

    additional HTML attributes applied to the rendered element

Options Hash (**html_attributes):

  • :class (String)

    additional CSS classes, merged with the component's own classes



18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/components/railsboot/modal_component.rb', line 18

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