Module: Voltron::Svg::SassHelpers

Defined in:
lib/voltron/svg.rb

Instance Method Summary collapse

Instance Method Details

#map_options(options = {}) ⇒ Object



17
18
19
20
21
# File 'lib/voltron/svg.rb', line 17

def map_options(options={})
  ::Sass::Util.map_hash(options) do |key, value|
    [key.to_sym, (value.respond_to?(:representation) ? value.representation : (value.respond_to?(:value) ? value.value : value))]
  end
end

#svg_icon(source, options = {}) ⇒ Object



11
12
13
14
15
# File 'lib/voltron/svg.rb', line 11

def svg_icon(source, options={})
  tag = Voltron::Svg::Tag.new(source.value, { extension: :svg }.merge(map_options(options)))

  ::Sass::Script::String.new "url(\"#{tag.image_path}\");\nbackground-image: url(\"#{tag.svg_path}\"), linear-gradient(transparent, transparent);\nbackground-size: #{tag.width}px #{tag.height}px"
end