Skip to content

Commit 404751b

Browse files
authored
Merge pull request #186 from manuel-rubio/master
let specify the full 'path' for FontAwesome fonts
2 parents bfb7a28 + 968ce96 commit 404751b

File tree

11 files changed

+30
-36
lines changed

11 files changed

+30
-36
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,8 @@ Widgets have shared options:
247247
- `:order` (optional) is the displaying order of the widget. Widgets are display in order based on this value. The default value is 999.
248248
- `:width` (optional) is the width the widget should occupy on the page. Valid values are 1 to 12. The default for tidbits is 3 and the others 6.
249249
- `:percentage` (required for progress widgets) is the percentage value for the progress. This must be an integer.
250-
- `:icon` (optional for tidbit widgets) is the icon displayed next to the tidbit's `content`. Any FontAwesome-valid icon is valid here. For example: `thumbs-up`.
250+
- `:full_icon` (optional for tidbit widgets) is the icon displayed next to the tidbit's `content`. You have to specify the full name given by FontAwesome like `fas fa-thumbs-up`.
251+
- `:icon` (optional for tidbit widgets) is the icon displayed next to the tidbit's `content`. Any FontAwesome-valid icon is valid here. For example: `thumbs-up`. But it's limited to the `fas` group. For full defintion see `:full_icon`.
251252

252253
When defining a chart widget, the content must be a map with the following required keys:
253254

config/config.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use Mix.Config
1+
import Config
22

33
# Use Jason for JSON parsing in Phoenix
44
# config :phoenix, :json_library, Jason

lib/kaffy.ex

Lines changed: 0 additions & 7 deletions
This file was deleted.

lib/kaffy/routes.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ defmodule Kaffy.Routes do
2525
plug(:fetch_flash)
2626
plug(:protect_from_forgery)
2727
plug(:put_secure_browser_headers)
28+
plug(:put_root_layout, {KaffyWeb.LayoutView, :root})
2829
end
2930

3031
scope unquote(scoped), KaffyWeb do

lib/kaffy/utils.ex

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -332,27 +332,30 @@ defmodule Kaffy.Utils do
332332
end
333333

334334
def extensions(conn) do
335-
exts = env(:extensions, [])
336-
337-
stylesheets =
338-
Enum.map(exts, fn ext ->
335+
env(:extensions, [])
336+
|> Enum.reduce(
337+
%{stylesheets: [], javascripts: []},
338+
fn ext, acc ->
339339
Code.ensure_loaded(ext)
340-
case function_exported?(ext, :stylesheets, 1) do
341-
true -> ext.stylesheets(conn)
342-
false -> []
343-
end
340+
stylesheets =
341+
if function_exported?(ext, :stylesheets, 1) do
342+
ext.stylesheets(conn)
343+
else
344+
[]
345+
end
346+
347+
javascripts =
348+
if function_exported?(ext, :javascripts, 1) do
349+
ext.javascripts(conn)
350+
else
351+
[]
352+
end
353+
354+
%{
355+
stylesheets: stylesheets ++ acc.stylesheets,
356+
javascripts: javascripts ++ acc.javascripts
357+
}
344358
end)
345-
346-
javascripts =
347-
Enum.map(exts, fn ext ->
348-
Code.ensure_loaded(ext)
349-
case function_exported?(ext, :javascripts, 1) do
350-
true -> ext.javascripts(conn)
351-
false -> []
352-
end
353-
end)
354-
355-
%{stylesheets: stylesheets, javascripts: javascripts}
356359
end
357360

358361
defp env(key, default \\ nil) do

lib/kaffy_web/templates/home/_card.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<div class="card bg-<%= @widget.type %> card-img-holder text-white">
33
<div class="card-body">
44
<img src="<%= Kaffy.Utils.static_asset_path(@conn, "/kaffy/assets/images/dashboard/circle.svg") %>" class="card-img-absolute" alt="circle-image" />
5-
<h4 class="font-weight-normal mb-3"><%= @widget.title %> <i class="fas fa-<%= @widget.icon %> float-right"></i></h4>
5+
<h4 class="font-weight-normal mb-3"><%= @widget.title %> <i class="<%= if @widget[:full_icon] do %><%= @widget.full_icon %><% else %>fas fa-<%= @widget.icon %><% end %> float-right"></i></h4>
66
<h2 class="mb-5"><%= @widget.content %></h2>
77
<h6 class="card-text"><%= @widget.subcontent %></h6>
88
</div>

lib/kaffy_web/templates/home/_tidbit.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div class="col-md-<%= @widget.width %> grid-margin stretch-card">
22
<div class="card shadow border-left-success">
33
<div class="card-body">
4-
<p class="font-weight-normal mb-1 text-success"><strong><%= @widget.title %></strong> <i class="fa fa-<%= @widget.icon %> float-right"></i></p>
4+
<p class="font-weight-normal mb-1 text-success"><strong><%= @widget.title %></strong> <i class="<%= if @widget[:full_icon] do %><%= @widget.full_icon %><% else %>fas fa-<%= @widget.icon %><% end %> float-right"></i></p>
55
<h2 class="mt-1"><%= @widget.content %></h2>
66
</div>
77
</div>

lib/kaffy_web/templates/layout/app.html.eex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
<li class="nav-item">
6666
<%= link to: custom_link.url, method: custom_link.method, class: "nav-link", target: custom_link.target do %>
6767
<span class="menu-title"><%= custom_link.name %></span>
68-
<i class="fas fa-<%= custom_link.icon %> menu-icon"></i>
68+
<i class="<%= if custom_link.full_icon do %><%= custom_link.full_icon %><% else %>fas fa-<%= custom_link.icon %><% end %> menu-icon"></i>
6969
<% end %>
7070
</li>
7171
<% end %>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<%= @inner_content %>

lib/kaffy_web/templates/page

Whitespace-only changes.

test/kaffy_test.exs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
defmodule KaffyTest do
22
use ExUnit.Case
3-
doctest Kaffy
43
alias KaffyTest.Schemas.{Company, Person, Pet}
54
# alias KaffyTest.Admin.PersonAdmin
65

7-
test "greets the world" do
8-
assert Kaffy.hello() == :world
9-
end
10-
116
test "creating a person" do
127
person = %Person{}
138
assert is_nil(person.name)

0 commit comments

Comments
 (0)