Module: Purpur::Helpers

Defined in:
lib/purpur/helpers.rb

Instance Method Summary collapse

Instance Method Details

#icon_tag(name, options = {}) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/purpur/helpers.rb', line 4

def icon_tag(name, options = {})
  size = Purpur::ICON_SIZES[options.delete(:size)]
  styleclass = ['icon', options.delete(:class)].join(' ')

  (:span, {class: styleclass, data: { icon: Purpur.icon_name(name), 'icon-size' => size }}.deep_merge(options)) do
    (:span, class: 'icon--wrapper') do
      (:svg, class: 'icon--cnt') do
        ('use', nil, 'xlink:href' => "#{asset_url('purpur.svg')}##{name}-icon", 'x' => 0, 'y' => 0)
      end
    end
  end
end