From 7283932d85bc19fdcb4be8d6ae12b94ecafc484c Mon Sep 17 00:00:00 2001 From: shibao Date: Sun, 13 Feb 2022 21:28:20 -0500 Subject: [PATCH] use topbar component --- lib/lokal_web/component/topbar.ex | 2 +- lib/lokal_web/templates/layout/app.html.heex | 9 ++-- lib/lokal_web/templates/layout/live.html.heex | 28 +++++++------ .../templates/layout/topbar.html.heex | 41 ------------------- lib/lokal_web/views/layout_view.ex | 2 +- 5 files changed, 24 insertions(+), 58 deletions(-) delete mode 100644 lib/lokal_web/templates/layout/topbar.html.heex diff --git a/lib/lokal_web/component/topbar.ex b/lib/lokal_web/component/topbar.ex index bf10a26..ab00340 100644 --- a/lib/lokal_web/component/topbar.ex +++ b/lib/lokal_web/component/topbar.ex @@ -1,4 +1,4 @@ -defmodule LokalWeb.Component.Topbar do +defmodule LokalWeb.Components.Topbar do @moduledoc """ Phoenix.Component for rendering an interactive topbar Assign diff --git a/lib/lokal_web/templates/layout/app.html.heex b/lib/lokal_web/templates/layout/app.html.heex index 1381559..3c8a34e 100644 --- a/lib/lokal_web/templates/layout/app.html.heex +++ b/lib/lokal_web/templates/layout/app.html.heex @@ -1,16 +1,19 @@ -
-
- <%= render("topbar.html", assigns) %> +
+
+ <.topbar current_user={assigns[:current_user]}> + <%= if get_flash(@conn, :info) do %> <% end %> + <%= if get_flash(@conn, :error) do %> <% end %>
+ <%= @inner_content %>
diff --git a/lib/lokal_web/templates/layout/live.html.heex b/lib/lokal_web/templates/layout/live.html.heex index f011b87..f99debf 100644 --- a/lib/lokal_web/templates/layout/live.html.heex +++ b/lib/lokal_web/templates/layout/live.html.heex @@ -1,15 +1,19 @@
- - - <%= if @flash && @flash |> Map.has_key?(:info) do %> - - <% end %> - <%= if @flash && @flash |> Map.has_key?(:error) do %> - - <% end %> +
+ <.topbar current_user={assigns[:current_user]}> + + <%= if @flash && @flash |> Map.has_key?(:info) do %> + + <% end %> + + <%= if @flash && @flash |> Map.has_key?(:error) do %> + + <% end %> +
+ <%= @inner_content %>
diff --git a/lib/lokal_web/templates/layout/topbar.html.heex b/lib/lokal_web/templates/layout/topbar.html.heex deleted file mode 100644 index f92e4ed..0000000 --- a/lib/lokal_web/templates/layout/topbar.html.heex +++ /dev/null @@ -1,41 +0,0 @@ - diff --git a/lib/lokal_web/views/layout_view.ex b/lib/lokal_web/views/layout_view.ex index ea3ba06..820c730 100644 --- a/lib/lokal_web/views/layout_view.ex +++ b/lib/lokal_web/views/layout_view.ex @@ -1,6 +1,6 @@ defmodule LokalWeb.LayoutView do use LokalWeb, :view - alias LokalWeb.PageLive + import LokalWeb.Components.Topbar # Phoenix LiveDashboard is available only in development by default, # so we instruct Elixir to not warn if the dashboard route is missing.