feat: add userdata for profile button #170

This commit is contained in:
Simon 2025-09-29 15:34:00 +02:00
parent 6033e33622
commit e3dd333e89
Signed by: simon
GPG key ID: 40E7A58C4AA1EDB2
15 changed files with 41 additions and 24 deletions

View file

@ -14,7 +14,8 @@ defmodule MvWeb.Layouts do
embed_templates "layouts/*"
@doc """
Renders the app layout
Renders the app layout. Can be used with or without a current_user.
When current_user is present, it will show the navigation bar.
## Examples
@ -22,18 +23,25 @@ defmodule MvWeb.Layouts do
<h1>Content</h1>
</Layout.app>
<Layouts.app flash={@flash} current_user={@current_user}>
<h1>Authenticated Content</h1>
</Layout.app>
"""
attr :flash, :map, required: true, doc: "the map of flash messages"
attr :current_user, :map, default: nil, doc: "the current user, if authenticated"
attr :current_scope, :map,
default: nil,
doc: "the current [scope](https://hexdocs.pm/phoenix/scopes.html)"
default: nil,
doc: "the current [scope](https://hexdocs.pm/phoenix/scopes.html)"
slot :inner_block, required: true
def app(assigns) do
~H"""
<.navbar />
<%= if @current_user do %>
<.navbar current_user={@current_user} />
<% end %>
<main class="px-4 py-20 sm:px-6 lg:px-16">
<div class="mx-auto max-full space-y-4">
{render_slot(@inner_block)}
@ -44,6 +52,7 @@ defmodule MvWeb.Layouts do
"""
end
@doc """
Shows the flash group with standard titles and content.