rails_heroicon 2.1.2 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -12,7 +12,7 @@ module RailsHeroicon
12
12
  # The helper method accepts mutiple arguments such as:
13
13
  #
14
14
  # === Variant
15
- # There are three types of variants: 'outline', 'solid' and 'mini', the default being the 'outline'.
15
+ # There are 4 types of variants: 'outline', 'solid', 'mini', and 'micro', the default being the 'outline'.
16
16
  # To specify the solid variant, call <tt><%= heroicon "icon_name", variant: "solid" %></tt>
17
17
  #
18
18
  # === HTML attributes
@@ -28,8 +28,9 @@ module RailsHeroicon
28
28
  #
29
29
  # This will set the <tt>height</tt> and <tt>width</tt> attribute on the svg.
30
30
  #
31
- # If the variant is set as <tt>outline</tt> or <tt>solid</tt>, size automatically defaults to 24,
32
- # and if the variant is set as <tt>mini</tt>, size automatically defaults to 20.
31
+ # If the variant is set as <tt>outline</tt> or <tt>solid</tt>, <tt>size</tt> defaults to 24, if the variant is set
32
+ # as <tt>mini</tt>, <tt>size</tt> defaults to 20, and if the variant is set as <tt>micro<tt>, <tt>size</tt>
33
+ # defaults to 16.
33
34
  # However, this can be over-written with the <tt>size</tt> attribute.
34
35
  #
35
36
  # == Accessibility
@@ -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.3.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.3.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: 2024-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionview
@@ -70,14 +70,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
70
  requirements:
71
71
  - - ">="
72
72
  - !ruby/object:Gem::Version
73
- version: '2.7'
73
+ version: 3.0.0
74
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  requirements:
76
76
  - - ">="
77
77
  - !ruby/object:Gem::Version
78
78
  version: '0'
79
79
  requirements: []
80
- rubygems_version: 3.1.6
80
+ rubygems_version: 3.4.20
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Ruby on Rails view helpers for the awesome Heroicons by Steve Schoger.