rails_heroicon 2.1.0 → 2.1.2
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 +4 -4
- data/README.md +10 -2
- data/compressed/icons.json +854 -854
- data/lib/rails_heroicon/helper.rb +8 -2
- data/lib/rails_heroicon/rails_heroicon.rb +7 -1
- data/lib/rails_heroicon/version.rb +1 -1
- metadata +3 -3
@@ -3,6 +3,8 @@ require "action_view"
|
|
3
3
|
module RailsHeroicon
|
4
4
|
module Helper
|
5
5
|
include ActionView::Helpers::TagHelper
|
6
|
+
|
7
|
+
mattr_accessor :icon_cache, default: {}
|
6
8
|
# To add a heroicon, call <tt><%= heroicon "icon_name" %></tt> on your erb template.
|
7
9
|
# Head over to https://heroicons.com to view all the icons.
|
8
10
|
#
|
@@ -34,10 +36,14 @@ module RailsHeroicon
|
|
34
36
|
# The helper method automatically sets <tt>aria-hidden=true</tt> if <tt>aria-label</tt> is not set, and
|
35
37
|
# if <tt>aria-label</tt> is set, then <tt>role=img</tt> is set automatically.
|
36
38
|
def heroicon(symbol, title: nil, **options)
|
37
|
-
|
39
|
+
cache_key = [symbol, title, options]
|
40
|
+
return icon_cache[cache_key] if icon_cache[cache_key]
|
38
41
|
|
42
|
+
icon = RailsHeroicon.new(symbol, **options)
|
39
43
|
title_tag = content_tag(:title, title) if title
|
40
|
-
content_tag(:svg, title_tag.to_s.html_safe + icon.svg_path.html_safe, icon.options)
|
44
|
+
tag = content_tag(:svg, title_tag.to_s.html_safe + icon.svg_path.html_safe, icon.options)
|
45
|
+
icon_cache[cache_key] = tag
|
46
|
+
tag
|
41
47
|
end
|
42
48
|
end
|
43
49
|
end
|
@@ -29,13 +29,14 @@ module RailsHeroicon
|
|
29
29
|
def svg_properties
|
30
30
|
properties = {}
|
31
31
|
|
32
|
+
properties[:xmlns] = "http://www.w3.org/2000/svg"
|
32
33
|
properties[:viewBox] = mini? ? "0 0 20 20" : "0 0 24 24"
|
33
34
|
properties[:height] = @size
|
34
35
|
properties[:width] = @size
|
35
36
|
properties[:version] = "1.1"
|
36
37
|
properties[:fill] = outline? ? "none" : "currentColor"
|
37
38
|
properties[:stroke] = outline? ? "currentColor" : "none"
|
38
|
-
properties[:"stroke-width"] =
|
39
|
+
properties[:"stroke-width"] = stroke_width
|
39
40
|
|
40
41
|
if options[:"aria-label"].nil? && options["aria-label"].nil? && options.dig(:aria, :label).nil?
|
41
42
|
properties[:"aria-hidden"] = "true"
|
@@ -55,6 +56,11 @@ module RailsHeroicon
|
|
55
56
|
24
|
56
57
|
end
|
57
58
|
|
59
|
+
def stroke_width
|
60
|
+
return unless outline?
|
61
|
+
@options[:"stroke-width"] || 1.5
|
62
|
+
end
|
63
|
+
|
58
64
|
def outline?
|
59
65
|
@variant == "outline"
|
60
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_heroicon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- abeidahmed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
80
|
+
rubygems_version: 3.1.6
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Ruby on Rails view helpers for the awesome Heroicons by Steve Schoger.
|