Files
openfoodnetwork/app/components/modal_component.rb
David Cook 38661a67bc Add option to open modal instantly
Using pre-existing feature in ModalController
2024-01-16 12:53:07 +11:00

28 lines
442 B
Ruby

# frozen_string_literal: true
class ModalComponent < ViewComponent::Base
def initialize(id:, close_button: true, instant: false)
@id = id
@close_button = close_button
@instant = instant
end
private
def close_button_class
if namespace == "admin"
"red"
else
"primary"
end
end
def close_button?
!!@close_button
end
def namespace
helpers.controller_path.split("/").first
end
end