diff --git a/app/components/dialog_component.rb b/app/components/dialog_component.rb index 97788691..94246872 100644 --- a/app/components/dialog_component.rb +++ b/app/components/dialog_component.rb @@ -43,21 +43,26 @@ class DialogComponent < ViewComponent::Base full: "lg:max-w-full" }.freeze - def initialize(variant: "modal", auto_open: true, reload_on_close: false, width: "md", disable_frame: false, **opts) + def initialize(variant: "modal", auto_open: true, reload_on_close: false, width: "md", frame: nil, disable_frame: false, **opts) @variant = variant.to_sym @auto_open = auto_open @reload_on_close = reload_on_close @width = width.to_sym + @frame = frame @disable_frame = disable_frame @opts = opts end + def frame + @frame || variant + end + # Caller must "opt-out" of using the default turbo-frame based on the variant def wrapper_element(&block) if disable_frame content_tag(:div, &block) else - content_tag("turbo-frame", id: variant, &block) + content_tag("turbo-frame", id: frame, &block) end end