diff --git a/lib/decentralised_book_index_web.ex b/lib/decentralised_book_index_web.ex index 2307bbd..8620eef 100644 --- a/lib/decentralised_book_index_web.ex +++ b/lib/decentralised_book_index_web.ex @@ -89,6 +89,7 @@ defmodule DecentralisedBookIndexWeb do import Phoenix.HTML # Core UI components import DecentralisedBookIndexWeb.CoreComponents + use DecentralisedBookIndexWeb.Components.MyPartials # Shortcut for generating JS commands alias Phoenix.LiveView.JS diff --git a/lib/decentralised_book_index_web/components/my_partials.ex b/lib/decentralised_book_index_web/components/my_partials.ex new file mode 100644 index 0000000..bfc3dc6 --- /dev/null +++ b/lib/decentralised_book_index_web/components/my_partials.ex @@ -0,0 +1,9 @@ +defmodule DecentralisedBookIndexWeb.Components.MyPartials do + alias DecentralisedBookIndexWeb.Components.MyPartials + + defmacro __using__(_) do + quote do + import MyPartials.Navbar, only: [partial_navbar: 1] + end + end +end diff --git a/lib/decentralised_book_index_web/components/my_partials/navbar.ex b/lib/decentralised_book_index_web/components/my_partials/navbar.ex new file mode 100644 index 0000000..7d1a284 --- /dev/null +++ b/lib/decentralised_book_index_web/components/my_partials/navbar.ex @@ -0,0 +1,49 @@ +defmodule DecentralisedBookIndexWeb.Components.MyPartials.Navbar do + use Phoenix.Component + use DecentralisedBookIndexWeb, :verified_routes + alias Phoenix.LiveView.JS + + attr(:page_title, :string, required: true) + + def partial_navbar(assigns) do + ~H""" + + """ + end + + defp selected_navbar_link_css(page_title, active_title) do + if active_title =~ page_title do + "block py-2 pr-4 pl-3 text-black dark:text-white rounded bg-primary-700 lg:bg-transparent lg:text-primary-700 lg:p-0 dark:text-white" + else + "block py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 lg:hover:text-primary-700 lg:p-0 dark:text-gray-400 lg:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent dark:border-gray-700" + end + end +end