Class: Maglev::Uikit::ModalComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/maglev/uikit/modal_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BaseComponent

#button_class_names

Constructor Details

#initialize(id:, open: false, focus: true, size: 'default') ⇒ ModalComponent

Returns a new instance of ModalComponent.



12
13
14
15
16
17
# File 'app/components/maglev/uikit/modal_component.rb', line 12

def initialize(id:, open: false, focus: true, size: 'default')
  @id = id
  @open = open
  @focus = focus
  @size = size
end

Instance Attribute Details

#focusObject (readonly)

Returns the value of attribute focus.



10
11
12
# File 'app/components/maglev/uikit/modal_component.rb', line 10

def focus
  @focus
end

#idObject (readonly)

Returns the value of attribute id.



10
11
12
# File 'app/components/maglev/uikit/modal_component.rb', line 10

def id
  @id
end

#openObject (readonly)

Returns the value of attribute open.



10
11
12
# File 'app/components/maglev/uikit/modal_component.rb', line 10

def open
  @open
end

Instance Method Details

#dialog_classesObject



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

def dialog_classes
  class_variants(
    base: %(
      relative transform overflow-y-visible rounded-lg bg-white px-4 pb-4 pt-5 text-left
      shadow-xl transition-all sm:my-8 sm:p-6 hidden
    ),
    variants: {
      size: { small: 'w-full sm:max-w-xl sm:min-w-96 sm:w-auto' }
    },
    defaults: { size: :default }
  ).render(size: @size)
end