rails_icons 1.8.0 → 1.10.0

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: 9d05be67d1c13063b9c5fca713d8ef525f2859bc06052909d5bd2df13bbede6f
4
- data.tar.gz: 37d0a613b5c7cbeac079203e5cd44337fd338f58f0e2b5ec8ad111cc4897e9b0
3
+ metadata.gz: 87983d78c763bf00cac5dfcff0cd432d9140643b12235dd3f549aa2d20a4a85f
4
+ data.tar.gz: 892fdb71667edd0e038265645e01a17757c5e16a8227b7265ed1dbb082d0213e
5
5
  SHA512:
6
- metadata.gz: 7d6fd9ff135d39bb5b02cb70e7a96b8a12d3f2f31c95c91cc0faab8280a87f54a97752254291bbe61083d409c7a125cef07d53f2ce7a0e2c4fceac28fbf11e66
7
- data.tar.gz: fdcffc8c5dfcbb944aea21f64994989d207b968764c0e74f9ff59fd5b8cab4294e15a9e4c35fbce918d3e4011d9e17566a0b6ef57c944a9c560c747c5ab2fe25
6
+ metadata.gz: 3f5c76f15631ed655d92d476c7c945f9a8e33981061fece4aed02ffc83b5cd84888d605c5e98b0b4496c97d7bf8b8a00798b6614010959799326ca10c67dea45
7
+ data.tar.gz: b9e806967af7a3aaf42d46e79dbc9433e4dd3d8ecd3781a66c24e33c15c54913ae95d31ad0de1dc87fb24a2431ef5e6fa9b6c07861ace8b2d51161af17564124
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_icons (1.8.0)
5
- icons (~> 0.8.1)
4
+ rails_icons (1.10.0)
5
+ icons (~> 0.11.0)
6
6
  rails (>= 7.0)
7
7
 
8
8
  GEM
@@ -102,7 +102,7 @@ GEM
102
102
  activesupport (>= 6.1)
103
103
  i18n (1.14.7)
104
104
  concurrent-ruby (~> 1.0)
105
- icons (0.8.1)
105
+ icons (0.11.0)
106
106
  nokogiri (~> 1.16, >= 1.16.4)
107
107
  io-console (0.8.1)
108
108
  irb (1.15.2)
data/README.md CHANGED
@@ -12,7 +12,7 @@ icon "check", class: "text-gray-500"
12
12
  icon "apple", library: "simple_icons", class: "text-black"
13
13
  ```
14
14
 
15
- The icons are sourced directly from their respective GitHub repositories, ensuring Rails Icons remain lightweight.
15
+ The icons are sourced directly from their respective GitHub repositories via the [Icons](https://github.com/Rails-Designer/icons) gem, ensuring Rails Icons remain lightweight.
16
16
 
17
17
 
18
18
  **Sponsored By [Rails Designer](https://railsdesigner.com/)**
@@ -44,6 +44,9 @@ rails generate rails_icons:install --library=heroicons
44
44
 
45
45
  # Or multiple at once
46
46
  rails generate rails_icons:install --libraries=heroicons lucide
47
+
48
+ # Or only specific variants
49
+ rails generate rails_icons:install --library=heroicons --variants solid outline
47
50
  ```
48
51
 
49
52
  The generator also mounts an icon preview at `/rails_icons` where you can browse and search all your available icons. This route is open by default, so restrict it in production if needed.
