Class: IronAdmin::Ui::ModalComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Ui::ModalComponent
- Defined in:
- app/components/iron_admin/ui/modal_component.rb
Overview
Renders a modal dialog overlay.
Constant Summary collapse
- SIZES =
Size class mappings.
{ 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
-
#dismissible ⇒ Boolean
readonly
Whether modal can be dismissed.
-
#size ⇒ Symbol
readonly
Modal size (:sm, :md, :lg, :xl, :full).
Instance Method Summary collapse
-
#initialize(size: :md, dismissible: true) ⇒ ModalComponent
constructor
A new instance of ModalComponent.
-
#modal_classes ⇒ String
private
CSS classes for modal container.
-
#size_classes ⇒ String
private
CSS classes for modal size.
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
Constructor Details
#initialize(size: :md, dismissible: true) ⇒ ModalComponent
Returns a new instance of ModalComponent.
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
#dismissible ⇒ Boolean (readonly)
Returns Whether modal can be dismissed.
21 22 23 |
# File 'app/components/iron_admin/ui/modal_component.rb', line 21 def dismissible @dismissible end |
#size ⇒ Symbol (readonly)
Returns 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
#modal_classes ⇒ String
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.
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_classes ⇒ String
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.
48 49 50 |
# File 'app/components/iron_admin/ui/modal_component.rb', line 48 def size_classes SIZES[@size] || SIZES[:md] end |
#theme ⇒ IronAdmin::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.
42 43 44 |
# File 'app/components/iron_admin/ui/modal_component.rb', line 42 def theme IronAdmin.configuration.theme end |