From 0a5d70abb67a23100f4cbf77f1f264814bd0ca65 Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Sun, 21 Jul 2024 22:03:50 +0500 Subject: [PATCH] fix: move account-related links to navbar --- assets/css/app.css | 10 +++++ lib/comfycamp_web.ex | 1 + .../components/layouts/app.html.heex | 8 +--- .../components/layouts/root.html.heex | 41 ----------------- lib/comfycamp_web/components/navbar.ex | 44 +++++++++++++++++++ 5 files changed, 56 insertions(+), 48 deletions(-) create mode 100644 lib/comfycamp_web/components/navbar.ex diff --git a/assets/css/app.css b/assets/css/app.css index 1feb872..39db93a 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -69,3 +69,13 @@ footer { align-items: center; gap: 8px; } + +.navbar { + display: flex; + gap: 16px; + padding-top: 16px; +} + +.navbar .space { + flex-grow: 1; +} diff --git a/lib/comfycamp_web.ex b/lib/comfycamp_web.ex index 4cb7922..61f4c25 100644 --- a/lib/comfycamp_web.ex +++ b/lib/comfycamp_web.ex @@ -88,6 +88,7 @@ defmodule ComfycampWeb do import ComfycampWeb.CoreComponents import ComfycampWeb.Flash import ComfycampWeb.Gettext + import ComfycampWeb.NavBar # Shortcut for generating JS commands alias Phoenix.LiveView.JS diff --git a/lib/comfycamp_web/components/layouts/app.html.heex b/lib/comfycamp_web/components/layouts/app.html.heex index b411e73..a7040b8 100644 --- a/lib/comfycamp_web/components/layouts/app.html.heex +++ b/lib/comfycamp_web/components/layouts/app.html.heex @@ -1,10 +1,4 @@ -
- -
+<.navbar current_user={@current_user} /> <.flash_group flash={@flash} /> diff --git a/lib/comfycamp_web/components/layouts/root.html.heex b/lib/comfycamp_web/components/layouts/root.html.heex index 4cb6b94..e0fcc7f 100644 --- a/lib/comfycamp_web/components/layouts/root.html.heex +++ b/lib/comfycamp_web/components/layouts/root.html.heex @@ -31,47 +31,6 @@ - <%= @inner_content %> diff --git a/lib/comfycamp_web/components/navbar.ex b/lib/comfycamp_web/components/navbar.ex new file mode 100644 index 0000000..8fac3cd --- /dev/null +++ b/lib/comfycamp_web/components/navbar.ex @@ -0,0 +1,44 @@ +defmodule ComfycampWeb.NavBar do + use Phoenix.Component + + alias Comfycamp.Accounts.User + + @doc """ + Navigation bar. + + ## Examples + + <.navbar current_user={@current_user} /> + """ + attr :current_user, User, required: false + + def navbar(assigns) do + ~H""" + + """ + end +end