Sha256: 3fd4477b87913ebbd38eed1fa1828194e3661645d1c339adcf14d80f082d9b81

Contents?: true

Size: 765 Bytes

Versions: 13

Compression:

Stored size: 765 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
            with_icon(**icon_opts) if icon_opts[:name]
          end
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
coveragebook_components-0.18.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.17.7 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.17.6 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.17.5 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.17.4 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.17.3 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.17.2 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.17.1 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.17.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.16.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.15.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.14.0 app/components/coco/concerns/with_icon.rb
coveragebook_components-0.13.1 app/components/coco/concerns/with_icon.rb