Class: Coco::Modal
- Inherits:
-
Component
- Object
- Component
- Coco::Modal
show all
- Includes:
- Concerns::AcceptsOptions, Turbo::FramesHelper
- Defined in:
- app/components/coco/base/modal/modal.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
#accepted_options, #get_option_group
Constructor Details
#initialize(name:, show: false, **kwargs) ⇒ Modal
Returns a new instance of Modal.
30
31
32
33
34
|
# File 'app/components/coco/base/modal/modal.rb', line 30
def initialize(name:, show: false, **kwargs)
@name = name
@show = show
title { kwargs[:title] } if kwargs[:title]
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
28
29
30
|
# File 'app/components/coco/base/modal/modal.rb', line 28
def name
@name
end
|
#show ⇒ Object
Returns the value of attribute show.
28
29
30
|
# File 'app/components/coco/base/modal/modal.rb', line 28
def show
@show
end
|
Instance Method Details
#content ⇒ Object
48
49
50
|
# File 'app/components/coco/base/modal/modal.rb', line 48
def content
@container_content.present? ? @container_content.call : super
end
|
#id ⇒ Object
40
41
42
|
# File 'app/components/coco/base/modal/modal.rb', line 40
def id
"coco-modal-#{name.to_s.dasherize}"
end
|
#modal_content ⇒ Object
44
45
46
|
# File 'app/components/coco/base/modal/modal.rb', line 44
def modal_content
container? ? container : content
end
|
#render_as_modal? ⇒ Boolean
36
37
38
|
# File 'app/components/coco/base/modal/modal.rb', line 36
def render_as_modal?
request.["Turbo-Frame"].present? || show
end
|
#render_flash_messages ⇒ Object
52
53
54
55
56
|
# File 'app/components/coco/base/modal/modal.rb', line 52
def render_flash_messages
if helpers.respond_to?(:render_turbo_stream_flash_messages)
helpers.render_turbo_stream_flash_messages
end
end
|