rails_heroicon 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@ require_relative "errors"
2
2
 
3
3
  module RailsHeroicon
4
4
  class RailsHeroicon
5
- VARIANTS = %w[outline solid mini].freeze
5
+ VARIANTS = %w[outline solid mini micro].freeze
6
6
 
7
7
  attr_reader :options
8
8
 
@@ -12,7 +12,7 @@ module RailsHeroicon
12
12
  @icon = icon.to_s
13
13
  @variant = variant.to_s
14
14
  @options = options.dup
15
- @size = icon_size_with(size)
15
+ @size = default_or_defined_size(size)
16
16
  @options.merge!(svg_properties)
17
17
  end
18
18
 
@@ -30,7 +30,7 @@ module RailsHeroicon
30
30
  properties = {}
31
31
 
32
32
  properties[:xmlns] = "http://www.w3.org/2000/svg"
33
- properties[:viewBox] = mini? ? "0 0 20 20" : "0 0 24 24"
33
+ properties[:viewBox] = view_box
34
34
  properties[:height] = @size
35
35
  properties[:width] = @size
36
36
  properties[:version] = "1.1"
@@ -48,9 +48,11 @@ module RailsHeroicon
48
48
  end
49
49
 
50
50
  # If the user has explicitly stated the size attribute, then use that. If size attribute is not passed
51
- # then default to 24 if variant is outline or solid, else default to 20 if variant is mini.
52
- def icon_size_with(size)
51
+ # then default to 24 if variant is outline or solid, else default to 20 if variant is mini, else default to 16 if
52
+ # variant is micro.
53
+ def default_or_defined_size(size)
53
54
  return size if size
55
+ return 16 if micro?
54
56
  return 20 if mini?
55
57
 
56
58
  24
@@ -61,6 +63,12 @@ module RailsHeroicon
61
63
  @options[:"stroke-width"] || 1.5
62
64
  end
63
65
 
66
+ def view_box
67
+ return "0 0 20 20" if mini?
68
+ return "0 0 16 16" if micro?
69
+ "0 0 24 24"
70
+ end
71
+
64
72
  def outline?
65
73
  @variant == "outline"
66
74
  end
@@ -72,5 +80,9 @@ module RailsHeroicon
72
80
  def mini?
73
81
  @variant == "mini"
74
82
  end
83
+
84
+ def micro?
85
+ @variant == "micro"
86
+ end
75
87
  end
76
88
  end
@@ -1,3 +1,3 @@
1
1
  module RailsHeroicon
2
- VERSION = "2.1.2".freeze
2
+ VERSION = "2.2.0".freeze
3
3
  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.2
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - abeidahmed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-22 00:00:00.000000000 Z
11
+ date: 2023-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview