Module: Coco::BaseHelper
- Included in:
- App::Elements::Button, App::Elements::Link, ComponentHelper
- Defined in:
- app/helpers/coco/base_helper.rb
Instance Method Summary collapse
- #coco_avatar(src, name = nil) ⇒ Object
- #coco_embed(platform, url = nil) ⇒ Object
- #coco_icon(icon_name = nil, &block) ⇒ Object
- #coco_image(src = nil) ⇒ Object
- #coco_link_to_modal(data: {}, modal: nil, **kwargs) ⇒ Object
- #coco_modal(name = "default", &block) ⇒ Object
- #coco_modal_data_attributes(name = "default") ⇒ Object
- #coco_modal_dialog(name = "default", &block) ⇒ Object
- #coco_modal_frame_id(name = "default") ⇒ Object
- #coco_modal_lightbox(name = "default", scroll_top: nil, &block) ⇒ Object
- #coco_placeholder(&block) ⇒ Object
- #coco_svg(path = nil) ⇒ Object
- #coco_tag(&block) ⇒ Object
Instance Method Details
#coco_avatar(src, name = nil) ⇒ Object
15 16 17 |
# File 'app/helpers/coco/base_helper.rb', line 15 def coco_avatar(src, name = nil, **) render Coco::Avatar.new(src: src, name: name, **) end |
#coco_embed(platform, url = nil) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'app/helpers/coco/base_helper.rb', line 23 def (platform, url = nil, **) case platform when :youtube render Coco::Embeds::Youtube.new(url: url, **) else raise ArgumentError, "`#{platform}` is not a valid embed type" end end |
#coco_icon(icon_name = nil, &block) ⇒ Object
19 20 21 |
# File 'app/helpers/coco/base_helper.rb', line 19 def coco_icon(icon_name = nil, **, &block) render Coco::Icon.new(name: icon_name, **), &block end |
#coco_image(src = nil) ⇒ Object
11 12 13 |
# File 'app/helpers/coco/base_helper.rb', line 11 def coco_image(src = nil, **) render Coco::Image.new(src: src, **) end |
#coco_link_to_modal(data: {}, modal: nil, **kwargs) ⇒ Object
52 53 54 55 56 |
# File 'app/helpers/coco/base_helper.rb', line 52 def coco_link_to_modal(*, data: {}, modal: nil, **kwargs, &) kwargs[:data] = coco_modal_data_attributes(modal || "default").merge(data) coco_link_to(*, **kwargs, &) end |
#coco_modal(name = "default", &block) ⇒ Object
36 37 38 |
# File 'app/helpers/coco/base_helper.rb', line 36 def coco_modal(name = "default", **, &block) render(Coco::Modal.new(name: name, **), &block) end |
#coco_modal_data_attributes(name = "default") ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'app/helpers/coco/base_helper.rb', line 62 def coco_modal_data_attributes(name = "default") return {} if name.nil? { turbo: true, turbo_frame: coco_modal_frame_id(name) } end |
#coco_modal_dialog(name = "default", &block) ⇒ Object
40 41 42 43 44 |
# File 'app/helpers/coco/base_helper.rb', line 40 def coco_modal_dialog(name = "default", **, &block) render(Coco::Modal.new(name: name, **)) do |modal| modal.with_container_dialog(&block) end end |
#coco_modal_frame_id(name = "default") ⇒ Object
58 59 60 |
# File 'app/helpers/coco/base_helper.rb', line 58 def coco_modal_frame_id(name = "default") "coco-modal-frame-#{name.to_s.dasherize}" end |
#coco_modal_lightbox(name = "default", scroll_top: nil, &block) ⇒ Object
46 47 48 49 50 |
# File 'app/helpers/coco/base_helper.rb', line 46 def coco_modal_lightbox(name = "default", scroll_top: nil, **, &block) render(Coco::Modal.new(name: name, scroll_top: scroll_top, **)) do |modal| modal.with_container_lightbox(&block) end end |
#coco_placeholder(&block) ⇒ Object
32 33 34 |
# File 'app/helpers/coco/base_helper.rb', line 32 def coco_placeholder(*, **, &block) render Coco::Placeholder.new(*, **), &block end |