railsui_icon 1.0.1 → 1.0.3

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: aabb52a9244cebba3bbe4f27b98de6e641f036623f93c05db799845e6d953fee
4
- data.tar.gz: 769f0953c601fa3a69b21edc071410827ad11b3c894bcfc38d6603729d42463d
3
+ metadata.gz: d45845912b9f9db2bd1ce2c19f8953fb20ed205b9156af38036c208710c1b7bc
4
+ data.tar.gz: 45dd58a2aeaa6ddcb07371f41d28e71a2edbec951197cb1c0d526789a0677d02
5
5
  SHA512:
6
- metadata.gz: f8402b00f1e32a4fd2c99f7cfa409febc378dc7d606f02545644e98828d44197f6b8fd5ee14712c91d4f44b4076807f9eddb0dbb606dcc4a99e88ccb57877eb4
7
- data.tar.gz: 85700d11e87da59f116e62281a608f712ba031a6720f4ff8e37cbaaf5b48919e646a008d65b08e21ad6025c74b3a2a4c5fa1a6ea249c5ad5f4c1dc583c44d2f3
6
+ metadata.gz: ff42b7699dbc33087a3cdd3fcc4b14b9ba35b81f10308f611f430271232b1ae6ad36e6557752dfd8d9ea35bd009b8de25ded5395f3d76386931b935aa7467d31
7
+ data.tar.gz: 1fba9f974a50d891eab7953a6d27adfde80549fca92607f3def566646606046610cc4a86e5ae98dbf564e80d79f4f0a85ebd91d4879d10629f7f0d37df2705a5
data/README.md CHANGED
@@ -104,7 +104,7 @@ If you set default classes in your configuration you can disable those explicitl
104
104
 
105
105
  **Pass a custom icon path**
106
106
 
107
- Additional icons can be sourced from `app/assets/images`. Pass a custom path to render those. It's assumed the icon will be the `.svg` format.
107
+ Additional icons can be sourced from `app/assets/images`. Pass a custom path to render those. It's assumed the icon will be the `.svg` format. The path should be relative with a leading slash.
108
108
 
109
109
  - An icon name or nil value for the name is still required.
110
110
  - The file suffix is required in this scenario.
@@ -112,14 +112,14 @@ Additional icons can be sourced from `app/assets/images`. Pass a custom path to
112
112
  ```erb
113
113
  <!-- Resolves from app/assets/images/logo.svg -->
114
114
 
115
- <%= icon "logo", custom_path: "logo.svg" %>
115
+ <%= icon "logo", custom_path: "/logo.svg" %>
116
116
 
117
117
  ```
118
118
 
119
119
  **The kitchen sink**
120
120
 
121
121
  ```erb
122
- <%= icon "star", variant: :micro, class: "size-3 fill-current text-pink-500", custom_path: "my_icons/star.svg", disable_default_class: true %>
122
+ <%= icon "star", variant: :micro, class: "size-3 fill-current text-pink-500", custom_path: "/my_icons/star.svg", disable_default_class: true %>
123
123
  ```
124
124
 
125
125
  ## Bugs
@@ -19,7 +19,6 @@ module RailsuiIcon
19
19
  def resolve_custom_path(path)
20
20
  return unless path
21
21
 
22
- # Check if the custom path is relative and convert it to an absolute asset path
23
22
  if Rails.application.config.assets.paths.any? { |p| path.start_with?(p) }
24
23
  path
25
24
  else
@@ -41,9 +41,23 @@ module RailsuiIcon
41
41
  end
42
42
 
43
43
  def render_custom_path(custom_path)
44
- asset_path = "app/assets/images/#{custom_path}"
45
- svg_content = File.read(asset_path)
44
+ # Check the engine's asset path first
45
+ engine_asset_path = Railsui::Engine.root.join("app/assets/images/#{custom_path}")
46
+
47
+ # Check the main app's asset path
48
+ app_asset_path = Rails.root.join("app/assets/images/#{custom_path}")
49
+
50
+ # Determine which path exists
51
+ asset_path = if File.exist?(engine_asset_path)
52
+ engine_asset_path
53
+ elsif File.exist?(app_asset_path)
54
+ app_asset_path
55
+ else
56
+ Rails.logger.error "Asset not found: #{engine_asset_path} and #{app_asset_path}"
57
+ return warning
58
+ end
46
59
 
60
+ svg_content = File.read(asset_path)
47
61
  doc = Nokogiri::HTML::DocumentFragment.parse(svg_content)
48
62
  svg = doc.at_css('svg')
49
63
 
@@ -1,3 +1,3 @@
1
1
  module RailsuiIcon
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: railsui_icon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Leverenz