Class: Pulse::Modal
- Inherits:
-
Component
- Object
- Component
- Pulse::Modal
- Includes:
- Turbo::FramesHelper
- Defined in:
- app/components/pulse/modal.rb
Overview
Renders a modal component targetable by turbo frame
Constant Summary collapse
- DEFAULT_SIZE =
:md- SIZE_MAPPINGS =
{ sm: 'pulse-max-w-md', md: 'pulse-max-w-2xl', lg: 'pulse-max-w-4xl', xl: 'pulse-max-w-5xl', xxl: 'pulse-max-w-6xl' }.freeze
- SIZE_OPTIONS =
SIZE_MAPPINGS.keys.freeze
Instance Method Summary collapse
-
#initialize(size: DEFAULT_SIZE, close_button: true, close_on_esc: true, close_on_overlay_click: true, close_on_submit: true, auto_close: false, **system_arguments) ⇒ Modal
constructor
A new instance of Modal.
Constructor Details
#initialize(size: DEFAULT_SIZE, close_button: true, close_on_esc: true, close_on_overlay_click: true, close_on_submit: true, auto_close: false, **system_arguments) ⇒ Modal
Returns a new instance of Modal.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/components/pulse/modal.rb', line 21 def initialize(size: DEFAULT_SIZE, close_button: true, close_on_esc: true, close_on_overlay_click: true, close_on_submit: true, auto_close: false, **system_arguments) @size = fetch_or_fallback(SIZE_OPTIONS, size, DEFAULT_SIZE) @system_arguments = system_arguments @modal_classes = merge_classes( 'pulse-w-full', SIZE_MAPPINGS[@size], @system_arguments.delete(:classes) ) @close_button = @close_on_esc = close_on_esc @close_on_overlay_click = @close_on_submit = close_on_submit @auto_close = auto_close @system_arguments[:'aria-labelledby'] = 'modal-title' @system_arguments[:'aria-modal'] = true @system_arguments[:classes] = 'pulse-fixed pulse-z-9999 pulse-inset-0 ' \ 'pulse-overflow-y-auto' @system_arguments[:data] = data_attributes @system_arguments[:role] = 'dialog' @system_arguments[:tabindex] = 0 @system_arguments[:tag] = :div end |