heroicons_helper 0.6.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbbab8ccd0d05be04deb3df081747364d962a5e21e581d427b0ebbeff67b54ae
4
- data.tar.gz: fcff746233b82222604d54d5f5e01cfd5760de65892532c8cfb4ad4c5cc64505
3
+ metadata.gz: ac5d87867f1aefd58513112eca2bdf6f8e6e54800bedef9d34be407f06f9f36c
4
+ data.tar.gz: 51184fcc333b5dfe492a312677338c8035b5a0f5d658bbb7c4c1247388976311
5
5
  SHA512:
6
- metadata.gz: e539907cca91fa6a1f9ed11651238721bb8b7949184d4f8270ea58a5b73855257714d5ed97378cc7613857e31dd1dbcf927be05bbb487dc1fbc462f3c8a990fa
7
- data.tar.gz: 36b3b4fe61cd709b59e36c61f8a05d2a2ce024bc11d6ff6bd54bce07990954516eb63df36f4caeddb384153ae711aa496ad64d338391e1fcea0ee2cc1e79ee61
6
+ metadata.gz: ea63f9c2fb9d2983168f13bb9fc14e86c23c1e142c4a5d1e354a079038b00e82d51c0655d893c7bd913814963b9850b2df81d3627e51909932bdc91b4f9743e9
7
+ data.tar.gz: 331963ec48860c5eefb19461232da7628927ea7f7eac29856090559bb6b112f659551f02f9d55c2a6641d779e0adcc6eebc264cbf4143991eda9db506c821a90
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.1
@@ -0,0 +1,8 @@
1
+ {
2
+ "[ruby]": {
3
+ "editor.defaultFormatter": "Shopify.ruby-lsp"
4
+ },
5
+ "[markdown]": {
6
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
7
+ }
8
+ }
data/Gemfile CHANGED
@@ -5,6 +5,10 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in heroicons_helper.gemspec
6
6
  gemspec
7
7
 
8
+ group :development do
9
+ gem "bundler", "~> 2.0"
10
+ end
11
+
8
12
  group :development, :test do
9
13
  gem "amazing_print"
10
14
  gem "debug"
data/README.md CHANGED
@@ -30,9 +30,9 @@ heroicon(icon, variant, attributes: {})
30
30
 
31
31
  where
32
32
 
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
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
- ``` ruby
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
- * If, given the `icons_to_preload` array, an item is located in the cache, `found` is true and `icon` is the cached item
69
- * Otherwise, `found` is false, and `icon` is the element currently being iterated. Also, the last line of the block sets the cache
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]
@@ -16,6 +16,10 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = spec.homepage
19
+ spec.metadata = {
20
+ "funding_uri" => "https://github.com/sponsors/gjtorikian/",
21
+ "rubygems_mfa_required" => "true",
22
+ }
19
23
 
20
24
  # Specify which files should be added to the gem when it is released.
21
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -28,6 +32,8 @@ Gem::Specification.new do |spec|
28
32
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
29
33
  spec.require_paths = ["lib"]
30
34
 
35
+ spec.add_runtime_dependency("activesupport", ">= 6")
36
+
31
37
  # Uncomment to register a new dependency of your gem
32
38
  # spec.add_dependency "example-gem", "~> 1.0"
33
39
 
@@ -6,8 +6,15 @@ module HeroiconsHelper
6
6
  LOOKUP = {}
7
7
 
8
8
  class << self
9
- def get_key(name:, variant:, width: nil, height: nil)
10
- attrs = { name: name, variant: variant, width: width, height: height }
9
+ def get_key(name:, variant:, unsafe: false, **attributes)
10
+ attrs = { name: name, variant: variant, unsafe: unsafe }.merge(attributes)
11
+ if unsafe
12
+ attrs[:unsafe] = true
13
+ else
14
+ attrs.delete(:unsafe)
15
+ attrs[:safe] = true
16
+ end
17
+
11
18
  attrs.compact!
12
19
  attrs.hash
13
20
  end
@@ -52,8 +59,9 @@ module HeroiconsHelper
52
59
  cache_key = HeroiconsHelper::Cache.get_key(
53
60
  name: icon["name"],
54
61
  variant: icon["variant"],
62
+ unsafe: icon["unsafe"] || false,
55
63
  height: height,
56
- width: width
64
+ width: width,
57
65
  )
58
66
 
59
67
  cache_icon = HeroiconsHelper::Cache.read(cache_key)