Class: Railsboot::ModalComponent

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

Constant Summary collapse

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

Constants inherited from Component

Component::COLORS, Component::DEFAULT_COLOR

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ModalComponent.



9
10
11
12
13
14
15
16
17
18
19
# File 'app/components/railsboot/modal_component.rb', line 9

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

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