Sha256: 178f89e386ef70575d92ee6d80f362108fc3287b4a8bf3641a17559b1799a5b1

Contents?: true

Size: 535 Bytes

Versions: 2

Compression:

Stored size: 535 Bytes

Contents

class Ikonic
  def self.icon(name, options={})
    DEFAULTS.each { |key, val| options[key] ||= val }

    template = File.read(
      File.join(__dir__, "../assets/#{options[:theme]}/#{options[:style]}/#{name}.svg"))

    template.gsub!(
        /stroke-width="(\d+)"/, 
        "stroke-width=\"#{options[:width]}\""
      ) if options[:width]

    template.insert(5, "class=\"#{options[:class]}\" ") if options[:class]

    template
  end

  DEFAULTS = {
    theme: 'heroicon',
    style: 'outline',
    size: 24,
    width: 2
  }
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ikonic-0.0.2 lib/ikonic.rb
ikonic-0.0.1 lib/ikonic.rb