Skip to content

Commit

Permalink
Merge branch 'release/0.2.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo0807 committed Nov 24, 2022
2 parents a4b3f34 + cbad096 commit 0488c08
Show file tree
Hide file tree
Showing 7 changed files with 3,073 additions and 36,015 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: erlef/setup-beam@v1
with:
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Tabler Icons

[![CI](https://github.com/sourceboat/ex_tabler_icons/actions/workflows/ci.yml/badge.svg)](https://github.com/sourceboat/ex_tabler_icons/actions/workflows/ci.yml)
[![Hex.pm](https://img.shields.io/hexpm/v/tabler_icons.svg)](https://hex.pm/packages/tabler_icons)
[![Hex](https://img.shields.io/hexpm/v/tabler_icons.svg)](https://hex.pm/packages/tabler_icons)
[![Hex Docs](https://img.shields.io/badge/hex-docs-green)](https://hexdocs.pm/tabler_icons/TablerIcons.html)

[Tabler Icons](https://tabler-icons.io/) are free and open source icons. This package provides Elixir functions in order to use [Tabler Icons](https://tabler-icons.io/) in your HTML, styled with arbitrary classes.

This package is strongly inspired by [heroicons_elixir](https://github.com/mveytsman/heroicons_elixir).

> Note: As we are dealing with over 3.000 icons and an output file with more than 100.000 lines of code, the compile time may be longer than usual.
> Note: As we are dealing with over 3.000 icons and an output file with more than 70.000 lines of code, the compile time may be longer than usual.
## Installation

Expand All @@ -25,12 +26,14 @@ end

```eex
<TablerIcons.user />
<TablerIcons.icon name={:user} />
```

You may pass arbitrary HTML attributes to the components:

```eex
<TablerIcons.user class="w-2 h-2" />
<TablerIcons.icon name={:user} class="w-2 h-2" />
```

For additional information and list of all icons see [the docs](https://hexdocs.pm/tabler_icons/TablerIcons.html).
Expand Down
37 changes: 27 additions & 10 deletions assets/tabler_icons.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@ defmodule TablerIcons do
"""
use Phoenix.Component

@default_html_attrs %{
width: "24",
height: "24",
viewBox: "0 0 24 24",
"stroke-width": "2",
stroke: "currentColor",
fill: "none",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}

@doc """
Renders an icon dynamically.
## Examples
<TablerIcons.icon name={:user} />
<TablerIcons.icon name={:user} class="w-4 h-4" />
"""

attr :rest, :global, doc: "arbitrary HTML attributes for the svg container", default: @default_html_attrs
attr :name, :atom, required: true, doc: "the name of the icon to be rendered"

def icon(assigns) do
apply(TablerIcons, assigns.name, [assigns])
end

<%= for {func, paths} <- @icons do %>
@doc """
Expand All @@ -29,16 +55,7 @@ defmodule TablerIcons do
<TablerIcons.<%= func %> />
<TablerIcons.<%= func %> class="w-4 h-4" />
"""
attr :rest, :global, doc: "arbitrary HTML attributes for the svg container", default: %{
"width": "24",
"height": "24",
"viewBox": "0 0 24 24",
"stroke-width": "2",
"stroke": "currentColor",
"fill": "none",
"stroke-linecap": "round",
"stroke-linejoin": "round"
}
attr :rest, :global, doc: "arbitrary HTML attributes for the svg container", default: @default_html_attrs

def <%= func %>(assigns) do
~H"""
Expand Down
Loading

0 comments on commit 0488c08

Please sign in to comment.