Class: IronAdmin::Ui::ModalComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/iron_admin/ui/modal_component.rb

Overview

Renders a modal dialog overlay.

Examples:

Basic modal

render IronAdmin::Ui::ModalComponent.new do |modal|
  modal.with_title { "Confirm Action" }
  "Are you sure?"
  modal.with_footer { render ButtonComponent.new(text: "Confirm") }
end

Constant Summary collapse

SIZES =

Size class mappings.

Returns:

  • (Hash{Symbol => String})
{
  sm: "max-w-md",
  md: "max-w-lg",
  lg: "max-w-2xl",
  xl: "max-w-4xl",
  full: "max-w-full mx-4",
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size: :md, dismissible: true) ⇒ ModalComponent

Returns a new instance of ModalComponent.

Parameters:

  • size (Symbol) (defaults to: :md)

    Modal size (default: :md)

  • dismissible (Boolean) (defaults to: true)

    Can be dismissed (default: true)



35
36
37
38
# File 'app/components/iron_admin/ui/modal_component.rb', line 35

def initialize(size: :md, dismissible: true)
  @size = size.to_sym
  @dismissible = dismissible
end

Instance Attribute Details

#dismissibleBoolean (readonly)

Returns Whether modal can be dismissed.

Returns:

  • (Boolean)

    Whether modal can be dismissed



21
22
23
# File 'app/components/iron_admin/ui/modal_component.rb', line 21

def dismissible
  @dismissible
end

#sizeSymbol (readonly)

Returns Modal size (:sm, :md, :lg, :xl, :full).

Returns:

  • (Symbol)

    Modal size (:sm, :md, :lg, :xl, :full)



18
19
20
# File 'app/components/iron_admin/ui/modal_component.rb', line 18

def size
  @size
end

Instance Method Details

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns CSS classes for modal container.

Returns:

  • (String)

    CSS classes for modal container



54
55
56
# File 'app/components/iron_admin/ui/modal_component.rb', line 54

def modal_classes
  "relative #{theme.card_bg} #{theme.border_radius} #{theme.card_shadow}-xl w-full #{size_classes}"
end

#size_classesString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns CSS classes for modal size.

Returns:

  • (String)

    CSS classes for modal size



48
49
50
# File 'app/components/iron_admin/ui/modal_component.rb', line 48

def size_classes
  SIZES[@size] || SIZES[:md]
end

#themeIronAdmin::Configuration::Theme

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Theme configuration.

Returns:



42
43
44
# File 'app/components/iron_admin/ui/modal_component.rb', line 42

def theme
  IronAdmin.configuration.theme
end