rails_icons 0.4.0 → 1.1.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.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/README.md +75 -60
  4. data/app/assets/svg/rails_icons/icons/animated/bouncing-dots.svg +1 -0
  5. data/app/assets/svg/rails_icons/icons/animated/faded-spinner.svg +1 -0
  6. data/app/assets/svg/rails_icons/icons/animated/fading-dots.svg +1 -0
  7. data/app/assets/svg/rails_icons/icons/animated/trailing-spinner.svg +1 -0
  8. data/lib/generators/rails_icons/initializer_generator.rb +89 -2
  9. data/lib/generators/rails_icons/install_generator.rb +27 -0
  10. data/lib/generators/rails_icons/sync_generator.rb +16 -37
  11. data/lib/generators/rails_icons/templates/initializer.rb.tt +0 -16
  12. data/lib/rails_icons/configuration/animated.rb +24 -0
  13. data/lib/rails_icons/configuration/boxicons.rb +74 -0
  14. data/lib/rails_icons/configuration/feather.rb +45 -0
  15. data/lib/rails_icons/configuration/heroicons.rb +101 -0
  16. data/lib/rails_icons/configuration/lucide.rb +50 -0
  17. data/lib/rails_icons/configuration/phosphor.rb +141 -0
  18. data/lib/rails_icons/configuration/radix.rb +44 -0
  19. data/lib/rails_icons/configuration/tabler.rb +67 -0
  20. data/lib/rails_icons/configuration.rb +13 -12
  21. data/lib/rails_icons/helpers/icon_helper.rb +3 -4
  22. data/lib/rails_icons/icon/attributes.rb +9 -3
  23. data/lib/rails_icons/icon/file_path.rb +57 -0
  24. data/lib/rails_icons/icon.rb +37 -45
  25. data/lib/rails_icons/libraries.rb +24 -0
  26. data/lib/rails_icons/railtie.rb +6 -0
  27. data/lib/rails_icons/sync/engine.rb +75 -0
  28. data/lib/rails_icons/sync/process_variants.rb +64 -0
  29. data/lib/rails_icons/sync/transformations.rb +27 -0
  30. data/lib/rails_icons/version.rb +1 -1
  31. data/lib/rails_icons.rb +2 -12
  32. data/rails_icons.gemspec +3 -3
  33. metadata +26 -10
  34. data/lib/rails_icons/icon_configs/heroicons_config.rb +0 -66
  35. data/lib/rails_icons/icon_configs/lucide_config.rb +0 -28
  36. data/lib/rails_icons/icon_configs/tabler_config.rb +0 -41
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b822f3cdeb49bbe4e7d23109b89d0508e4b23e39c5da7b1c26a633977744b6f
4
- data.tar.gz: 0becd12bf8f1a1ce9ae6f35877cb8c0ef936d8b6e2693d04849c8716fccb8c7e
3
+ metadata.gz: 628225582b62195c9f7bc3994d9fcad7aa37dc563b4d0e73069c5efdddd81332
4
+ data.tar.gz: 3241569575d809f7c6bbce51804cab8255df585f24a9473878432d2930596fcb
5
5
  SHA512:
6
- metadata.gz: b34876d807ff8d3bb63faae9cb71d9a5527eee3543b1ce8b37034fe7719e8420149a202c3d1be2b0251d04fa7ebc0e52d0b6628570a045b8c469f84d56e3aace
7
- data.tar.gz: 81f8bd92e599e2fa2ff1421ab75ff334728f06792063dfd7ae2a74a0559ae5b73778192e64c1d772ea1fb2e2cb32e43cecd809e0985d91f3386488f9f87d0810
6
+ metadata.gz: c4226fb17440c8eb8949ecce47be982b7dc17f022e33b1bccc640dbd16b700096e2f6867dceace37c597e56919be83621523ac8f842976365dc81517149bf4cc
7
+ data.tar.gz: 1c1b35579576475f1b06ccf56416850c3d333402ebfefc63b8b1250b4317a196b04b15512ca5ac17cd26faba7298439114b4f175803c564ecbf1d22123db3eba
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_icons (0.4.0)
4
+ rails_icons (1.1.0)
5
5
  nokogiri (~> 1.16, >= 1.16.4)
6
6
  rails (> 6.1)
7
7
 
data/README.md CHANGED
@@ -1,112 +1,127 @@
1
1
  # Rails Icons
2
2
 
