Sha256: 6ced82b8f7ed213499e029d8621a6f0f39e831bf37bc23aae1ffd3ba666b974c

Contents?: true

Size: 1.79 KB

Versions: 15

Compression:

Stored size: 1.79 KB

Contents

module Coco
  module BaseHelper
    def coco_tag(*, **, &block)
      render Coco::Tag.new(*, **), &block
    end

    def coco_svg(path = nil, **)
      render Coco::Svg.new(path: path, **)
    end

    def coco_image(src = nil, **)
      render Coco::Image.new(src: src, **)
    end

    def coco_avatar(src, name = nil, **)
      render Coco::Avatar.new(src: src, name: name, **)
    end

    def coco_icon(icon_name = nil, **, &block)
      render Coco::Icon.new(name: icon_name, **), &block
    end

    def coco_embed(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

    def coco_placeholder(*, **, &block)
      render Coco::Placeholder.new(*, **), &block
    end

    def coco_modal(name = "default", **, &block)
      render(Coco::Modal.new(name: name, **), &block)
    end

    def coco_modal_dialog(name = "default", **, &block)
      render(Coco::Modal.new(name: name, **)) do |modal|
        modal.with_container_dialog(&block)
      end
    end

    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

    def coco_link_to_modal(*, data: {}, modal: nil, **kwargs, &)
      kwargs[:data] = coco_modal_data_attributes(modal || "default").merge(data)

      coco_link_to(*, **kwargs, &)
    end

    def coco_modal_frame_id(name = "default")
      "coco-modal-frame-#{name.to_s.dasherize}"
    end

    def coco_modal_data_attributes(name = "default")
      return {} if name.nil?

      {
        turbo: true,
        turbo_frame: coco_modal_frame_id(name)
      }
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
coveragebook_components-0.9.1 app/helpers/coco/base_helper.rb
coveragebook_components-0.9.0 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.9 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.8 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.7 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.6 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.5 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.4 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.3 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.2 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.1 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.0 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.0.beta.3 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.0.beta.2 app/helpers/coco/base_helper.rb
coveragebook_components-0.8.0.beta.1 app/helpers/coco/base_helper.rb