Sha256: 34bc60377b7f0e30ee422dd8d9ce004785479d08ebe9af3749a429481b05c2da

Contents?: true

Size: 950 Bytes

Versions: 26

Compression:

Stored size: 950 Bytes

Contents

module Coco
  class Link < Coco::Component
    include Concerns::ActsAsLink
    include Concerns::WithIcon
    include Concerns::AcceptsOptions
    include Concerns::AcceptsTheme

    THEMES = %W[positive primary warning negative info neutral-dark neutral-light] << nil

    accepts_option :theme, from: THEMES
    accepts_option :underline, from: [true, false]

    before_initialize do |kwargs|
      if kwargs.key?(:modal)
        modal_name = (kwargs[:modal] == true) ? "default" : kwargs[:modal]
        kwargs[:data] = kwargs.fetch(:data, {}).merge(coco_modal_data_attributes(modal_name))
        kwargs.delete(:modal)
      end
      kwargs
    end

    def call
      render component_tag(class: ["coco-link", ("with-icon" if icon?)]) do
        safe_join([
          icon,
          icon? ? tag.span(link_text, class: "link-text") : link_text
        ])
      end
    end

    class << self
      include Coco::ModalHelper
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
coveragebook_components-0.19.9 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.8 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.7 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.6 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.5 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.4 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.3 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.2 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.1 app/components/coco/navigation/link/link.rb
coveragebook_components-0.19.0 app/components/coco/navigation/link/link.rb
coveragebook_components-0.18.8 app/components/coco/navigation/link/link.rb
coveragebook_components-0.18.7 app/components/coco/navigation/link/link.rb
coveragebook_components-0.18.0 app/components/coco/navigation/link/link.rb
coveragebook_components-0.17.7 app/components/coco/navigation/link/link.rb
coveragebook_components-0.17.6 app/components/coco/navigation/link/link.rb
coveragebook_components-0.17.5 app/components/coco/navigation/link/link.rb
coveragebook_components-0.17.4 app/components/coco/navigation/link/link.rb
coveragebook_components-0.17.3 app/components/coco/navigation/link/link.rb
coveragebook_components-0.17.2 app/components/coco/navigation/link/link.rb
coveragebook_components-0.17.1 app/components/coco/navigation/link/link.rb