@@ -77,6 +80,97 @@ icon "check", stroke_width: 2
77
80
  ```
78
81
 
79
82
 
83
+ ## Sprites
84
+
85
+ Rails Icons supports SVG sprites for improved performance. Instead of inlining each icon's full SVG, sprite icons reference a shared set of `<symbol>` definitions via `<use href="…">`.
86
+
87
+
88
+ ### Configuration
89
+
90
+ ```ruby
91
+ # config/initializers/rails_icons.rb
92
+ RailsIcons.configure do |config|
93
+ config.default_library = "heroicons"
94
+ config.default_variant = "outline"
95
+
96
+ # Where `sprite_icon` references symbols. Defaults to the gem-served
97
+ # endpoint below. Set to nil to use inline mode (`<%= icons_sprite %>` in layout).
98
+ config.default_sprite_location = "/rails_icons/sprite.svg"
99
+
100
+ # Set to true to validate that referenced icons exist on disk
101
+ config.validate_sprite_icons = false
102
+
103
+ # Define which icons to include in the sprite
104
+ config.sprite = {
105
+ heroicons: {
106
+ outline: %w[check chevron-down menu search x],
107
+ mini: %w[check chevron-down]
108
+ }
109
+ }
110
+ end
111
+ ```
112
+
113
+
114
+ ### External sprite (default)
115
+
116
+ Rails Icons serves the sprite at `/rails_icons/sprite.svg` out of the box — no controller, route or MIME type setup needed. The endpoint sits at the host app level, so it stays reachable even when the preview engine is mounted behind authentication.
117
+ ```erb
118
+ <%= sprite_icon "check" %>
119
+ <%# renders: <svg><use href="/rails_icons/sprite.svg#heroicons_outline_check"></use></svg> %>
120
+ ```
121
+
122
+ Point at a precompiled file or a CDN by changing the location:
123
+ ```ruby
124
+ config.default_sprite_location = "https://cdn.example.com/sprite_icons.svg"
125
+ ```
126
+
127
+ Override per icon:
128
+ ```erb
129
+ <%= sprite_icon "check", sprite_location: "/assets/sprites.svg" %>
130
+ ```
131
+
132
+
133
+ ### Inline sprite
134
+
135
+ Set the location to `nil` and embed the sprite directly in your layout:
136
+ ```ruby
137
+ config.default_sprite_location = nil
138
+ ```
139
+
140
+ ```erb
141
+ <body>
142
+ <%= icons_sprite %>
143
+
144
+ <%= sprite_icon "check" %>
145
+ <%= sprite_icon "search", class: "text-blue-500" %>
146
+ <%= sprite_icon "menu", data: { controller: "nav" } %>
147
+ </body>
148
+ ```
149
+
150
+ You can also generate a sprite for a specific set of icons:
151
+ ```erb
152
+ <%= icons_sprite ["check", "search"], library: "heroicons", variant: "outline" %>
153
+ ```
154
+
155
+
156
+ ### Helpers
157
+
158
+ `sprite_icon` accepts the same options as `icon`:
159
+ ```ruby
160
+ sprite_icon "check"
161
+ sprite_icon "check", library: "heroicons", variant: "mini"
162
+ sprite_icon "check", class: "size-6", data: { controller: "swap" }, stroke_width: 2
163
+ sprite_icon "check", sprite_location: "/sprite.svg"
164
+ ```
165
+
166
+ `icons_sprite` generates the inline `<svg>` containing `<symbol>` definitions:
167
+ ```ruby
168
+ icons_sprite # all configured icons
169
+ icons_sprite ["check", "search"] # specific icons
170
+ icons_sprite ["check", "search"], library: "heroicons", variant: "outline" # with library/variant
171
+ ```
172
+
173
+
80
174
  ## First-party libraries
81
175
 
82
176
  - [Boxicons](https://railsdesigner.com/open-source/rails-icons/boxicons/) (1600+ icons)
@@ -105,19 +199,6 @@ Rails Icons also includes a few animated icons. Great for loading states and so
105
199
  Use like this: `icon "faded-spinner", library: "animated"`. The same attributes as the other libraries are available.
106
200
 
107
201
 
108
- ## Custom icon library
109
-
110
- Need to use an icon from another library (for example [Simple Icons](https://simpleicons.org/))?
111
-
112
- 1. run `rails generate rails_icons:initializer --custom=simple_icons`;
113
- 2. add the SVG icons to the created directory (*app/assets/svg/icons/simple_icons*);
114
-
115
- Every custom icon can now be used with the same interface as first-party icon libraries:
116
- ```ruby
117
- icon "apple", library: "simple_icons", class: "text-black"
118
- ```
119
-
120
-
121
202
  ## Sync icons
122
203
 
123
204
  To sync all libraries, run:
@@ -133,12 +214,52 @@ rails generate rails_icons:sync --library=heroicons
133
214
  rails generate rails_icons:sync --libraries=heroicons lucide
134
215
  ```
