module Coco class ModalDialog < Coco::Component include Concerns::AcceptsOptions accepts_option :dismissable, from: [true, false], default: true accepts_option :size, from: [:sm, :md, :lg], default: :md renders_one :notice, ->(**kwargs) do Coco::Notice.new(**kwargs, dismissable: false) end renders_one :title before_render do unless title? raise ArgumentError, "A title is required for modal dialogs" end end def initialize(**kwargs) with_title { kwargs[:title] } if kwargs[:title] end def header? title || dismissable? end def dismissable? get_option_value(:dismissable) end end end