Sha256: 5c46af3c4459a78b8466c257082b8aed20f342c77dd2c312f469316cf0bd3458

Contents?: true

Size: 786 Bytes

Versions: 1

Compression:

Stored size: 786 Bytes

Contents

# frozen_string_literal: true

class FoxTail::IconButtonComponent < FoxTail::ButtonBaseComponent
  renders_many :icons, lambda { |icon, options = {}|
    options[:class] = classnames theme.apply(:icon, self), options[:class]
    FoxTail::IconBaseComponent.new icon, options
  }

  def initialize(icon_or_attributes = {}, html_attributes = {})
    if icon_or_attributes.is_a? Hash
      html_attributes = icon_or_attributes
      icon_or_attributes = nil
    end

    super(html_attributes)

    with_icon icon_or_attributes if icon_or_attributes.present?
  end

  def call
    super do
      icons.each { |icon| concat icon }

      if content? || i18n_content.present?
        concat content_tag(:span, retrieve_content, class: theme.apply(:content, self))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fox_tail-0.1.0 app/components/fox_tail/icon_button_component.rb