rails_heroicon 2.0.0 → 2.1.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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/compressed/icons.json +876 -840
- data/lib/rails_heroicon/helper.rb +5 -4
- data/lib/rails_heroicon/rails_heroicon.rb +16 -24
- data/lib/rails_heroicon/railtie.rb +1 -1
- data/lib/rails_heroicon/version.rb +1 -1
- metadata +3 -3
@@ -2,6 +2,7 @@ require "action_view"
|
|
2
2
|
|
3
3
|
module RailsHeroicon
|
4
4
|
module Helper
|
5
|
+
include ActionView::Helpers::TagHelper
|
5
6
|
# To add a heroicon, call <tt><%= heroicon "icon_name" %></tt> on your erb template.
|
6
7
|
# Head over to https://heroicons.com to view all the icons.
|
7
8
|
#
|
@@ -9,7 +10,7 @@ module RailsHeroicon
|
|
9
10
|
# The helper method accepts mutiple arguments such as:
|
10
11
|
#
|
11
12
|
# === Variant
|
12
|
-
# There are
|
13
|
+
# There are three types of variants: 'outline', 'solid' and 'mini', the default being the 'outline'.
|
13
14
|
# To specify the solid variant, call <tt><%= heroicon "icon_name", variant: "solid" %></tt>
|
14
15
|
#
|
15
16
|
# === HTML attributes
|
@@ -25,9 +26,9 @@ module RailsHeroicon
|
|
25
26
|
#
|
26
27
|
# This will set the <tt>height</tt> and <tt>width</tt> attribute on the svg.
|
27
28
|
#
|
28
|
-
# If the variant is set as <tt>outline</tt>, size automatically defaults to 24,
|
29
|
-
# <tt>
|
30
|
-
# attribute.
|
29
|
+
# If the variant is set as <tt>outline</tt> or <tt>solid</tt>, size automatically defaults to 24,
|
30
|
+
# and if the variant is set as <tt>mini</tt>, size automatically defaults to 20.
|
31
|
+
# However, this can be over-written with the <tt>size</tt> attribute.
|
31
32
|
#
|
32
33
|
# == Accessibility
|
33
34
|
# The helper method automatically sets <tt>aria-hidden=true</tt> if <tt>aria-label</tt> is not set, and
|
@@ -11,11 +11,9 @@ module RailsHeroicon
|
|
11
11
|
|
12
12
|
@icon = icon.to_s
|
13
13
|
@variant = variant.to_s
|
14
|
-
@options = options
|
14
|
+
@options = options.dup
|
15
15
|
@size = icon_size_with(size)
|
16
|
-
|
17
|
-
@options.merge!(a11y)
|
18
|
-
@options.merge!(misc)
|
16
|
+
@options.merge!(svg_properties)
|
19
17
|
end
|
20
18
|
|
21
19
|
# Finds the svg icon with respect to variant.
|
@@ -28,30 +26,24 @@ module RailsHeroicon
|
|
28
26
|
|
29
27
|
private
|
30
28
|
|
31
|
-
def
|
32
|
-
|
29
|
+
def svg_properties
|
30
|
+
properties = {}
|
31
|
+
|
32
|
+
properties[:viewBox] = mini? ? "0 0 20 20" : "0 0 24 24"
|
33
|
+
properties[:height] = @size
|
34
|
+
properties[:width] = @size
|
35
|
+
properties[:version] = "1.1"
|
36
|
+
properties[:fill] = outline? ? "none" : "currentColor"
|
37
|
+
properties[:stroke] = outline? ? "currentColor" : "none"
|
38
|
+
properties[:"stroke-width"] = "1.5" if outline?
|
33
39
|
|
34
|
-
if
|
35
|
-
|
40
|
+
if options[:"aria-label"].nil? && options["aria-label"].nil? && options.dig(:aria, :label).nil?
|
41
|
+
properties[:"aria-hidden"] = "true"
|
36
42
|
else
|
37
|
-
|
43
|
+
properties[:role] = "img"
|
38
44
|
end
|
39
45
|
|
40
|
-
|
41
|
-
end
|
42
|
-
|
43
|
-
def misc
|
44
|
-
hash = {}
|
45
|
-
|
46
|
-
hash[:viewBox] = mini? ? "0 0 20 20" : "0 0 24 24"
|
47
|
-
hash[:height] = @size
|
48
|
-
hash[:width] = @size
|
49
|
-
hash[:version] = "1.1"
|
50
|
-
hash[:fill] = outline? ? "none" : "currentColor"
|
51
|
-
hash[:stroke] = outline? ? "currentColor" : "none"
|
52
|
-
hash[:"stroke-width"] = "1.5" if outline?
|
53
|
-
|
54
|
-
hash
|
46
|
+
properties
|
55
47
|
end
|
56
48
|
|
57
49
|
# If the user has explicitly stated the size attribute, then use that. If size attribute is not passed
|
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.
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- abeidahmed
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -70,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
70
|
requirements:
|
71
71
|
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
|
-
version: 2.
|
73
|
+
version: '2.7'
|
74
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
76
|
- - ">="
|