Skip to content

Commit a058b75

Browse files
authored
Merge pull request #150 from MartinElvar/master
Add support for custom logo
2 parents 84ad795 + 4c5f610 commit a058b75

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,8 @@ Otherwise, if you'd like to explicitly specify your schemas and their admin modu
107107
# config.exs
108108
config :kaffy,
109109
admin_title: "My Awesome App",
110+
admin_logo: "/images/logo.png",
111+
admin_logo_mini: "/images/logo-mini.png",
110112
hide_dashboard: false,
111113
home_page: [kaffy: :dashboard],
112114
ecto_repo: MyApp.Repo,

lib/kaffy/utils.ex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ defmodule Kaffy.Utils do
99
env(:admin_title, "Kaffy")
1010
end
1111

12+
@doc """
13+
Returns the :admin_logo config if present, otherwise returns Kaffy default logo.
14+
"""
15+
@spec logo(Plug.Conn.t()) :: String.t()
16+
def logo(conn) do
17+
router().static_path(conn, env(:admin_logo, "/kaffy/assets/images/logo.png"))
18+
end
19+
20+
@doc """
21+
Returns the :admin_logo_mini config if present, otherwise returns Kaffy default logo.
22+
"""
23+
@spec logo_mini(Plug.Conn.t()) :: String.t()
24+
def logo_mini(conn) do
25+
router().static_path(conn, env(:admin_logo_mini, "/kaffy/assets/images/logo-mini.png"))
26+
end
27+
1228
@doc """
1329
Returns the JSON package used by phoenix configs. If no such config exists, raise an exception.
1430
"""

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
<nav class="navbar default-layout-navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
2121
<div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center">
2222
<%= link to: Kaffy.Utils.router().kaffy_home_path(@conn, :index), class: "navbar-brand brand-logo" do %>
23-
<img src="/kaffy/assets/images/logo.png" alt="logo" />
23+
<img src="<%= Kaffy.Utils.logo(@conn) %>" alt="logo" />
2424
<% end %>
2525
<%= link to: Kaffy.Utils.router().kaffy_home_path(@conn, :index), class: "navbar-brand brand-logo-mini" do %>
26-
<img src="/kaffy/assets/images/logo-mini.png" alt="logo" />
26+
<img src="<%= Kaffy.Utils.logo_mini(@conn) %>" alt="logo" />
2727
<% end %>
2828
</div>
2929
<div class="navbar-menu-wrapper d-flex align-items-stretch">

0 commit comments

Comments
 (0)