3
- Embed any library's icon in your Rails app. There are many icon gems for Rails already, but none are library-agnostic. This means you need to pull in other gems or add your logic to display that one specific icon.
3
+ Add any icon library to a Rails app. Rails Icons has first-party support for a [handful of libraries](#first-party-libraries). It is library agnostic so it can be used with any icon library using the same interface.
4
4
 
5
- The first-party supported icons are stored in a seperate repo: [rails_icons_vault](https://github.com/Rails-Designer/rails_icons_vault). This allows you to pull in only the icon libraries you need, keeping the rails_icons gem lean and lightweight.
5
+ ```erb
6
+ # Using the default icon library
7
+ <%= icon "check", class: "text-gray-500" %>
8
+
9
+ # Using any custom library
10
+ <%= icon "apple", library: "simple_icons", class: "text-black" %>
11
+ ```
12
+
13
+ The icons are sourced directly from their respective GitHub repositories, ensuring Rails Icons remain lightweight.
6
14
 
7
15
 
8
- ## Sponsored By [Rails Designer](https://railsdesigner.com/)
16
+ **Sponsored By [Rails Designer](https://railsdesigner.com/)**
9
17
 
10
18
  <a href="https://railsdesigner.com/" target="_blank">
11
- <img src="https://raw.githubusercontent.com/Rails-Designer/rails_icons/main/docs/rails_designer_icon.jpg" alt="Rails Designer logo" width="300" />
19
+ <picture>
20
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Rails-Designer/rails_icons/HEAD/.github/logo-dark.svg">
21
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/Rails-Designer/rails_icons/HEAD/.github/logo-light.svg">
22
+ <img alt="Rails Designer" src="https://raw.githubusercontent.com/Rails-Designer/rails_icons/HEAD/.github/logo-light.svg" width="240" style="max-width: 100%;">
23
+ </picture>
12
24
  </a>
13
25
 
14
26
 
15
27
  ## Install
16
28
 
17
- Add this line to your Gemfile:
18
-
19
- ```ruby
20
- gem "rails_icons"
29
+ Add the gem
30
+ ```bash
31
+ bundle add rails_icons
21
32
  ```
22
33
 
23
- And run:
24
-
34
+ Install, choosing one of the supported libraries
25
35
  ```bash
26
- bundle
36
+ rails generate rails_icons:install --libraries=LIBRARY_NAME
27
37
  ```
28
38
 
29
- Sync any of the supported icon libraries from the
30
- [rails_icons_vault](https://github.com/Rails-Designer/rails_icons_vault):
31
-
39
+ **Example**
32
40
  ```bash
33
- rails generate rails_icons:sync heroicons
41
+ rails generate rails_icons:install --libraries=heroicons
42
+
43
+ Or multiple at once
44
+ rails generate rails_icons:install --libraries=heroicons lucide
34
45
  ```
35
46
 
36
47
 
37
48
  ## Usage
38
49
 
39
50
  ```ruby
40
- # The default library is Heroicons, with "outline" as the default set
51
+ # Uses the default library and variant defined in config/initializer/rails_icons.rb
41
52
  icon "check"
42
53
 
43
- # Use another set (options are: outline, solid, mini, micro)
44
- icon "check", set: "solid"
54
+ # Use another variant
55
+ icon "check", variant: "solid"
45
56
 
46
- # Add CSS to the icon
57
+ # Set library explictly
58
+ icon "check", library: "heroicons"
59
+
60
+ # Add CSS
47
61
  icon "check", class: "text-green-500"
48
62
 
63
+ # Add CSS with class_names
64
+ # article: https://railsdesigner.com/conditional-css-classes-in-rails/
65
+ # docs: https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#method-i-token_list
66
+ icon "check", class: ["size-4", "bg-red-500": !verified?, "bg-green-500": verified?]
67
+
49
68
  # Add data attributes
50
69
  icon "check", data: { controller: "swap" }
51
70
 
52
- # Tweak the stroke-width
71
+ # Set the stroke-width
53
72
  icon "check", stroke_width: 2
54
73
  ```
55
74
 
56
75
 
57
- ## Initializer
76
+ ## First-party libraries
58
77
 
59
- ```ruby
60
- RailsIcons.configure do |config|
61
- # Set the default set for the library
62
- config.default_library = "heroicons"
63
- config.default_set = "outline"
78
+ - [Boxicons](https://github.com/atisawd/boxicons) (1600+ icons)
79
+ - [Feather](https://github.com/feathericons/feather) (280+ icons)
80
+ - [Heroicons](https://github.com/tailwindlabs/heroicons) (300+ icons)
81
+ - [Lucide](https://github.com/lucide-icons/lucide) (1500+ icons)
82
+ - [Phosphor](https://github.com/phosphor-icons/core) (9000+ icons)
83
+ - [Radix](https://github.com/radix-ui/icons/) (300+ icons)
84
+ - [Tabler](https://github.com/tabler/tabler-icons) (5700+ icons)
64
85
 
65
- config.libraries.heroicons.solid.default.css = "w-6 h-6"
66
- config.libraries.heroicons.solid.default.data = {}
67
86
 
68
- config.libraries.heroicons.outline.default.css = "w-6 h-6"
69
- config.libraries.heroicons.outline.default.stroke_width = "1.5"
70
- config.libraries.heroicons.outline.default.data = {}
87
+ ## Animated icons
71
88
 
72
- config.libraries.heroicons.mini.default.css = "w-5 h-5"
73
- config.libraries.heroicons.mini.default.data = {}
89
+ Rails Icons also includes a few animated icons. Great for loading states and so on. These are currently included:
74
90
 
75
- config.libraries.heroicons.micro.default.css = "w-4 h-4"
76
- config.libraries.heroicons.micro.default.data = {}
77
- end
78
- ```
91
+ - `faded-spinner`
92
+ - `trailing-spinner`
93
+ - `fading-dots`
94
+ - `bouncing-dots`
95
+
96
+ Use like this: `icon "faded-spinner", library: "animated"`. The same attributes as other libraries are available.
79
97
 
80
- Or run `rails generate rails_icons:initializer`.
81
98
 
99
+ ## Custom icon library
82
100
 
83
- ## Add a custom icon library
101
+ Need to use an icon from another library?
84
102
 
103
+ 1. run `rails generate rails_icons:initializer --custom=simple_icons`;
104
+ 2. add the (SVG) icons to the created directory **app/assets/svg/icons/simple_icons**;
105
+
106
+ Every custom icon can now be used with the same interface as first-party icon libraries.
85
107
  ```ruby
86
- RailsIcons.configure do |config|
87
- # …
88
- config.libraries.merge!(
89
- {
90
- custom: {
91
- simple_icons: {
92
- solid: {
93
- path: "app/assets/svg/simple_icons/solid", # optional: the default lookup path is: `app/assets/svg/#{library_name}/#{set}`
94
- default: {
95
- css: "w-6 h-6"
96
- }
97
- }
98
- }
99
- }
100
- }
101
- )
102
- # …
103
- end
108
+ icon "apple", library: "simple_icons", class: "text-black"
104
109
  ```
105
110
 
106
- You can now use any svg-icon in the `app/assets/svg/simple_icons/solid` folder as a first-party icon:
107
111
 
108
- ```ruby
109
- icon "reddit", library: "simple_icons", set: "solid"
112
+ ## Sync icons
113
+
114
+ To sync all installed libraries, run
115
+ ```bash
116
+ rails generate rails_icons:sync
117
+ ```
118
+
119
+ To sync only a specific library, run
120
+ ```bash
121
+ rails generate rails_icons:sync --libraries=heroicons
122
+
123
+ # Or multiple at once:
124
+ rails generate rails_icons:sync --libraries=heroicons lucide
110
125
  ```
111
126
 
112
127
 
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle fill="currentColor" stroke="none" cx="4" cy="12" r="2.5"><animateTransform attributeName="transform" dur="1s" type="translate" values="0 3.6 ; 0 -3.6; 0 3.6" repeatCount="indefinite" begin="0.1"></animateTransform></circle><circle fill="currentColor" stroke="none" cx="12" cy="12" r="2.5"><animateTransform attributeName="transform" dur="1s" type="translate" values="0 2.4 ; 0 -2.4; 0 2.4" repeatCount="indefinite" begin="0.2"></animateTransform></circle><circle fill="currentColor" stroke="none" cx="20" cy="12" r="2.5"><animateTransform attributeName="transform" dur="1s" type="translate" values="0 1.2 ; 0 -1.2; 0 1.2" repeatCount="indefinite" begin="0.3"></animateTransform></circle></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" ><defs><style>@keyframes spin {to{transform:rotate(360deg);}}</style></defs><g style="transform-origin:center;animation:spin 1s linear infinite"><circle style="opacity: 0.25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" fill="none"/><path style="opacity: 0.75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"/></g></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><circle fill="currentColor" stroke="none" cx="4" cy="12" r="2.5"> <animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.1"></animate></circle><circle fill="currentColor" stroke="none" cx="12" cy="12" r="2.5"><animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.2"></animate></circle><circle fill="currentColor" stroke="none" cx="20" cy="12" r="2.5"><animate attributeName="opacity" dur="1s" values="0;1;0" repeatCount="indefinite" begin="0.3"></animate></circle></svg>
@@ -0,0 +1 @@
1
+ <svg stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><style>.spinner{transform-origin:center; animation:spinner_outside 2s linear infinite}.spinner circle{stroke-linecap:round;animation:spinner_inside 1.5s ease-in-out infinite}@keyframes spinner_outside{100%{transform:rotate(360deg)}}@keyframes spinner_inside{0%{stroke-dasharray:0 150;stroke-dashoffset:0}47.5%{stroke-dasharray:42 150;stroke-dashoffset:-16}95%,100%{stroke-dasharray:42 150;stroke-dashoffset:-59}}</style><g class="spinner"><circle cx="12" cy="12" r="9.5" fill="none" stroke-width="4"></circle></g></svg>
@@ -1,12 +1,99 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsIcons
4
- # Copies the initializer template to your Rails project
5
4
  class InitializerGenerator < Rails::Generators::Base
6
5
  source_root File.expand_path("templates", __dir__)
7
6
 
7
+ desc "Create the Rails Icons initializer."
8
+
9
+ class_option :libraries, type: :array, default: [], desc: "Choose libraries (#{RailsIcons.libraries.keys.join("/")})"
10
+ class_option :destination, type: :string, default: RailsIcons.configuration.destination_path, desc: "Specify destination folder for icons"
11
+ class_option :custom, type: :string, desc: "Name of the custom library"
12
+
8
13
  def copy_initializer
9
- copy_file "initializer.rb", "config/initializers/rails_icons.rb"
14
+ return if File.exist?(INITIALIZER)
15
+
16
+ copy_file "initializer.rb", INITIALIZER
17
+ end
18
+
19
+ def insert_default_configuration
20
+ return unless File.exist?(INITIALIZER)
21
+ return if default_configuration_exists?
22
+
23
+ if options[:libraries].present?
24
+ default_configuration = <<~RB.indent(2)
25
+ config.default_library = "#{options[:libraries].first}"
26
+ # config.default_variant = "" # Set a default variant for all libraries
27
+ RB
28
+
29
+ insert_into_file INITIALIZER, default_configuration, after: "RailsIcons.configure do |config|\n"
30
+ end
31
+ end
32
+
33
+ def insert_custom_destination_path
34
+ return if options[:destination] && options[:destination] == RailsIcons.configuration.destination_path
35
+
36
+ insert_into_file INITIALIZER, <<~RB.indent(2), after: "RailsIcons.configure do |config|\n"
37
+ # Default destination path
38
+ config.destination_path = "#{options[:destination]}"
39
+
40
+ RB
41
+ end
42
+
43
+ def insert_libraries_configuration
44
+ insert_into_file INITIALIZER, "\n#{library_configuration}", before: "end"
45
+ end
46
+
47
+ def setup_custom_configuration
48
+ return "" if options[:custom].blank?
49
+
50
+ insert_custom_configuration
51
+ create_custom_directory
52
+ end
53
+
54
+ private
55
+
56
+ INITIALIZER = "config/initializers/rails_icons.rb"
57
+
58
+ def insert_custom_configuration
59
+ unless File.read(INITIALIZER).include?("config.libraries.merge!")
60
+ custom_default_configuration = <<~RB.indent(2)
61
+ config.libraries.merge!(
62
+
63
+ {
64
+ custom: {
65
+ }
66
+ }
67
+ )
68
+ RB
69
+
70
+ insert_into_file INITIALIZER, custom_default_configuration, before: "end"
71
+ end
72
+
73
+ insert_into_file INITIALIZER, "\n#{custom_configuration}", after: "custom: {"
74
+ end
75
+
76
+ def create_custom_directory = FileUtils.mkdir_p(File.join(options[:destination], options[:custom]))
77
+
78
+ def library_configuration
79
+ options[:libraries].map { RailsIcons.libraries[_1.to_sym].initializer_config }.join("\n")
80
+ end
81
+
82
+ def custom_configuration
83
+ <<~RB.indent(8)
84
+ #{options[:custom]}: {
85
+ # path: "app/assets/svg/icons/#{options[:custom]}/",
86
+ default: {
87
+ css: "size-6"
88
+ }
89
+ }
90
+ RB
91
+ end
92
+
93
+ def default_configuration_exists?
94
+ line = /^\s*config\.default_library\s*=/
95
+
96
+ File.readlines(INITIALIZER).any? { _1.match?(line) }
10
97
  end
11
98
  end
12
99
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsIcons
4
+ class InstallGenerator < Rails::Generators::Base
5
+ source_root File.expand_path("templates", __dir__)
6
+
7
+ desc "Install Rails Icons with the choosen libraries. This creates the configuration initializer and will sync the icons."
8
+
9
+ class_option :libraries, type: :array, default: [], desc: "Choose libraries (#{RailsIcons.libraries.keys.join("/")})"
10
+ class_option :destination, type: :string, default: RailsIcons.configuration.destination_path, desc: "Specify destination folder for icons"
11
+ class_option :skip_sync, type: :boolean, default: false
12
+
13
+ def initializer_generator
14
+ generate("rails_icons:initializer", *attributes)
15
+ end
16
+
17
+ def sync_generator
18
+ return if options[:skip_sync] || options[:libraries].blank?
19
+
20
+ generate("rails_icons:sync", *attributes)
21
+ end
22
+
23
+ private
24
+
25
+ def attributes = ["--libraries=#{options[:libraries].join(" ")}", "--destination=#{options[:destination]}"].join(" ")
26
+ end
27
+ end
@@ -1,52 +1,31 @@
1
- require "fileutils"
1
+ # frozen_string_literal: true
2
+
3
+ require "rails_icons/sync/engine"
2
4
 
3
5
  module RailsIcons
4
6
  class SyncGenerator < Rails::Generators::Base
5
- ICON_VAULT_REPO_URL = "https://github.com/Rails-Designer/rails_icons_vault.git".freeze
6
-
7
- argument :libraries, type: :array, default: [], banner: "heroicons lucide tabler"
8
-
9
- class_option :destination, type: :string, default: nil,
10
- desc: "Custom destination folder for icons (default: `app/assets/svg/icons/`)"
11
-
12
- desc "Sync a specified icon set(s) from the Rails Icons Vault (https://github.com/Rails-Designer/rails_icons_vault)"
13
7
  source_root File.expand_path("templates", __dir__)
14
8
 
15
- def sync_icons
16
- icons_dir = options[:destination] || Rails.root.join("app/assets/svg/icons")
17
- tmp_dir = Rails.root.join("tmp/icons")
18
-
19
- FileUtils.rm_rf(tmp_dir) if Dir.exist?(tmp_dir)
20
- FileUtils.mkdir_p(tmp_dir)
9
+ desc "Sync the choosen icon libraries from their respective git repos."
21
10
 
22
- if system("git clone '#{ICON_VAULT_REPO_URL}' '#{tmp_dir}'")
23
- say "Repository cloned successfully.", :green
24
- else
25
- say "Failed to clone repository.", :red
11
+ class_option :libraries, type: :array, default: [], desc: "Choose libraries (#{RailsIcons.libraries.keys.join("/")})"
26
12
 
27
- exit 1
28
- end
29
-
30
- libraries.each do |set|
31
- set_path = File.join(tmp_dir, "icons", set)
13
+ def sync_icons
14
+ raise "[Rails Icons] Not a valid library" if libraries.empty?
32
15
 
33
- if Dir.exist?(set_path)
34
- destination_path = File.join(icons_dir, set)
16
+ libraries.each { Sync::Engine.new(_1).sync }
17
+ end
35
18
 
36
- FileUtils.mkdir_p(destination_path)
37
- FileUtils.cp_r(Dir.glob("#{set_path}/*"), destination_path)
19
+ private
38
20
 
39
- say "Synced `#{set}` icons for set", :green
40
- else
41
- say "Icon set `#{set}` not found", :red
21
+ def libraries
22
+ options[:libraries].presence || synced_libraries
23
+ end
42
24
 
43
- exit 1
44
- end
25
+ def synced_libraries
26
+ RailsIcons.libraries.keys.map(&:to_s).select do |library|
27
+ Dir.exist?(File.join(RailsIcons.configuration.destination_path, library.to_s))
45
28
  end
46
-
47
- FileUtils.rm_rf(tmp_dir)
48
-
49
- say "Icons synced successfully", :green
50
29
  end
51
30
  end
52
31
  end
@@ -1,18 +1,2 @@
1
1
  RailsIcons.configure do |config|
2
- # Set the default set for the library
3
- config.default_library = "heroicons" # https://heroicons.com/
4
- config.default_set = "outline" # other sets for Heroicons are: solid, mini, micro
5
-
6
- config.libraries.heroicons.solid.default.css = "w-6 h-6"
7
- config.libraries.heroicons.solid.default.data = {}
8
-
9
- config.libraries.heroicons.outline.default.css = "w-6 h-6"
10
- config.libraries.heroicons.outline.default.stroke_width = "1.5"
11
- config.libraries.heroicons.outline.default.data = {}
12
-
13
- config.libraries.heroicons.mini.default.css = "w-5 h-5"
14
- config.libraries.heroicons.mini.default.data = {}
15
-
16
- config.libraries.heroicons.micro.default.css = "w-4 h-4"
17
- config.libraries.heroicons.micro.default.data = {}
18
2
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsIcons
4
+ class Configuration
5
+ module Animated
6
+ extend self
7
+
8
+ def config
9
+ ActiveSupport::OrderedOptions.new.tap do |options|
10
+ options.default = default_options
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def default_options
17
+ ActiveSupport::OrderedOptions.new.tap do |options|
18
+ options.css = "size-6"
19
+ options.data = {}
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,74 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsIcons
4
+ class Configuration
5
+ module Boxicons
6
+ extend self
7
+
8
+ def config
9
+ ActiveSupport::OrderedOptions.new.tap do |options|
10
+ options.default_variant = :regular
11
+
12
+ setup_regular_config(options)
13
+ setup_solid_config(options)
14
+ setup_logos_config(options)
15
+ end
16
+ end
17
+
18
+ def initializer_config
19
+ <<~RB.indent(2)
20
+ # Override Boxicons defaults
21
+ # config.libraries.boxicons.solid.css = "size-6"
22
+ # config.libraries.boxicons.solid.data = {}
23
+
24
+ # config.libraries.boxicons.regular.css = "size-6"
25
+ # config.libraries.boxicons.regular.data = {}
26
+
27
+ # config.libraries.boxicons.logos.css = "size-6"
28
+ # config.libraries.boxicons.logos.data = {}
29
+ RB
30
+ end
31
+
32
+ def source
33
+ {
34
+ url: "https://github.com/atisawd/boxicons.git",
35
+ variants: {
36
+ logos: "svg/logos",
37
+ regular: "svg/regular",
38
+ solid: "svg/solid"
39
+ }
40
+ }
41
+ end
42
+
43
+ def transformations
44
+ {
45
+ filenames: {
46
+ delete_prefix: ["bxl-", "bx-", "bxs-"]
47
+ }
48
+ }
49
+ end
50
+
51
+ def setup_regular_config(options)
52
+ options.regular = ActiveSupport::OrderedOptions.new
53
+ options.regular.default = default_options
54
+ end
55
+
56
+ def setup_solid_config(options)
57
+ options.solid = ActiveSupport::OrderedOptions.new
58
+ options.solid.default = default_options
59
+ end
60
+
61
+ def setup_logos_config(options)
62
+ options.logos = ActiveSupport::OrderedOptions.new
63
+ options.logos.default = default_options
64
+ end
65
+
66
+ def default_options
67
+ ActiveSupport::OrderedOptions.new.tap do |options|
68
+ options.css = "size-6"
69
+ options.data = {}
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsIcons
4
+ class Configuration
5
+ module Feather
6
+ extend self
7
+
8
+ def config
9
+ ActiveSupport::OrderedOptions.new.tap do |options|
10
+ options.default_variant = nil
11
+
12
+ options.default = default_options
13
+ end
14
+ end
15
+
16
+ def initializer_config
17
+ <<~RB.indent(2)
18
+ # Override Feather defaults
19
+ # config.libraries.feather.default.css = "size-6"
20
+ # config.libraries.feather.default.stroke_width = "2"
21
+ # config.libraries.feather.default.data = {}
22
+ RB
23
+ end
24
+
25
+ def source
26
+ {
27
+ url: "https://github.com/feathericons/feather.git",
28
+ variants: {
29
+ ".": "icons" # Feather has no variants, store in the top directory
30
+ }
31
+ }
32
+ end
33
+
34
+ private
35
+
36
+ def default_options
37
+ ActiveSupport::OrderedOptions.new.tap do |options|
38
+ options.stroke_width = "2"
39
+ options.css = "size-6"
40
+ options.data = {}
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end