avo-icons 0.2.0 → 0.2.1

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: ade5d8a320ddc48f948c992dddfb970d97a96073cab7e6cc57ca5a83488b38f7
4
- data.tar.gz: 946092a71177db88065762d270510253fc024da224fb5447284fa94fe8256f7d
3
+ metadata.gz: d7e1ba1003c871809b4a0e3d1ed7ba933698ab3b4e3195ab465410ed914d11be
4
+ data.tar.gz: 2be3955291f9dacbdbe213a4d1fdbd67d391c8bf07f791caca8780ea4e7e8c38
5
5
  SHA512:
6
- metadata.gz: 921503ad245c16ce813823ad1cc461926b1a70f1cf05f59912373d4c8b5c32b5286597115ab378430893259847c08cdee5726eddb906b2fbaa7b5d0710522682
7
- data.tar.gz: 4ac6b8449a17da2e984dd9b3db134d0ba1af810401d9031555c9adb6bf022369a0afccecbb351fa1c1fe4b642c07e6e77164f13b70db232ed10f6fe7e91bf391
6
+ metadata.gz: 3ce50600d3946cfa30f8971a16bf825cc2f3294ef06af591353d66712c689b41eb703c95ec17a325c4559b3e6145d8239f0f0871d2f3d5376be5c6dd9a4a95b7
7
+ data.tar.gz: b13e91c5981c074de4a251ecd4837ea6608acbc48cc05581aa77aff0c2b7a9c68947c88171cb680cb258fad961a6b20e820ef70d338cb8511ea7174fd596fc99
@@ -20,23 +20,41 @@ module Avo
20
20
 
21
21
  private
22
22
 
23
- # Override inline_svg's placeholder to use our own css class.
23
+ # Override inline_svg's placeholder, but only for lookups made through
24
+ # our #svg helper (detected via the asset finder thread-local). Host app
25
+ # calls to inline_svg/inline_svg_tag keep inline_svg's own behavior.
24
26
  # https://github.com/jamesmartin/inline_svg/blob/main/lib/inline_svg/action_view/helpers.rb#L61
25
27
  def placeholder(filename)
28
+ return avo_missing_svg_placeholder(filename) if Thread.current[:inline_svg_asset_finder] == Avo::Icons::SvgFinder
29
+ return super if defined?(super)
30
+
31
+ # Minimal silent placeholder for direct calls outside a full ActionView
32
+ # helper chain. Mirrors inline_svg's default shape only — it does not
33
+ # consult svg_not_found_css_class or add the extension hint.
34
+ escaped_filename = ERB::Util.html_escape_once(filename.to_s)
35
+ "<svg><!-- SVG file not found: '#{escaped_filename}' --></svg>".html_safe
36
+ end
37
+
38
+ # The loud debug glyph rendered when an Avo icon lookup misses.
39
+ def avo_missing_svg_placeholder(filename)
26
40
  css_class = "avo-missing-svg"
27
41
  escaped_filename = ERB::Util.html_escape_once(filename.to_s)
28
42
  missing_icon = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="icon icon-tabler icons-tabler-outline icon-tabler-ice-cream-off"><path stroke="none" d="M0 0h24v24H0z" fill="none" /><path d="M12 21.5v-4.5" /><path d="M8 8v9h8v-1m0 -4v-5a4 4 0 0 0 -7.277 -2.294" /><path d="M8 10.5l1.74 -.76m2.79 -1.222l3.47 -1.518" /><path d="M8 14.5l4.488 -1.964" /><path d="M3 3l18 18" /></svg>'
29
43
  "<div data-tippy='tooltip' class='#{css_class}' style='width: 2rem; height: 2rem; color: #ef4444;' title='SVG file not found: #{escaped_filename}'><!-- SVG file not found: '#{escaped_filename}' -->#{missing_icon}</div>".html_safe
30
44
  end
31
45
 
32
- # Taken from the original library
46
+ # Adapted from the original library, with an ensure so the Avo finder
47
+ # marker (which #placeholder keys off) cannot outlive the call — even
48
+ # when the block raises — and any pre-existing finder is restored
49
+ # instead of clobbered.
33
50
  # https://github.com/jamesmartin/inline_svg/blob/main/lib/inline_svg/action_view/helpers.rb#L76
34
51
  def with_asset_finder(asset_finder)
52
+ previous_asset_finder = Thread.current[:inline_svg_asset_finder]
35
53
  Thread.current[:inline_svg_asset_finder] = asset_finder
36
- output = yield
37
- Thread.current[:inline_svg_asset_finder] = nil
38
54
 
39
- output
55
+ yield
56
+ ensure
57
+ Thread.current[:inline_svg_asset_finder] = previous_asset_finder
40
58
  end
41
59
  end
42
60
  end
@@ -1,5 +1,5 @@
1
1
  module Avo
2
2
  module Icons
3
- VERSION = "0.2.0"
3
+ VERSION = "0.2.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avo-icons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Bob