feat: added membersLiveView for testing Primer components
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
carla 2025-05-08 14:24:18 +02:00
parent e0a15b1a57
commit e0f8b69315
5 changed files with 76 additions and 41 deletions

View file

@ -9,6 +9,7 @@ defmodule MvWeb.Layouts do
`use MvWeb, :live_view`. `use MvWeb, :live_view`.
""" """
use MvWeb, :html use MvWeb, :html
alias PrimerLive.Component, as: Primer
embed_templates "layouts/*" embed_templates("layouts/*")
end end

View file

@ -1,29 +1,23 @@
<header class="px-4 sm:px-6 lg:px-8"> <Primer.header>
<div class="flex items-center justify-between border-b border-zinc-100 py-3 text-sm"> <:item>
<div class="flex items-center gap-4"> <Primer.avatar
<a href="/"> width="128"
<img src={~p"/images/logo.svg"} width="36" /> src={~p"/images/local_it.png"}
</a> />
<p class="bg-brand/5 text-brand rounded-full px-2 font-medium leading-6"> </:item>
v{Application.spec(:phoenix, :vsn)} <:item>
</p> <Primer.select_menu>
</div> <:toggle>Menu</:toggle>
<div class="flex items-center gap-4 font-semibold leading-6 text-zinc-900"> <:item navigate="/">
<a href="https://twitter.com/elixirphoenix" class="hover:text-zinc-700"> Phoenix Standard Startseite
@elixirphoenix </:item>
</a> </Primer.select_menu>
<a href="https://github.com/phoenixframework/phoenix" class="hover:text-zinc-700"> </:item>
GitHub <:item is_full_width />
</a> <:item class="mr-0">
<a <Primer.octicon name="person-24" />
href="https://hexdocs.pm/phoenix/overview.html" </:item>
class="rounded-lg bg-zinc-100 px-2 py-1 hover:bg-zinc-200/80" </Primer.header>
>
Get Started <span aria-hidden="true">&rarr;</span>
</a>
</div>
</div>
</header>
<main class="px-4 py-20 sm:px-6 lg:px-8"> <main class="px-4 py-20 sm:px-6 lg:px-8">
<div class="mx-auto max-w-2xl"> <div class="mx-auto max-w-2xl">
<.flash_group flash={@flash} /> <.flash_group flash={@flash} />

View file

@ -0,0 +1,39 @@
defmodule MvWeb.MembersLive do
use MvWeb, :live_view
alias PrimerLive.Component, as: Primer
def mount(_params, _session, socket) do
# Initialize any state you need here
{:ok,
assign(
socket,
:title,
"Willkommen zur test Live View für PrimerLive bis hier members gezeigt werden..."
)}
end
def render(assigns) do
~H"""
<div>
<h1 class="h1"><%= @title %></h1>
<Primer.state_label is_draft>Entwurf</Primer.state_label>
<Primer.subhead>
<span class="h2">Heading</span>
<:actions>
<Primer.button is_primary>Action</Primer.button>
</:actions>
<:description>
Description
</:description>
</Primer.subhead>
<Primer.button is_danger phx-click="click_me">Click Me!</Primer.button>
</div>
"""
end
def handle_event("click_me", _value, socket) do
# Handle the button click event
new_title = "You clicked the button!"
{:noreply, assign(socket, :title, new_title)}
end
end

View file

@ -2,22 +2,23 @@ defmodule MvWeb.Router do
use MvWeb, :router use MvWeb, :router
pipeline :browser do pipeline :browser do
plug :accepts, ["html"] plug(:accepts, ["html"])
plug :fetch_session plug(:fetch_session)
plug :fetch_live_flash plug(:fetch_live_flash)
plug :put_root_layout, html: {MvWeb.Layouts, :root} plug(:put_root_layout, html: {MvWeb.Layouts, :root})
plug :protect_from_forgery plug(:protect_from_forgery)
plug :put_secure_browser_headers plug(:put_secure_browser_headers)
end end
pipeline :api do pipeline :api do
plug :accepts, ["json"] plug(:accepts, ["json"])
end end
scope "/", MvWeb do scope "/", MvWeb do
pipe_through :browser pipe_through(:browser)
get "/", PageController, :home get("/", PageController, :home)
live("/members", MembersLive, :index)
end end
# Other scopes may use custom stacks. # Other scopes may use custom stacks.
@ -35,10 +36,10 @@ defmodule MvWeb.Router do
import Phoenix.LiveDashboard.Router import Phoenix.LiveDashboard.Router
scope "/dev" do scope "/dev" do
pipe_through :browser pipe_through(:browser)
live_dashboard "/dashboard", metrics: MvWeb.Telemetry live_dashboard("/dashboard", metrics: MvWeb.Telemetry)
forward "/mailbox", Plug.Swoosh.MailboxPreview forward("/mailbox", Plug.Swoosh.MailboxPreview)
end end
end end
@ -46,9 +47,9 @@ defmodule MvWeb.Router do
import AshAdmin.Router import AshAdmin.Router
scope "/admin" do scope "/admin" do
pipe_through :browser pipe_through(:browser)
ash_admin "/" ash_admin("/")
end end
end end
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB