Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Feather as a first-party library #29

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ icon "check", stroke_width: 2

## First-party libraries

- [Feather](https://github.com/feathericons/feather)
- [Heroicons](https://github.com/tailwindlabs/heroicons)
- [Lucide](https://github.com/lucide-icons/lucide)
- [Tabler](https://github.com/tabler/tabler-icons)
Expand Down
10 changes: 10 additions & 0 deletions lib/generators/rails_icons/initializer_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def insert_configuration

def library_configuration
configs = {
feather: feather_config,
heroicons: heroicons_config,
lucide: lucide_config,
tabler: tabler_config,
Expand All @@ -43,6 +44,15 @@ def library_configuration
libraries.map { configs[_1.to_sym] }.join("\n")
end

def feather_config
<<~RB.indent(2)
# Override Feather defaults
# config.libraries.feather.outline.default.css = "size-6"
# config.libraries.feather.outline.default.stroke_width = "2"
# config.libraries.feather.outline.default.data = {}
RB
end

def heroicons_config
<<~RB.indent(2)
# Override Heroicon defaults
Expand Down
2 changes: 2 additions & 0 deletions lib/rails_icons/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require_relative "configuration/animated"
require_relative "configuration/feather"
require_relative "configuration/heroicons"
require_relative "configuration/lucide"
require_relative "configuration/tabler"
Expand Down Expand Up @@ -37,6 +38,7 @@ def set_libraries_config
@config.libraries = ActiveSupport::OrderedOptions.new

@config.libraries.animated = Configuration::Animated.new.config
@config.libraries.feather = Configuration::Feather.new.config
@config.libraries.heroicons = Configuration::Heroicons.new.config
@config.libraries.lucide = Configuration::Lucide.new.config
@config.libraries.tabler = Configuration::Tabler.new.config
Expand Down
28 changes: 28 additions & 0 deletions lib/rails_icons/configuration/feather.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

module RailsIcons
class Configuration
class Feather
def config
ActiveSupport::OrderedOptions.new.tap do |options|
setup_outline_config(options)
end
end

private

def setup_outline_config(options)
options.outline = ActiveSupport::OrderedOptions.new
options.outline.default = default_outline_options
end

def default_outline_options
ActiveSupport::OrderedOptions.new.tap do |options|
options.stroke_width = "2"
options.css = "size-6"
options.data = {}
end
end
end
end
end
24 changes: 16 additions & 8 deletions lib/rails_icons/libraries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ module Libraries

def all
{
feather: {
name: "feather",
url: "https://github.com/feathericons/feather.git",
variants: {
outline: "icons"
}
},

heroicons: {
name: "heroicons",
url: "https://github.com/tailwindlabs/heroicons.git",
Expand All @@ -15,21 +23,21 @@ def all
}
},

lucide: {
name: "lucide",
url: "https://github.com/lucide-icons/lucide.git",
variants: {
outline: "icons"
}
},

tabler: {
name: "tabler",
url: "https://github.com/tabler/tabler-icons.git",
variants: {
filled: "icons/filled",
outline: "icons/outline"
}
},

lucide: {
name: "lucide",
url: "https://github.com/lucide-icons/lucide.git",
variants: {
outline: "icons"
}
}
}
end
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions test/icon_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ class IconTest < ActiveSupport::TestCase
end
end

test "using feather library, it returns a SVG" do
assert_nothing_raised do
icon("activity", library: "feather")
end
end

test "using lucide library, it returns a SVG" do
assert_nothing_raised do
icon("graduation-cap", library: "lucide")
Expand Down