initial bootstrap/navbar setup akin to bones73k implementation
This commit is contained in:
parent
dfe805b811
commit
0a83f8f317
32 changed files with 6856 additions and 7865 deletions
lib
|
@ -6,4 +6,9 @@ defmodule Home73k do
|
|||
Contexts are also responsible for managing your data, regardless
|
||||
if it comes from the database, an external API or others.
|
||||
"""
|
||||
|
||||
@app_vars Application.get_env(:bones73k, :app_global_vars, time_zone: "America/New_York")
|
||||
@app_time_zone @app_vars[:time_zone]
|
||||
|
||||
def app_time_zone, do: @app_time_zone
|
||||
end
|
||||
|
|
|
@ -31,7 +31,8 @@ defmodule Home73kWeb do
|
|||
quote do
|
||||
use Phoenix.View,
|
||||
root: "lib/home73k_web/templates",
|
||||
namespace: Home73kWeb
|
||||
namespace: Home73kWeb,
|
||||
pattern: "**/*"
|
||||
|
||||
# Import convenience functions from controllers
|
||||
import Phoenix.Controller,
|
||||
|
@ -48,6 +49,7 @@ defmodule Home73kWeb do
|
|||
layout: {Home73kWeb.LayoutView, "live.html"}
|
||||
|
||||
unquote(view_helpers())
|
||||
import Home73kWeb.LiveHelpers
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -56,6 +58,7 @@ defmodule Home73kWeb do
|
|||
use Phoenix.LiveComponent
|
||||
|
||||
unquote(view_helpers())
|
||||
import Home73kWeb.LiveHelpers
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -87,6 +90,9 @@ defmodule Home73kWeb do
|
|||
# Import basic rendering functionality (render, render_layout, etc)
|
||||
import Phoenix.View
|
||||
|
||||
# Import SVG Icon helper
|
||||
import Home73kWeb.IconHelpers
|
||||
|
||||
import Home73kWeb.ErrorHelpers
|
||||
import Home73kWeb.Gettext
|
||||
alias Home73kWeb.Router.Helpers, as: Routes
|
||||
|
|
|
@ -23,7 +23,7 @@ defmodule Home73kWeb.Endpoint do
|
|||
plug Plug.Static,
|
||||
at: "/",
|
||||
from: :home73k,
|
||||
gzip: false,
|
||||
gzip: true,
|
||||
only: ~w(css fonts images js favicon.ico robots.txt)
|
||||
|
||||
# Code reloading can be explicitly enabled under the
|
||||
|
|
13
lib/home73k_web/live/live_helpers.ex
Normal file
13
lib/home73k_web/live/live_helpers.ex
Normal file
|
@ -0,0 +1,13 @@
|
|||
defmodule Home73kWeb.LiveHelpers do
|
||||
@doc """
|
||||
Performs the {:noreply, socket} for a given socket.
|
||||
This helps make the noreply pipeable
|
||||
"""
|
||||
def live_noreply(socket), do: {:noreply, socket}
|
||||
|
||||
@doc """
|
||||
Performs the {:ok, socket} for a given socket.
|
||||
This helps make the ok reply pipeable
|
||||
"""
|
||||
def live_okreply(socket), do: {:ok, socket}
|
||||
end
|
|
@ -3,7 +3,7 @@ defmodule Home73kWeb.PageLive do
|
|||
|
||||
@impl true
|
||||
def mount(_params, _session, socket) do
|
||||
{:ok, assign(socket, query: "", results: %{})}
|
||||
{:ok, assign(socket, query: "", results: %{}, page_title: "~")}
|
||||
end
|
||||
|
||||
@impl true
|
||||
|
|
61
lib/home73k_web/templates/layout/_navbar.html.eex
Normal file
61
lib/home73k_web/templates/layout/_navbar.html.eex
Normal file
|
@ -0,0 +1,61 @@
|
|||
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-4">
|
||||
<div class="container">
|
||||
|
||||
<h1 class="fs-4 my-0 py-0 lh-base">
|
||||
<%= link to: Routes.page_path(@conn, :index), class: "navbar-brand fs-4" do %>
|
||||
<%= icon_div @conn, "mdi-desktop-classic", [class: "icon baseline me-1 fs-3"] %>
|
||||
<span class="fw-light" style="font-family: Righteous;">\\AdamPion73k</span>
|
||||
<% end %>
|
||||
</h1>
|
||||
|
||||
<button class="hamburger hamburger--squeeze collapsed navbar-toggler" id="navbarSupportedContentToggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="hamburger-box d-flex">
|
||||
<span class="hamburger-inner"></span>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
|
||||
<%# nav LEFT items %>
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
|
||||
<%# ACTIVE page link example %>
|
||||
<%# <li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Home</a>
|
||||
</li> %>
|
||||
|
||||
<%# DISABLED page link example %>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
|
||||
</li>
|
||||
|
||||
<%# <li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdownExample" data-bs-toggle="dropdown" aria-expanded="false">Dropdown</a>
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdownExample">
|
||||
<li><a class="dropdown-item" href="#">Action</a></li>
|
||||
<li><a class="dropdown-item" href="#">Another action</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="#">Something else here</a></li>
|
||||
</ul>
|
||||
</li> %>
|
||||
|
||||
</ul>
|
||||
|
||||
<%# nav RIGHT items %>
|
||||
<ul class="navbar-nav">
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="#">Resume</a>
|
||||
</li>
|
||||
|
||||
<%= link nav_link_opts(@conn, to: Routes.page_path(@conn, :index), class: "btn btn-outline-dark d-none d-lg-block") do %>
|
||||
<%#= icon_div @conn, "bi-door-open", [class: "icon baseline"] %>
|
||||
Log in
|
||||
<% end %>
|
||||
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
|
@ -1,5 +1,19 @@
|
|||
<main role="main" class="container">
|
||||
<p class="alert alert-info" role="alert"><%= get_flash(@conn, :info) %></p>
|
||||
<p class="alert alert-danger" role="alert"><%= get_flash(@conn, :error) %></p>
|
||||
|
||||
<%# phoenix flash alerts: %>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12 col-lg-10 col-xxl-8 ">
|
||||
<%= for {kind, class} <- alert_kinds() do %>
|
||||
<%= if flash_content = get_flash(@conn, kind) do %>
|
||||
<div class="alert <%= class %> alert-dismissible fade show" role="alert">
|
||||
<%= flash_content %>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= @inner_content %>
|
||||
|
||||
</main>
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
<main role="main" class="container">
|
||||
<p class="alert alert-info" role="alert"
|
||||
phx-click="lv:clear-flash"
|
||||
phx-value-key="info"><%= live_flash(@flash, :info) %></p>
|
||||
|
||||
<p class="alert alert-danger" role="alert"
|
||||
phx-click="lv:clear-flash"
|
||||
phx-value-key="error"><%= live_flash(@flash, :error) %></p>
|
||||
<%# liveview flash alerts: %>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-12 col-lg-10 col-xxl-8 ">
|
||||
<%= for {kind, class} <- alert_kinds() do %>
|
||||
<%= if flash_content = live_flash(@flash, kind) do %>
|
||||
<div class="alert <%= class %> alert-dismissible fade show" role="alert" id="lv-alert-<%= kind %>" phx-hook="AlertRemover" data-key="<%= kind %>">
|
||||
<%= flash_content %>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= @inner_content %>
|
||||
|
||||
</main>
|
||||
|
|
29
lib/home73k_web/templates/layout/navbar/_user_menu.html.eex
Normal file
29
lib/home73k_web/templates/layout/navbar/_user_menu.html.eex
Normal file
|
@ -0,0 +1,29 @@
|
|||
<li class="nav-item dropdown">
|
||||
|
||||
<a href="#" class="nav-link dropdown-toggle" id="navbarDropdownUserMenu" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<%= icon_div @conn, "bi-person-circle", [class: "icon baseline me-1"] %>
|
||||
Hello
|
||||
</a>
|
||||
|
||||
<ul class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdownUserMenu">
|
||||
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
|
||||
<li>
|
||||
<%= link nav_link_opts(@conn, to: Routes.page_path(@conn, :index), class: "dropdown-item") do %>
|
||||
<%= icon_div @conn, "bi-people", [class: "icon baseline me-1"] %>
|
||||
Users
|
||||
<% end %>
|
||||
</li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
|
||||
<li>
|
||||
<%= link nav_link_opts(@conn, to: Routes.page_path(@conn, :index), class: "dropdown-item") do %>
|
||||
<%= icon_div @conn, "bi-sliders", [class: "icon baseline me-1"] %>
|
||||
Settings
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</li>
|
|
@ -5,26 +5,19 @@
|
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<%= csrf_meta_tag() %>
|
||||
<%= live_title_tag assigns[:page_title] || "Home73k", suffix: " · Phoenix Framework" %>
|
||||
<%= live_title_tag assigns[:page_title] || "", prefix: assigns[:page_title] && "73k.us \\ " || "73k.us" %>
|
||||
<meta name="author" content="Adam Piontek"/>
|
||||
<link rel="me" href="mailto:adam@73k.us"/>
|
||||
<link rel="me" href="sms:+16462341697"/>
|
||||
<link rel="authorization_endpoint" href="https://indieauth.com/auth"/>
|
||||
<link phx-track-static rel="stylesheet" href="<%= Routes.static_path(@conn, "/css/app.css") %>"/>
|
||||
<script defer phx-track-static type="text/javascript" src="<%= Routes.static_path(@conn, "/js/app.js") %>"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<section class="container">
|
||||
<nav role="navigation">
|
||||
<ul>
|
||||
<li><a href="https://hexdocs.pm/phoenix/overview.html">Get Started</a></li>
|
||||
<%= if function_exported?(Routes, :live_dashboard_path, 2) do %>
|
||||
<li><%= link "LiveDashboard", to: Routes.live_dashboard_path(@conn, :home) %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</nav>
|
||||
<a href="https://phoenixframework.org/" class="phx-logo">
|
||||
<img src="<%= Routes.static_path(@conn, "/images/phoenix.png") %>" alt="Phoenix Framework Logo"/>
|
||||
</a>
|
||||
</section>
|
||||
</header>
|
||||
|
||||
<%= render "_navbar.html", assigns %>
|
||||
|
||||
<%= @inner_content %>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
38
lib/home73k_web/views/icon_helpers.ex
Normal file
38
lib/home73k_web/views/icon_helpers.ex
Normal file
|
@ -0,0 +1,38 @@
|
|||
defmodule Home73kWeb.IconHelpers do
|
||||
@moduledoc """
|
||||
Generate SVG sprite use tags for SVG icons
|
||||
"""
|
||||
|
||||
use Phoenix.HTML
|
||||
alias Home73kWeb.Router.Helpers, as: Routes
|
||||
|
||||
def icon_div(conn, name, div_opts \\ [], svg_opts \\ []) do
|
||||
content_tag(:div, tag_opts(name, div_opts)) do
|
||||
icon_svg(conn, name, svg_opts)
|
||||
end
|
||||
end
|
||||
|
||||
def icon_svg(conn, name, opts \\ []) do
|
||||
opts = aria_hidden?(opts)
|
||||
|
||||
content_tag(:svg, tag_opts(name, opts)) do
|
||||
~E"""
|
||||
<%= if title = Keyword.get(opts, :aria_label), do: content_tag(:title, title) %>
|
||||
<%= tag(:use, "xlink:href": Routes.static_path(conn, "/images/icons.svg##{name}")) %>
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
||||
defp tag_opts(name, opts) do
|
||||
Keyword.update(opts, :class, name, fn c -> "#{c} #{name}" end)
|
||||
end
|
||||
|
||||
defp aria_hidden?(opts) do
|
||||
case Keyword.get(opts, :aria_hidden) do
|
||||
"false" -> Keyword.drop(opts, [:aria_hidden])
|
||||
false -> Keyword.drop(opts, [:aria_hidden])
|
||||
"true" -> opts
|
||||
_ -> Keyword.put(opts, :aria_hidden, "true")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,3 +1,21 @@
|
|||
defmodule Home73kWeb.LayoutView do
|
||||
use Home73kWeb, :view
|
||||
|
||||
def nav_link_opts(conn, opts) do
|
||||
case Keyword.get(opts, :to) == Phoenix.Controller.current_path(conn) do
|
||||
false -> opts
|
||||
true -> Keyword.update(opts, :class, "active", fn c -> "#{c} active" end)
|
||||
end
|
||||
end
|
||||
|
||||
def alert_kinds do
|
||||
[
|
||||
success: "alert-success",
|
||||
info: "alert-info",
|
||||
error: "alert-danger",
|
||||
warning: "alert-warning",
|
||||
primary: "alert-primary",
|
||||
secondary: "alert-secondary"
|
||||
]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue