heroicons_helper 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/.vscode/settings.json +14 -0
- data/CHANGELOG.md +2 -0
- data/README.md +7 -6
- data/Rakefile +6 -0
- data/lib/heroicons_helper/cache.rb +2 -9
- data/lib/heroicons_helper/data.json +1 -1
- data/lib/heroicons_helper/icon.rb +22 -52
- data/lib/heroicons_helper/version.rb +1 -1
- data/lib/heroicons_helper.rb +5 -6
- data/package-lock.json +38 -639
- data/script/update_heroicons +22 -10
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28720863a41facb4bb2880743d85a24110f57bf4e17ad0b84333e09eddbf1899
|
4
|
+
data.tar.gz: 7e6e0743470659c4c6463c5d10e568ceea9e6d27f8d29dca2d369a86c92e96e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6aa5b6a36a845f2519b53fe14868b1f5f37b2aeeda072d9bc0032f93d03f2168a7d08aec5f7d0c39967e0337ba042ec47e8c69a27869fce2d23060bc11fa531
|
7
|
+
data.tar.gz: 62bff5b69f019356962b10433a443a1748d732e8c5075d2df0939f23552319c89d49a742f957fcbfb67cef346038af646a637888119bc359bf0594c90b7b3253
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.2.1
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"[ruby]": {
|
3
|
+
"editor.defaultFormatter": "Shopify.ruby-lsp"
|
4
|
+
},
|
5
|
+
"[markdown]": {
|
6
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
7
|
+
},
|
8
|
+
"[javascript]": {
|
9
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
10
|
+
},
|
11
|
+
"[json]": {
|
12
|
+
"editor.defaultFormatter": "vscode.json-language-features"
|
13
|
+
}
|
14
|
+
}
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -30,9 +30,9 @@ heroicon(icon, variant, attributes: {})
|
|
30
30
|
|
31
31
|
where
|
32
32
|
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
- `icon` is the Heroicon name (eg. `:bell` or `"bell")
|
34
|
+
- `variant` is the type of Heroicons (eg., `outline`, `solid`, or `mini`)
|
35
|
+
- `attributes` are any additional HTML attributes to add on to the resulting `svg` element
|
36
36
|
|
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
|
|
@@ -40,6 +40,7 @@ This one method call returns an object that represents the Heroicon, and you sho
|
|
40
40
|
outline_icon = heroicon("x-mark", variant: HeroiconsHelper::Icon::VARIANT_OUTLINE)
|
41
41
|
puts outline_icon.to_svg
|
42
42
|
```
|
43
|
+
|
43
44
|
```
|
44
45
|
=> <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"></path></svg>
|
45
46
|
```
|
@@ -48,7 +49,7 @@ puts outline_icon.to_svg
|
|
48
49
|
|
49
50
|
This gem also comes with a simple caching system, which can be useful to preload icons. It works like this:
|
50
51
|
|
51
|
-
```
|
52
|
+
```ruby
|
52
53
|
icons_to_preload = [{
|
53
54
|
name: "thumb-down",
|
54
55
|
variant: "outline",
|
@@ -65,8 +66,8 @@ end
|
|
65
66
|
|
66
67
|
`HeroiconsHelper::Cache.preload!` does one of two things:
|
67
68
|
|
68
|
-
|
69
|
-
|
69
|
+
- If, given the `icons_to_preload` array, an item is located in the cache, `found` is true and `icon` is the cached item
|
70
|
+
- Otherwise, `found` is false, and `icon` is the element currently being iterated. Also, the last line of the block sets the cache
|
70
71
|
|
71
72
|
The Hash elements within `icons_to_preload` can also take `height` and `width` keys.
|
72
73
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
|
+
require "rubygems/package_task"
|
4
5
|
require "rake/testtask"
|
5
6
|
|
6
7
|
Rake::TestTask.new(:test) do |t|
|
@@ -12,3 +13,8 @@ end
|
|
12
13
|
require "rubocop/rake_task"
|
13
14
|
|
14
15
|
RuboCop::RakeTask.new
|
16
|
+
|
17
|
+
GEMSPEC = Bundler.load_gemspec("heroicons_helper.gemspec")
|
18
|
+
gem_path = Gem::PackageTask.new(GEMSPEC).define
|
19
|
+
desc "Package the ruby gem"
|
20
|
+
task "package" => [gem_path]
|
@@ -6,14 +6,8 @@ module HeroiconsHelper
|
|
6
6
|
LOOKUP = {}
|
7
7
|
|
8
8
|
class << self
|
9
|
-
def get_key(name:, variant:,
|
10
|
-
attrs = { name: name, variant: variant
|
11
|
-
if unsafe
|
12
|
-
attrs[:unsafe] = true
|
13
|
-
else
|
14
|
-
attrs.delete(:unsafe)
|
15
|
-
attrs[:safe] = true
|
16
|
-
end
|
9
|
+
def get_key(name:, variant:, **attributes)
|
10
|
+
attrs = { name: name, variant: variant }.merge(attributes)
|
17
11
|
|
18
12
|
attrs.compact!
|
19
13
|
attrs.hash
|
@@ -59,7 +53,6 @@ module HeroiconsHelper
|
|
59
53
|
cache_key = HeroiconsHelper::Cache.get_key(
|
60
54
|
name: icon["name"],
|
61
55
|
variant: icon["variant"],
|
62
|
-
unsafe: icon["unsafe"] || false,
|
63
56
|
height: height,
|
64
57
|
width: width,
|
65
58
|
)
|