Sha256: 739235ae3e3877a77249ceb4468cc3791bcc3c3310b2f682ba0efcba8fca4d9c
Contents?: true
Size: 1.17 KB
Versions: 29
Compression:
Stored size: 1.17 KB
Contents
module PgEngine module FrameHelper # Will the current view rendered in a modal? def using_modal? controller.instance_variable_get(:@using_modal) || modal_targeted? end def using_modal2? @using_modal || modal_targeted? end def in_modal? request.headers['Modal-Opened'] == 'true' end def current_turbo_frame request.headers['Turbo-Frame'] end def turbo_frame? current_turbo_frame.present? end def modal_targeted? current_turbo_frame == 'modal_content' end def frame_embedded? turbo_frame? && current_turbo_frame.include?('embedded') end def embed_index(object, key) content_tag(:div, 'data-controller': 'embedded-frame') do turbo_frame_tag "embedded--#{key}", refresh: :morph, src: url_for([pg_namespace, object, key]) do content_tag(:p, class: 'p text-body-secondary text-center') { 'Cargando...' } end end end def nav_bg if frame_embedded? 'bg-warning bg-opacity-25' elsif using_modal? 'bg-warning bg-opacity-50' else 'bg-primary-subtle' end end end end
Version data entries
29 entries across 29 versions & 1 rubygems