Skip to content

Commit

Permalink
Avoid specifying sidebar's icon fill color manually
Browse files Browse the repository at this point in the history
With the default value of the icon_tag helper (fill-current)
it's already inheriting from the parent color.
  • Loading branch information
kennyadsl authored and elia committed Aug 2, 2023
1 parent 3966164 commit cca5f65
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def icon
common_classes = "inline-block w-[1.125rem] h-[1.125rem] mr-[0.68rem] body-small"

return tag.span(class: common_classes) unless @item.icon
icon_tag(@item.icon, class: "#{common_classes} align-text-bottom fill-black group-hover:fill-red-500 group-[.active]:fill-red-500")
icon_tag(@item.icon, class: "#{common_classes} align-text-bottom fill-current")
end

def path
Expand Down
1 change: 1 addition & 0 deletions admin/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@

config.include ViewComponent::TestHelpers, type: :component
config.include ViewComponent::SystemTestHelpers, type: :component
config.include SolidusAdmin::ComponentHelpers, type: :component

config.include Rails::Generators::Testing::Behaviour, type: :generator
config.include FileUtils, type: :generator
Expand Down
24 changes: 24 additions & 0 deletions admin/spec/support/solidus_admin/component_helpers.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# frozen_string_literal: true

module SolidusAdmin
module ComponentHelpers
# Mocks a component class with the given definition.
#
# @param definition [Proc] the component definition
# @example
# mock_component do
# def call
# "Rendered"
# end
# end
def mock_component(&definition)
Class.new(SolidusAdmin::BaseComponent) do
# ViewComponent will complain if we don't fake a class name:
# @see https://github.com/ViewComponent/view_component/blob/5decd07842c48cbad82527daefa3fe9c65a4226a/lib/view_component/base.rb#L371
def self.name
"Foo"
end
end.tap { |klass| klass.class_eval(&definition) }
end
end
end

0 comments on commit cca5f65

Please sign in to comment.