135
216
 
217
+ To sync only specific variants for a library:
218
+ ```bash
219
+ rails generate rails_icons:sync --library=heroicons --variants solid outline
220
+ ```
221
+
222
+
223
+ ## Custom icon libraries
224
+
225
+ Rails Icons pulls SVGs straight from the path `<icons_path>/<library_name>/<name>.svg`. No generator is required for custom icons. Configuration is optional and only used to define defaults.
226
+
227
+ To add a custom library, create its directory and drop in your SVGs:
228
+
229
+ ```
230
+ app/assets/svg/icons/simple_icons/apple.svg
231
+ ```
232
+
233
+ (Alternatively, scaffold it with `rails generate rails_icons:install --library=simple_icons`, which creates the directory and adds `config.custom_library :simple_icons` in the initializer.)
234
+
235
+ Use them like any other library:
236
+
237
+ ```ruby
238
+ icon "apple", library: :simple_icons
239
+ ```
240
+
241
+ To add a git source for syncing, edit the initializer:
242
+ ```ruby
243
+ RailsIcons.configure do |config|
244
+ config.custom_library :my_icons, source: {
245
+ url: "https://github.com/user/icons.git",
246
+ variants: { default: "." }
247
+ }
248
+ end
249
+ ```
250
+
251
+ Then sync:
252
+ ```bash
253
+ rails generate rails_icons:sync --library=my_icons
254
+ ```
255
+
136
256
 
137
257
  ## Projects using Rails Icons
138
258
 
