Class: Daisy::Actions::ModalComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::Actions::ModalComponent
- Defined in:
- app/components/daisy/actions/modal_component.rb
Overview
The Modal component renders a modal dialog that can be opened and closed. It provides a structured way to display content that requires user attention or interaction, such as forms, confirmations, or detailed information.
Note that the modal uses the HTML ‘<dialog>` element and its native methods (`showModal()` and `close()`). This provides better accessibility and keyboard navigation compared to div-based modals.
content.
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary collapse
-
#closable ⇒ Boolean
(also: #closable?)
readonly
Whether or not this dialog can be closed.
-
#dialog_id ⇒ String
readonly
The unique ID for the ‘<dialog>` element.
-
#simple_title ⇒ String
readonly
Accessor for the ‘title` string passed via the component config.
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
-
#before_render ⇒ Object
Sets up the component with various CSS classes and HTML attributes.
-
#initialize(title = nil, **kws, &block) ⇒ ModalComponent
constructor
Creates a new instance of the ModalComponent.
Methods inherited from LocoMotion::BaseComponent
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Constructor Details
#initialize(title = nil, **kws, &block) ⇒ ModalComponent
Creates a new instance of the ModalComponent.
111 112 113 114 115 116 117 |
# File 'app/components/daisy/actions/modal_component.rb', line 111 def initialize(title = nil, **kws, &block) super @dialog_id = config_option(:dialog_id, SecureRandom.uuid) @closable = config_option(:closable, true) @simple_title = config_option(:title, title) end |
Instance Attribute Details
#closable ⇒ Boolean (readonly) Also known as: closable?
84 85 86 |
# File 'app/components/daisy/actions/modal_component.rb', line 84 def closable @closable end |
#dialog_id ⇒ String (readonly)
88 89 90 |
# File 'app/components/daisy/actions/modal_component.rb', line 88 def dialog_id @dialog_id end |
#simple_title ⇒ String (readonly)
92 93 94 |
# File 'app/components/daisy/actions/modal_component.rb', line 92 def simple_title @simple_title end |
Instance Method Details
#before_render ⇒ Object
Sets up the component with various CSS classes and HTML attributes.
122 123 124 125 126 127 128 129 130 |
# File 'app/components/daisy/actions/modal_component.rb', line 122 def before_render setup_component setup_backdrop setup_box setup_close_icon setup_title setup_actions end |