Rails-Designer / rails_icons

Add any icon library to a Rails app
https://railsdesigner.com/rails-icons/
MIT License
39 stars 4 forks source link

Custom library icons full sync #25

Open eelcoj opened 2 days ago

eelcoj commented 2 days ago

There is currently the option to render custom icons. In (main) you can run rails generate rails_icons:initializer --library=custom and it will add the following to config/initializer/rails_icons.rb:

  config.libraries.merge!(
          {
            custom: {
              LIBRARY_NAME: {
                solid: {
                  path: "app/assets/svg/icons/LIBRARY_NAME/#{RailsIcons.configuration.default_variant}/",
                  default: {
                    css: "size-6"
                  }
                }
              }
            }
          }
        )

Super useful for for one (or a few) icons you manually download. But would be useful to allow to sync custom libraries too? So non-first-party libraries can be synced too?

API/interface could be the same, eg. rails generate rails_icons:initializer --library=simple_icons. Then in the custom configuration something like this could be added:

  config.libraries.merge!(
          {
            custom: {
              simple_icons: {
                sync: {
                  url: "https://github.com/tailwindlabs/heroicons.git",
                    variants: {
                      icons: "icons",
                   }
                },
                solid: {
                  path: "app/assets/svg/icons/LIBRARY_NAME/#{RailsIcons.configuration.default_variant}/",
                  default: {
                    css: "size-6"
                  }
                }

              }
            }
          }
        )

Not 100% sure if useful. As a PR with the correct config would be pretty simple (thanks to @jordancalhoun!).

jordancalhoun commented 2 days ago

I love the idea of updating this to support syncing any set of icons following the format defined in the 'SET' for the three we currently have defined in there. I think it could be setup with minimal work for more flexibility by the end user without needing to fork/submit a PR. Would allow anyone to keep their icon sets up to date without any manual work.

Is this what you had in mind?

eelcoj commented 1 day ago

That's what I had in mind, indeed.

I like the versatility of it, but unsure how big the upside is (vs the amount of code/added complexity).

I just added the Feather library and this is really all it takes: https://github.com/Rails-Designer/rails_icons/pull/29/files