2023-03-15 01:18:15 +00:00
|
|
|
defmodule ExampleWeb.Layouts do
|
|
|
|
|
use ExampleWeb, :html
|
|
|
|
|
|
|
|
|
|
embed_templates "layouts/*"
|
2026-01-31 22:14:15 +00:00
|
|
|
|
|
|
|
|
# Single source of truth for main nav (sidebar + desktop). Layout has route helpers (~p).
|
|
|
|
|
def nav_groups do
|
|
|
|
|
[
|
|
|
|
|
%{
|
|
|
|
|
label: "Basics",
|
|
|
|
|
links: [
|
|
|
|
|
%{label: "Hello World", to: ~p"/hello-world"},
|
|
|
|
|
%{label: "Lodash", to: ~p"/lodash"},
|
|
|
|
|
%{label: "Struct Props", to: ~p"/live-struct"}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
%{
|
|
|
|
|
label: "Interactive",
|
|
|
|
|
links: [
|
|
|
|
|
%{label: "Counter", to: ~p"/live-simple-counter"},
|
|
|
|
|
%{label: "Lights", to: ~p"/live-lights"},
|
|
|
|
|
%{label: "Sigil", to: ~p"/live-sigil"},
|
|
|
|
|
%{label: "Plus/Minus (Static)", to: ~p"/plus-minus-svelte"},
|
|
|
|
|
%{label: "Plus/Minus (Live)", to: ~p"/live-plus-minus"},
|
2026-02-18 19:30:17 +00:00
|
|
|
%{label: "Hybrid Counter", to: ~p"/live-plus-minus-hybrid"},
|
2026-03-06 08:43:07 +00:00
|
|
|
%{label: "Drag & Drop", to: ~p"/live-drag-drop"},
|
2026-02-18 19:30:17 +00:00
|
|
|
%{label: "Static + List", to: ~p"/live-static-color"}
|
2026-01-31 22:14:15 +00:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
%{
|
|
|
|
|
label: "Data",
|
|
|
|
|
links: [
|
|
|
|
|
%{label: "Log List", to: ~p"/live-log-list"},
|
|
|
|
|
%{label: "Breaking News", to: ~p"/live-breaking-news"},
|
|
|
|
|
%{label: "Chat", to: ~p"/live-chat"},
|
2026-02-24 06:20:50 +00:00
|
|
|
%{label: "Props Diff", to: ~p"/live-props-diff"},
|
|
|
|
|
%{label: "ID List Diff", to: ~p"/live-id-list-diff"}
|
2026-01-31 22:14:15 +00:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
%{
|
|
|
|
|
label: "Slots",
|
|
|
|
|
links: [
|
|
|
|
|
%{label: "Simple Slots", to: ~p"/live-slots-simple"},
|
|
|
|
|
%{label: "Dynamic Slots", to: ~p"/live-slots-dynamic"}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
%{
|
|
|
|
|
label: "Advanced",
|
|
|
|
|
links: [
|
2026-03-05 21:00:30 +00:00
|
|
|
%{label: "Client Loading", to: ~p"/live-client-side-loading"},
|
2026-03-06 09:26:59 +00:00
|
|
|
%{label: "Rich Editor (@attach)", to: ~p"/live-editor"},
|
2026-03-06 10:00:29 +00:00
|
|
|
%{label: "Runed Utilities", to: ~p"/live-runed"},
|
2026-03-06 10:20:42 +00:00
|
|
|
%{label: "Svelte Stores", to: ~p"/live-stores"},
|
2026-03-05 21:00:30 +00:00
|
|
|
%{label: "SSR Demo", to: ~p"/live-ssr"}
|
2026-01-31 22:14:15 +00:00
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
%{
|
|
|
|
|
label: "Ecto",
|
|
|
|
|
links: [
|
|
|
|
|
%{label: "Notes (OTP)", to: ~p"/live-notes-otp"}
|
|
|
|
|
]
|
2026-02-25 00:14:26 +00:00
|
|
|
},
|
|
|
|
|
%{
|
|
|
|
|
label: "Composables",
|
|
|
|
|
links: [
|
2026-02-25 00:57:47 +00:00
|
|
|
%{label: "Form (useLiveForm)", to: ~p"/live-form"},
|
|
|
|
|
%{label: "Navigation (useLiveNavigation)", to: ~p"/live-navigation"},
|
2026-02-25 07:16:04 +00:00
|
|
|
%{label: "Composition (useLiveSvelte)", to: ~p"/live-composition"},
|
2026-02-25 08:13:17 +00:00
|
|
|
%{label: "File Upload (useLiveUpload)", to: ~p"/live-upload"},
|
|
|
|
|
%{label: "Event Reply (useEventReply)", to: ~p"/live-event-reply"}
|
2026-02-25 00:14:26 +00:00
|
|
|
]
|
2026-01-31 22:14:15 +00:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def nav_sidebar_items(assigns) do
|
|
|
|
|
assigns = assign(assigns, :nav_groups, nav_groups())
|
|
|
|
|
|
|
|
|
|
~H"""
|
|
|
|
|
<nav class="flex flex-1 flex-col">
|
|
|
|
|
<ul role="list" class="flex flex-1 flex-col gap-y-7">
|
|
|
|
|
<li :for={group <- @nav_groups}>
|
2026-02-08 11:47:39 +00:00
|
|
|
<div class="text-xs font-semibold leading-6 text-base-content/40 uppercase tracking-wider">
|
2026-02-25 21:51:22 +00:00
|
|
|
{group.label}
|
2026-01-31 22:14:15 +00:00
|
|
|
</div>
|
|
|
|
|
<ul role="list" class="-mx-2 mt-2 space-y-1">
|
|
|
|
|
<li :for={link <- group.links}>
|
2026-02-25 21:51:22 +00:00
|
|
|
<a
|
|
|
|
|
href={link.to}
|
|
|
|
|
class="block px-3 py-2 rounded-md text-sm font-medium text-base-content hover:bg-base-200"
|
|
|
|
|
>
|
|
|
|
|
{link.label}
|
2026-01-31 22:14:15 +00:00
|
|
|
</a>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</nav>
|
|
|
|
|
"""
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def nav_desktop_dropdowns(assigns) do
|
|
|
|
|
assigns = assign(assigns, :nav_groups, nav_groups())
|
|
|
|
|
|
|
|
|
|
~H"""
|
|
|
|
|
<nav class="hidden lg:flex lg:items-center lg:gap-1">
|
|
|
|
|
<div :for={group <- @nav_groups} class="relative group">
|
2026-02-25 21:51:22 +00:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
class="px-3 py-2 text-sm font-medium text-base-content rounded-md hover:bg-base-200"
|
|
|
|
|
>
|
|
|
|
|
{group.label}
|
2026-01-31 22:14:15 +00:00
|
|
|
</button>
|
2026-02-08 11:47:39 +00:00
|
|
|
<div class="absolute left-0 mt-1 w-48 bg-base-100 rounded-box shadow-lg border border-base-300 opacity-0 invisible group-hover:opacity-100 group-hover:visible transition-all duration-150 z-50">
|
2026-01-31 22:14:15 +00:00
|
|
|
<div class="py-1">
|
2026-02-25 21:51:22 +00:00
|
|
|
<a
|
|
|
|
|
:for={link <- group.links}
|
|
|
|
|
href={link.to}
|
|
|
|
|
class="block px-4 py-2 text-sm text-base-content hover:bg-base-200"
|
|
|
|
|
>
|
|
|
|
|
{link.label}
|
2026-01-31 22:14:15 +00:00
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</nav>
|
|
|
|
|
"""
|
|
|
|
|
end
|
2023-03-15 01:18:15 +00:00
|
|
|
end
|