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

Updated fill and stroke colors to match heroicons.com #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 10 additions & 2 deletions lib/heroicons.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ defmodule Heroicons do
~H"""
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
fill={fill_color(@type)}
viewBox={svg_viewbox(@type)}
stroke-width="1.5"
stroke="currentColor"
stroke={stroke_color(@type)}
aria-hidden="true"
data-slot="icon"
class={@class}
Expand All @@ -167,6 +167,14 @@ defmodule Heroicons do
end
end

defp fill_color("outline"), do: "none"

defp fill_color(_), do: "currentColor"

defp stroke_color("outline"), do: "currentColor"

defp stroke_color(_), do: "none"

for %Icon{name: name, type: type, file: file} <- icons do
defp svg_body(unquote(name), unquote(type)) do
unquote(file)
Expand Down
28 changes: 28 additions & 0 deletions test/heroicons_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,34 @@ defmodule HeroiconsTest do
assert html =~ ~s(aria-hidden="true")
end

test "renders micro icon with fill of currentColor and no stroke" do
assigns = %{}
html = rendered_to_string(~H[<Heroicons.icon name="academic-cap" type="micro" />])
assert html =~ ~s(fill="currentColor")
assert html =~ ~s(stroke="none")
end

test "renders mini icon with fill of currentColor and no stroke" do
assigns = %{}
html = rendered_to_string(~H[<Heroicons.icon name="academic-cap" type="mini" />])
assert html =~ ~s(fill="currentColor")
assert html =~ ~s(stroke="none")
end

test "renders solid icon with fill of currentColor and no stroke" do
assigns = %{}
html = rendered_to_string(~H[<Heroicons.icon name="academic-cap" type="solid" />])
assert html =~ ~s(fill="currentColor")
assert html =~ ~s(stroke="none")
end

test "renders outline icon with no fill and stroke of currentColor" do
assigns = %{}
html = rendered_to_string(~H[<Heroicons.icon name="academic-cap" type="outline" />])
assert html =~ ~s(fill="none")
assert html =~ ~s(stroke="currentColor")
end

test "raises when icon name is not found" do
assigns = %{}

Expand Down