iconify-ruby 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cbee42d007dfab0b442d3dc3a8fb81c937606db0bd07c3e56fcf89472cdab36
4
- data.tar.gz: 3811e8dfe4f279fa0ae7f37961fbbade6c07af7bfef0533cf5b9cc0c805a6197
3
+ metadata.gz: 29f61d253fdcbabdba39a441d9dffd13188b55421c1a22ae025850ebe23cde39
4
+ data.tar.gz: edcdebf9092774eb6e282afb77c16071cea3debd892632267698d340730569e6
5
5
  SHA512:
6
- metadata.gz: 71d26ef81b23eddad1a36bdd4e66f8c826ea423d55a3b675978876daedb1e7818a80f37af9c7001bf84cff6301720fa8698e3a4ac7881965586bcb98278ed3b9
7
- data.tar.gz: 747a40101781ac1980732e32666441d98f6cd1253b03bf2fe37717522067db5346b0031fedb1672bc1b318c5a3b8a4929850c6bd1b35ce9d4d7fb7d34de585f0
6
+ metadata.gz: 98916acfd0c604cc3af45fcd3ad83a791c51915a04130c0edc235f373b29627e5f798a99e6ea478c92fc68ff50ae72c7367620b5dfac869dca06398547f40abb
7
+ data.tar.gz: 26dd9dfb0e29aea5c3b3b292d59adc875478b0a4531669d836d8acfb58fe23dc11b9fc736c49107f586adf40a6f342d6154f6db023e8b67ad093e207035f2129
data/README.md CHANGED
@@ -27,6 +27,17 @@ Or install it yourself as:
27
27
  collections = Iconify::Ruby.collections
28
28
  locate = Iconify::Ruby.locate("bx")
29
29
  svg_path = locale["icons"]["bx-abacus"]["body"]
30
+
31
+ # render svg string
32
+ module ApplicationHelper
33
+ include Iconify::Ruby::Helper
34
+ end
35
+ ```
36
+
37
+ ```erb
38
+ <%== iconify_icon("bx-chevron-up", class: 'w-4 h-4 text-red-500') %>
39
+
40
+ <%== iconify_icon("chevron-down", class: 'w-4 h-4 text-red-500', locate: 'akar-icons') %>
30
41
  ```
31
42
 
32
43
  ## Development
@@ -0,0 +1,28 @@
1
+ module Iconify
2
+ module Ruby
3
+ module Helper
4
+ def iconify_icon(name, options = {})
5
+ locate_name = options.delete(:locate) || "bx"
6
+ options = options.dup
7
+
8
+ locate = Iconify::Ruby.locate(locate_name)
9
+ height = locate["height"]
10
+ width = locate["width"]
11
+
12
+ options.merge!({
13
+ viewBox: "0 0 #{width} #{height}",
14
+ version: "1.1",
15
+ })
16
+
17
+ path = locate["icons"][name]["body"]
18
+ "<svg xmlns='http://www.w3.org/2000/svg' #{iconify_html_attributes(options)}>#{path}</svg>"
19
+ end
20
+
21
+ def iconify_html_attributes(options)
22
+ attrs = ""
23
+ options.each { |attr, value| attrs += "#{attr}=\"#{value}\" " }
24
+ attrs.strip
25
+ end
26
+ end
27
+ end
28
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Iconify
4
4
  module Ruby
5
- VERSION = "0.2.1"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
data/lib/iconify/ruby.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
  require "json"
3
+ require_relative "ruby/helper"
3
4
  require_relative "ruby/version"
4
5
 
5
6
  module Iconify
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iconify-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - doabit
@@ -176,6 +176,7 @@ files:
176
176
  - iconify-json/readme.md
177
177
  - iconify-ruby.gemspec
178
178
  - lib/iconify/ruby.rb
179
+ - lib/iconify/ruby/helper.rb
179
180
  - lib/iconify/ruby/version.rb
180
181
  homepage: https://github.com/ruby-gems/iconify-ruby
181
182
  licenses: []