-
-
Notifications
You must be signed in to change notification settings - Fork 13
Description
Is there a reason that "custom" libraries need to be under the "custom" library key?
They don't appear to work the same as the preconfigured libraries. For example, I created a custom library with the generator:
# config/initializers/rails_icons.rb
RailsIcons.configure do |config|
config.libraries.merge!(
{
custom: {
coolicons: {
# path: "app/assets/svg/icons/coolicons/",
default: {
css: "size-6"
}
}
}
}
)
end
Files added to app/assets/svg/icons/coolicons/classic/
I can then use the helper like so:
icon(:envelope, library: :coolicons, variant: :classic)
Great, now I want to modify to have a default variant and this is where things start to not work the same. When I change the initializer to:
# config/initializers/rails_icons.rb
RailsIcons.configure do |config|
config.libraries.merge!(
{
custom: {
coolicons: {
# path: "app/assets/svg/icons/coolicons/",
default: {
css: "size-6"
},
default_variant: "classic"
}
}
}
)
end
I am unable to find the correct default variant attribute because of the way the custom libraries are looked up. The library itself is found fine with the custom_library
method but that is not used when setting the default variant. So then the variant is not found.
After looking through the source I didn't really see a reason to mark custom libraries and 'custom' other than the possibility that there could be a naming collision with a pre-defined library.
So I tried just changing the config and this worked out really well with no changes to the codebase.
# config/initializers/rails_icons.rb
RailsIcons.configure do |config|
config.libraries.merge!(
{
coolicons: {
# path: "app/assets/svg/icons/coolicons/",
default: {
css: "size-6"
},
default_variant: "classic"
}
}
)
end
Configuring this way makes the "custom" library work exactly as every other library as far as I can tell and now I can utilize the defaults
icon(:envelope, library: :coolicons)
If this makes sense to you, I propose a documentation change and then possibly the removal of the custom_library
& custom_library?
methods.