Sha256: 6240e832b1e2503c089c2ce492bb561bb7c7635efe9fb1c4ff9993c188462a68

Contents?: true

Size: 760 Bytes

Versions: 49

Compression:

Stored size: 760 Bytes

Contents

module Coco
  module Concerns
    module WithIcon
      extend ActiveSupport::Concern
      include AcceptsOptions

      included do
        accepts_option :icon,
          shorthand: :name do |tt|
          tt.accepts_option :name, private: true
          tt.accepts_option :position, from: ["start", "end", :start, :end]
        end

        renders_one :icon, ->(icon_name = nil, position: nil, **kwargs) do
          set_option_value(:icon, :position, position) unless position.nil?
          Coco::Icon.new(name: icon_name, **kwargs)
        end

        before_render do
          unless icon?
            icon_opts = get_option_group(:icon).values
            icon(**icon_opts) if icon_opts[:name]
          end
        end
      end
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
coveragebook_components-0.13.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.12.2 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.12.1 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.12.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.11.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.10.1.beta.2 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.10.1.beta.1 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.10.1.beta.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.10.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.9.1 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.9.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.9 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.8 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.7 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.6 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.5 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.4 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.3 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.2 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.8.1 app/components/coco/concerns/with_icon.rb