139
259
  - [Rails Designer UI Components](https://railsdesigner.com/components/) — The first professionally-designed UI components library for Ruby on Rails apps
140
260
  - [Chirp Form](https://chirpform.com/) — Add forms to any site. Display responses anywhere
141
- - [Helptail](https://helptail.com/) — Put your routine tasks on autopilot
261
+ - [Seal Static](https://sealstatic.com/) — Host sites for every need
262
+ - [Spinal CMS](https://spinalcms.com/) — Minimal and beautiful CMS for static site generators
142
263
 
143
264
 
144
265
  ## Contributing
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsIcons
4
+ class SpritesController < ActionController::Base
5
+ def show
6
+ expires_in RailsIcons.sprite_cache_expires_in, public: true
7
+
8
+ respond_to do |format|
9
+ format.svg { render plain: Icons::Sprite.new.svg, content_type: "image/svg+xml" }
10
+ end
11
+ end
12
+ end
13
+ end
@@ -8,10 +8,9 @@ module RailsIcons
8
8
 
9
9
  desc "Create the Rails Icons initializer."
10
10
 
11
- class_option :library, type: :string, desc: "Choose a library (#{RailsIcons.libraries.keys.join("/")})"
12
- class_option :libraries, type: :array, default: [], desc: "Choose libraries (#{RailsIcons.libraries.keys.join("/")})"
13
- class_option :destination, type: :string, default: RailsIcons.configuration.icons_path, desc: "Specify icons folder"
14
- class_option :custom, type: :string, desc: "Name of the custom library"
11
+ class_option :library, type: :string, desc: "Choose a library"
12
+ class_option :libraries, type: :array, default: [], desc: "Choose libraries"
13
+ class_option :destination, type: :string, default: RailsIcons.configuration&.icons_path, desc: "Specify icons folder"
15
14
 
16
15
  def copy_initializer
17
16
  return if File.exist?(INITIALIZER)
@@ -34,7 +33,7 @@ module RailsIcons
34
33
  end
35
34
 
36
35
  def insert_custom_icons_path
37
- return if options[:destination] && options[:destination] == RailsIcons.configuration.icons_path
36
+ return if options[:destination] == RailsIcons.configuration&.icons_path
38
37
 
39
38
  insert_into_file INITIALIZER, <<~RB.indent(2), after: "RailsIcons.configure do |config|\n"
40
39
  # Default icons path
@@ -44,49 +43,39 @@ module RailsIcons
44
43
  end
45
44
 
46
45
  def insert_libraries_configuration
46
+ return if first_party_libraries.empty?
47
+
47
48
  insert_into_file INITIALIZER, "\n#{library_configuration}", before: "end"
48
49
  end
49
50
 
50
- def setup_custom_configuration
51
- return if options[:custom].blank?
51
+ def setup_custom_libraries
52
+ return if custom_libraries.empty?
53
+
54
+ insert_into_file INITIALIZER, "\n#{custom_library_configuration}", before: "end"
52
55
 
53
- insert_custom_configuration
54
- create_custom_directory
56
+ custom_libraries.each do |name|
57
+ FileUtils.mkdir_p(File.join(options[:destination], name))
58
+ end
55
59
  end
56
60
 
57
61
  private
58
62
 
59
63
  INITIALIZER = "config/initializers/rails_icons.rb"
60
64
 
61
- def insert_custom_configuration
62
- unless file_contains?(INITIALIZER, "config.libraries.merge!")
63
- custom_default_configuration = <<~RB.indent(2)
64
-
65
- config.libraries.merge!(
66
- )
67
- RB
68
-
69
- insert_into_file INITIALIZER, custom_default_configuration, before: "end"
70
- end
71
-
72
- insert_into_file INITIALIZER, "\n#{custom_configuration}", after: "config.libraries.merge!("
65
+ def library_configuration
66
+ first_party_libraries.map { |library| RailsIcons.libraries[library.to_sym].initializer_config }.join("\n")
73
67
  end
74
68
 
75
- def create_custom_directory = FileUtils.mkdir_p(File.join(options[:destination], options[:custom]))
69
+ def custom_library_configuration
70
+ custom_libraries.map { |name| "config.custom_library :#{name}" }.join("\n")
71
+ end
76
72
 
77
- def library_configuration
78
- libraries.map { |library| RailsIcons.libraries[library.to_sym].initializer_config }.join("\n")
73
+ def first_party_libraries
74
+ libraries.select { |library| RailsIcons.libraries.key?(library.to_sym) }
79
75
  end
80
76
 
81
- def custom_configuration
82
- <<~RB.indent(4)
83
- #{options[:custom]}: {
84
- # path: "app/assets/svg/icons/#{options[:custom]}/",
85
- default: {
86
- css: "size-6"
87
- }
88
- }
89
- RB
77
+ def custom_libraries
78
+ libraries.reject { |library| RailsIcons.libraries.key?(library.to_sym) }
90
79
  end
91
80
 
92
81
  def default_configuration_exists?
@@ -12,15 +12,16 @@ module RailsIcons
12
12
  class_option :libraries, type: :array, default: [], desc: "Choose libraries (#{RailsIcons.libraries.keys.join("/")})"
13
13
  class_option :destination, type: :string, default: RailsIcons.configuration.icons_path, desc: "Specify destination folder for icons"
14
14
  class_option :skip_sync, type: :boolean, default: false
15
+ class_option :variants, type: :array, desc: "Only sync specific variants (e.g. solid outline)"
15
16
 
16
17
  def initializer_generator
17
18
  generate("rails_icons:initializer", *attributes)
18
19
  end
19
20
 
20
21
  def sync_generator
21
- return if options[:skip_sync] || libraries.blank?
22
+ return if options[:skip_sync] || sync_libraries.blank?
22
23
 
23
- generate("rails_icons:sync", *attributes)
24
+ generate("rails_icons:sync", "--libraries=#{sync_libraries.map(&:downcase).join(" ")}")
24
25
  end
25
26
 
26
27
  def add_route
@@ -34,13 +35,19 @@ module RailsIcons
34
35
  private
35
36
 
36
37
  def attributes
37
- ["--libraries=#{libraries.map(&:downcase).join(" ")}", "--destination=#{options[:destination]}"].join(" ")
38
+ ["--libraries=#{libraries.map(&:downcase).join(" ")}", "--destination=#{options[:destination]}"].tap do |parts|
39
+ parts << "--variants=#{options[:variants].join(" ")}" if options[:variants].present?
40
+ end.join(" ")
38
41
  end
39
42
 
40
43
  def libraries
41
44
  [*options.libraries, options.library].compact_blank
42
45
  end
43
46
 
47
+ def sync_libraries
48
+ libraries.select { |library| RailsIcons.libraries.key?(library.to_sym) }
49
+ end
50
+
44
51
  def validatable? = true
45
52
  end
46
53
  end
@@ -10,13 +10,18 @@ module RailsIcons
10
10
 
11
11
  class_option :library, type: :string, desc: "Choose a library (#{RailsIcons.libraries.keys.join("/")})"
12
12
  class_option :libraries, type: :array, default: [], desc: "Choose libraries (#{RailsIcons.libraries.keys.join("/")})"
13
+ class_option :variants, type: :array, desc: "Only sync specific variants (e.g. solid outline)"
13
14
 
14
15
  def sync_icons
15
- libraries.each { |library| Icons::Sync.new(library).now }
16
+ libraries.each { |library| Icons::Sync.new(library, variants: variants).now }
16
17
  end
17
18
 
18
19
  private
19
20
 
21
+ def variants
22
+ options[:variants]&.map(&:to_sym)
23
+ end
24
+
20
25
  def libraries
21
26
  [options[:library], *options[:libraries]]
22
27
  .compact_blank
@@ -13,10 +13,7 @@ module RailsIcons
13
13
  private
14
14
 
15
15
  def validate!
16
- return if custom_library?
17
-
18
- raise Icons::LibraryNotFound.new("") if libraries.empty?
19
- raise Icons::LibraryNotFound.new(invalid_libraries.join(", ")) if invalid_libraries.any?
16
+ raise Icons::LibraryNotFound.new if libraries.empty?
20
17
  end
21
18
 
22
19
  def validatable? = false
@@ -25,14 +22,6 @@ module RailsIcons
25
22
  [*options.libraries, options.library].compact_blank
26
23
  end
27
24
 
28
- def invalid_libraries
29
- libraries.map(&:to_sym).map(&:downcase).reject { |library| RailsIcons.libraries.key?(library) }
30
- end
31
-
32
- def custom_library?
33
- options.custom.present?
34
- end
35
-
36
25
  # Uses `gsub_file` as a read-only operation to check file content. This
37
26
  # approach is preferred over `File.read` because `gsub_file` is properly stubbed
38
27
  # in generator tests, while `File.read` would fail in the test environment.
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails_icons/helpers/icon_helper"
4
+ require "rails_icons/helpers/sprite_helper"
4
5
 
5
6
  module RailsIcons
6
7
  class Engine < ::Rails::Engine
@@ -12,9 +13,31 @@ module RailsIcons
12
13
  end
13
14
  end
14
15
 
16
+ initializer "rails_icons.sprite_configuration", before: :load_config_initializers do
17
+ Icons.configure do |config|
18
+ config.sprite = {}
19
+ config.default_sprite_location = "/rails_icons/sprite.svg"
20
+ config.validate_sprite_icons = false
21
+ end
22
+ end
23
+
24
+ initializer "rails_icons.mime_types", before: :load_config_initializers do
25
+ Mime::Type.register "image/svg+xml", :svg unless Mime::Type.lookup_by_extension(:svg)
26
+ end
27
+
28
+ initializer "rails_icons.sprite_route", after: :load_config_initializers do |app|
29
+ app.routes.prepend do
30
+ get "/rails_icons/sprite.svg",
31
+ to: "rails_icons/sprites#show",
32
+ as: :rails_icons_sprite,
33
+ defaults: {format: :svg}
34
+ end
35
+ end
36
+
15
37
  initializer "rails_icons.helpers" do
16
38
  ActiveSupport.on_load(:action_view) do
17
39
  include RailsIcons::Helpers::IconHelper
40
+ include RailsIcons::Helpers::SpriteHelper
18
41
  end
19
42
  end
20
43
  end
@@ -3,6 +3,20 @@
3
3
  module RailsIcons
4
4
  module Helpers
5
5
  module IconHelper
6
+ # Renders an SVG icon
7
+ #
8
+ # @param name [String] The icon name
9
+ # @param library [String] The icon library (defaults to RailsIcons configuration)
10
+ # @param from [String] Syntactic sugar for a cleanly readable view layer API (preferred over `library`)
11
+ # @param variant [String] The icon variant (optional)
12
+ # @param arguments [Hash] Additional arguments including class, data, stroke_width, etc.
13
+ # @return [ActiveSupport::SafeBuffer] An HTML-safe SVG string
14
+ #
15
+ # @example
16
+ # <%= icon "chevron-down" %>
17
+ # <%= icon "search", class: "text-blue-500" %>
18
+ # <%= icon "check", variant: "solid", library: "heroicons" %>
19
+ #
6
20
  def icon(name, library: RailsIcons.configuration.default_library, from: library, variant: nil, **arguments)
7
21
  Icons::Icon.new(
8
22
  name: name,
@@ -12,6 +26,19 @@ module RailsIcons
12
26
  ).svg.html_safe
13
27
  end
14
28
 
29
+ # Returns a base64-encoded data URI for an SVG icon
30
+ #
31
+ # @param name [String] The icon name
32
+ # @param library [String] The icon library (defaults to RailsIcons configuration)
33
+ # @param from [String] Syntactic sugar for a cleanly readable view layer API (preferred over `library`)
34
+ # @param variant [String] The icon variant (optional)
35
+ # @param arguments [Hash] Additional arguments including class, data, stroke_width, etc.
36
+ # @return [String] A base64-encoded data URI string (e.g. "data:image/svg+xml;base64,...")
37
+ #
38
+ # @example
39
+ # encoded_icon "chevron-down"
40
+ # # => "data:image/svg+xml;base64,PHN2ZyB4bWxucz0..."
41
+ #
15
42
  def encoded_icon(name, library: RailsIcons.configuration.default_library, from: library, variant: nil, **arguments)
16
43
  svg_content = Icons::Icon.new(
17
44
  name: name,
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "icons/sprite_icon"
4
+
5
+ module RailsIcons
6
+ module Helpers
7
+ module SpriteHelper
8
+ # Renders an SVG icon from a sprite, compatible with Rails Icons API
9
+ #
10
+ # @param name [String] The icon name
11
+ # @param library [String] The icon library (defaults to RailsIcons configuration)
12
+ # @param from [String] Syntactic sugar for a cleanly readable view layer API (preferred over `library`)
13
+ # @param variant [String] The icon variant (optional)
14
+ # @param sprite_location [String] Override sprite URL (optional)
15
+ # @param arguments [Hash] Additional arguments including class, data, stroke_width, etc.
16
+ #
17
+ # @return [ActiveSupport::SafeBuffer] An HTML-safe SVG string referencing a sprite symbol
18
+ #
19
+ # @example
20
+ # <%= sprite_icon "chevron-down" %>
21
+ # <%= sprite_icon "search", class: "text-blue-500" %>
22
+ # <%= sprite_icon "check", variant: "solid", library: "heroicons" %>
23
+ # <%= sprite_icon "heart", library: "lucide", data: { controller: "favorite" } %>
24
+ #
25
+ def sprite_icon(name, library: nil, from: library, variant: nil, sprite_location: nil, **arguments)
26
+ Icons::SpriteIcon.new(
27
+ name: name,
28
+ library: from || library || RailsIcons.configuration.default_library,
29
+ variant: variant,
30
+ sprite_location: sprite_location,
31
+ arguments: arguments
32
+ ).svg.html_safe
33
+ end
34
+
35
+ # Returns the inline SVG sprite content containing all symbols
36
+ #
37
+ # @param icons [Array<String>] Optional array of icon names to include (defaults to all configured icons)
38
+ # @param library [String] Optional library to use for icons
39
+ # @param variant [String] Optional variant to use for icons
40
+ #
41
+ # @return [ActiveSupport::SafeBuffer] An HTML-safe SVG string containing `<symbol>` elements
42
+ #
43
+ # @example
44
+ # <%= icons_sprite %>
45
+ # <%= icons_sprite(["check", "search", "menu"]) %>
46
+ # <%= icons_sprite(["check", "search"], library: "heroicons", variant: "outline") %>
47
+ #
48
+ def icons_sprite(icons = nil, library: nil, variant: nil)
49
+ Icons::Sprite.new(icons: icons, library: library, variant: variant).svg.html_safe
50
+ end
51
+ end
52
+ end
53
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsIcons
2
- VERSION = "1.8.0"
2
+ VERSION = "1.10.0"
3
3
  end
data/lib/rails_icons.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support/core_ext/numeric/time"
3
4
  require "icons"
4
5
 
5
6
  require_relative "rails_icons/version"
@@ -7,11 +8,22 @@ require_relative "rails_icons/engine"
7
8
 
8
9
  module RailsIcons
9
10
  class << self
11
+ attr_accessor :sprite_cache_expires_in
12
+
13
+ # @yield [config] Yields a configuration object
14
+ # @yieldparam config [Icons::Configuration]
15
+ #
10
16
  def configure(&block) = Icons.configure(&block)
11
17
 
18
+ # @return [Icons::Configuration]
19
+ #
12
20
  def configuration = Icons.configuration
13
21
  alias_method :config, :configuration
14
22
 
23
+ # @return [Hash{Symbol => Icons::Library}] The registered icon libraries
24
+ #
15
25
  def libraries = Icons.libraries
16
26
  end
27
+
28
+ self.sprite_cache_expires_in = 1.hour
17
29
  end
data/rails_icons.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "Add any icon library to a Rails app"
12
12
  spec.description = "Add any icon library to a Rails app, from Heroicons, to Lucide to Tabler (and others). Rails Icons is library-agnostic, so you can add any library while using the same interface."
13
- spec.homepage = "https://railsdesigner.com/rails-icons/"
13
+ spec.homepage = "https://railsdesigner.com/open-source/rails-icons/"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.metadata["homepage_uri"] = spec.homepage
@@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
19
19
  spec.files = Dir["{bin,app,config,db,lib,public}/**/*", "Rakefile", "README.md", "rails_icons.gemspec", "Gemfile", "Gemfile.lock"]
20
20
 
21
21
  spec.add_dependency "rails", ">= 7.0"
22
- spec.add_dependency "icons", "~> 0.8.1"
22
+ spec.add_dependency "icons", "~> 0.11.0"
23
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_icons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rails Designer Developers
@@ -29,14 +29,14 @@ dependencies:
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 0.8.1
32
+ version: 0.11.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 0.8.1
39
+ version: 0.11.0
40
40
  description: Add any icon library to a Rails app, from Heroicons, to Lucide to Tabler
41
41
  (and others). Rails Icons is library-agnostic, so you can add any library while
42
42
  using the same interface.
@@ -54,6 +54,7 @@ files:
54
54
  - app/assets/javascripts/rails_icons/preview/preview.js
55
55
  - app/assets/stylesheets/rails_icons/preview.css
56
56
  - app/controllers/rails_icons/previews_controller.rb
57
+ - app/controllers/rails_icons/sprites_controller.rb
57
58
  - app/models/rails_icons/preview.rb
58
59
  - app/models/rails_icons/preview/tags.rb
59
60
  - app/models/rails_icons/preview/tags/animated.yml
@@ -82,14 +83,15 @@ files:
82
83
  - lib/rails_icons/engine.rb
83
84
  - lib/rails_icons/generate_tags.rb
84
85
  - lib/rails_icons/helpers/icon_helper.rb
86
+ - lib/rails_icons/helpers/sprite_helper.rb
85
87
  - lib/rails_icons/version.rb
86
88
  - lib/ruby_lsp/rails_icons/addon.rb
87
89
  - rails_icons.gemspec
88
- homepage: https://railsdesigner.com/rails-icons/
90
+ homepage: https://railsdesigner.com/open-source/rails-icons/
89
91
  licenses:
90
92
  - MIT
91
93
  metadata:
92
- homepage_uri: https://railsdesigner.com/rails-icons/
94
+ homepage_uri: https://railsdesigner.com/open-source/rails-icons/
93
95
  source_code_uri: https://github.com/Rails-Designer/rails_icons/
94
96
  rdoc_options: []
95
97
  require_paths:
@@ -105,7 +107,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
107
  - !ruby/object:Gem::Version
106
108
  version: '0'
107
109
  requirements: []
108
- rubygems_version: 4.0.9
110
+ rubygems_version: 4.0.22
109
111
  specification_version: 4
110
112
  summary: Add any icon library to a Rails app
111
113
  test_files: []