heroicons_helper 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/lib/heroicons_helper/icon.rb +12 -5
- data/lib/heroicons_helper/version.rb +1 -1
- data/lib/heroicons_helper.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea79c1638e02674896f2f251375b879df8e289d10c39bd1b6550b35f65bb667e
|
4
|
+
data.tar.gz: 49e4f89e38f7ceec4e09970d9864f859424f4e59f314b40353df87e73ff128b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4c7715c0dc796769dd80fd26e38a56bbccadb1c00418ac0ff8911722679bd571e2a2cb058ecbf3931e9c6da3020628239ee5500ef90b05aed66c53f856bec5c
|
7
|
+
data.tar.gz: 0257f55a823a70b7147b4ac0d7c3051fd407febea7577b0ffd2cc9bb2e14b7582299daae2a425f273de59ca7bd4dd5ddd51181baeb5ac40cdd47c1006224a324
|
data/README.md
CHANGED
@@ -22,10 +22,10 @@ require "heroicons_helper"
|
|
22
22
|
include HeroiconsHelper
|
23
23
|
```
|
24
24
|
|
25
|
-
You'll have a brand new method called `
|
25
|
+
You'll have a brand new method called `heroicon` whose signature looks like this:
|
26
26
|
|
27
27
|
```ruby
|
28
|
-
|
28
|
+
heroicon(symbol, variant, attributes: {})
|
29
29
|
```
|
30
30
|
|
31
31
|
where
|
@@ -37,7 +37,7 @@ where
|
|
37
37
|
This one method call returns an object that represents the Heroicon, and you should call `to_svg` to get the resulting SVG string:
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
outline_icon =
|
40
|
+
outline_icon = heroicon("x", "outline")
|
41
41
|
puts outline_icon.to_svg
|
42
42
|
```
|
43
43
|
```
|
@@ -58,7 +58,7 @@ icons_to_preload = [{
|
|
58
58
|
},]
|
59
59
|
|
60
60
|
HeroiconsHelper::Cache.preload!(icons_to_preload) do |found, icon|
|
61
|
-
# An instance of `FakeClass`
|
61
|
+
# An instance of `FakeClass` will be stored in the cache
|
62
62
|
FakeClass.new(icon) unless found
|
63
63
|
end
|
64
64
|
```
|
@@ -55,15 +55,22 @@ module HeroiconsHelper
|
|
55
55
|
end
|
56
56
|
|
57
57
|
def get_heroicon(symbol, variant)
|
58
|
-
|
59
|
-
raise "
|
58
|
+
symbol_s = symbol.to_s
|
59
|
+
raise ArgumentError, "Icon name can't be empty" if symbol_s.empty?
|
60
60
|
|
61
|
-
|
62
|
-
raise "
|
61
|
+
variant_s = variant.to_s
|
62
|
+
raise ArgumentError, "Variant `#{variant.inspect}` is invalid; must be one of #{VARIANTS.join(", ")}" unless VARIANTS.include?(variant_s)
|
63
|
+
|
64
|
+
icon = HeroiconsHelper::ICON_SYMBOLS[symbol_s]
|
65
|
+
|
66
|
+
raise ArgumentError, "Couldn't find Heroicon for `#{symbol.inspect}`" unless icon
|
67
|
+
|
68
|
+
icon_in_variant = icon["variants"][variant_s]
|
69
|
+
raise ArgumentError, "Heroicon for `#{symbol.inspect}` doesn't have variant `#{variant.inspect}`" unless icon_in_variant
|
63
70
|
|
64
71
|
{
|
65
72
|
"name" => icon["name"],
|
66
|
-
"variant" =>
|
73
|
+
"variant" => variant_s,
|
67
74
|
"width" => icon_in_variant["width"],
|
68
75
|
"height" => icon_in_variant["height"],
|
69
76
|
"path" => icon_in_variant["path"],
|
data/lib/heroicons_helper.rb
CHANGED
@@ -9,7 +9,7 @@ module HeroiconsHelper
|
|
9
9
|
file_data = File.read(File.join(File.dirname(__FILE__), "./heroicons_helper/data.json"))
|
10
10
|
ICON_SYMBOLS = JSON.parse(file_data).freeze
|
11
11
|
|
12
|
-
def
|
12
|
+
def heroicon(symbol, variant, attributes: {})
|
13
13
|
::HeroiconsHelper::Icon.new(symbol, variant, attributes: attributes)
|
14
14
|
end
|
15
15
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroicons_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
@@ -58,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
58
58
|
- !ruby/object:Gem::Version
|
59
59
|
version: '0'
|
60
60
|
requirements: []
|
61
|
-
rubygems_version: 3.3.
|
61
|
+
rubygems_version: 3.3.7
|
62
62
|
signing_key:
|
63
63
|
specification_version: 4
|
64
64
|
summary: Heroicons port for Ruby
|