heroicon-rails 0.2.6 → 0.2.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e112f0b760d1eb338db45f92aa4ccef920da43e7a9ce1b2bfc1cedd0fc702231
4
- data.tar.gz: a3f4692f2b709f010a9a975ea5b106ebb63fe0b17b52379d71e52689f8c575f9
3
+ metadata.gz: 90142cd4905946fbffc96887824e183e024ef876b8d6fa2d39399d69bc8af39f
4
+ data.tar.gz: 5596b5cb9a0b0dade3f28782010c4138a0c385764341cd7dc65b2271d0ec3c58
5
5
  SHA512:
6
- metadata.gz: 4ccaaef593336ce8d653472dfdbf20d5c3c395c5409b049c3f2ba2e808b118495f8028cda7af2ef451f004c83dfef16cdfd933ab1199165467fa4d379b33f187
7
- data.tar.gz: '08252cf7db3518ddfbc585a3ceafd87674bf328bf6d1f2643b43efca62ae3445849253b31aa1f1fa580be961bf28b6a4c99b854fc5396a4956879510437ccb50'
6
+ metadata.gz: 204fb049648dc6aed2da6adc4cea80196f26492dc8c20b5d91f8eaf1ad907bec2ea6a8e084b44e357fcfc04b5c3ad1f9546f4e7c9db748c9a102a5cdf82595c7
7
+ data.tar.gz: ad41cb2c48a677e369a5c991942164005b3073b91613f123d7169ffb04347aed033c9bcecd78bc79e3319f3eb26df6f16b0a578acafd5cc0580dda9341774928
@@ -1,4 +1,4 @@
1
- require 'active_support/core_ext/string/output_safety'
1
+ require "active_support/core_ext/string/output_safety"
2
2
 
3
3
  module HeroiconHelper
4
4
  HEROICONS_PATH = File.expand_path("assets/heroicons", __dir__)
@@ -9,25 +9,32 @@ module HeroiconHelper
9
9
  # @param options [Hash] additional options including custom CSS classes
10
10
  # @return [String] HTML safe string with the SVG content or error message
11
11
  def heroicon(name, type: "solid", **options)
12
+ # Allow strings or symbols for name and type arguments
13
+ name = name.to_s
14
+ type = type.to_s
15
+
16
+ # Handle class attribute
12
17
  custom_class = options.delete(:class) || ""
13
- # Handle style attribute separately to avoid unintended deletions
18
+
19
+ # Handle style attribute
14
20
  style_attribute = options.delete(:style)
15
21
 
16
- # Handle data- attributes, filtering out anything that doesn't start with 'data-'
17
- data_attributes = options.select { |key, _| key.to_s.start_with?('data-') }
22
+ # Handle data- attributes, filtering out anything that doesn"t start with "data-"
23
+ data_attributes = options.select { |key, _| key.to_s.start_with?("data-") }
18
24
  options.except!(*data_attributes.keys)
19
25
 
26
+ # Load the SVG icon
20
27
  gem_root = Gem::Specification.find_by_name("heroicon-rails").gem_dir
21
28
  icon_path = File.join(gem_root, "lib", "heroicon", "rails", "assets", "heroicons", type, "#{name}.svg")
22
29
  icon_content = File.read(icon_path)
23
30
  icon_doc = Nokogiri::HTML::DocumentFragment.parse(icon_content)
24
31
  svg = icon_doc.at_css("svg")
25
32
 
26
- # Apply custom classes
33
+ # Apply custom css classes
27
34
  custom_width_class = custom_class[/\bw-\d+/]
28
35
  custom_height_class = custom_class[/\bh-\d+/]
29
- default_width = custom_width_class ? '' : (type == "mini" ? "w-5" : "w-6")
30
- default_height = custom_height_class ? '' : (type == "mini" ? "h-5" : "h-6")
36
+ default_width = custom_width_class ? "" : (type == "mini" ? "w-5" : "w-6")
37
+ default_height = custom_height_class ? "" : (type == "mini" ? "h-5" : "h-6")
31
38
  css_classes = "#{default_width} #{default_height} #{custom_class}".strip
32
39
  svg[:class] = css_classes unless css_classes.empty?
33
40
 
@@ -48,7 +55,7 @@ module HeroiconHelper
48
55
  end
49
56
 
50
57
  icon_doc.to_html.html_safe
51
- rescue StandardError => e
52
- "Icon '#{name}' not found. Error: #{e.message}"
58
+ rescue StandardError
59
+ "Icon #{name} not found. Error: #{e.message}"
53
60
  end
54
61
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Heroicon
4
4
  module Rails
5
- VERSION = "0.2.6"
5
+ VERSION = "0.2.8"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroicon-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Weis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-20 00:00:00.000000000 Z
11
+ date: 2024-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport