Sha256: 588b98bf3f43b37ef661f378d9d64843b1ada855d5d319bd7c05bfc0b2d5bcdb

Contents?: true

Size: 629 Bytes

Versions: 3

Compression:

Stored size: 629 Bytes

Contents

require 'tao_on_rails/components/base'

module TaoUi
  module Components
    class IconComponent < TaoOnRails::Components::Base

      attr_reader :name

      def initialize view, name, options = {}
        super view, options

        @name = name.to_s.dasherize

        if @options[:class].present?
          @options[:class] += " icon icon-#{name}"
        else
          @options[:class] = "icon icon-#{name}"
        end
      end

      def render
        view.content_tag(:svg, %Q(<use xlink:href="#icon-#{name}"/>).html_safe, options)
      end

      def self.component_name
        :icon
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tao_ui-0.1.2 lib/tao_ui/components/icon_component.rb
tao_ui-0.1.1 lib/tao_ui/components/icon_component.rb
tao_ui-0.1.0 lib/tao_ui/components/icon_component.rb