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 +4 -4
- data/lib/avo/icons/helpers.rb +23 -5
- data/lib/avo/icons/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d7e1ba1003c871809b4a0e3d1ed7ba933698ab3b4e3195ab465410ed914d11be
|
|
4
|
+
data.tar.gz: 2be3955291f9dacbdbe213a4d1fdbd67d391c8bf07f791caca8780ea4e7e8c38
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ce50600d3946cfa30f8971a16bf825cc2f3294ef06af591353d66712c689b41eb703c95ec17a325c4559b3e6145d8239f0f0871d2f3d5376be5c6dd9a4a95b7
|
|
7
|
+
data.tar.gz: b13e91c5981c074de4a251ecd4837ea6608acbc48cc05581aa77aff0c2b7a9c68947c88171cb680cb258fad961a6b20e820ef70d338cb8511ea7174fd596fc99
|
data/lib/avo/icons/helpers.rb
CHANGED
|
@@ -20,23 +20,41 @@ module Avo
|
|
|
20
20
|
|
|
21
21
|
private
|
|
22
22
|
|
|
23
|
-
# Override inline_svg's placeholder
|
|
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
|
-
#
|
|
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
|
-
|
|
55
|
+
yield
|
|
56
|
+
ensure
|
|
57
|
+
Thread.current[:inline_svg_asset_finder] = previous_asset_finder
|
|
40
58
|
end
|
|
41
59
|
end
|
|
42
60
|
end
|
data/lib/avo/icons/version.rb
CHANGED