Update the Book form and core components for the bids' nested form.

This commit is contained in:
2025-03-20 17:12:57 +02:00
parent 709905a8e1
commit 05365ee210
2 changed files with 138 additions and 13 deletions
@@ -176,6 +176,69 @@ defmodule DecentralisedBookIndexWeb.CoreComponents do
"""
end
attr :kind, :string,
values: ~w(base primary error),
default: "base"
attr :inverse, :boolean, default: false
attr :size, :string, values: ~w(sm xs md), default: "md"
attr :class, :string, default: ""
attr :rest, :global, include: ~w(navigate disabled patch)
slot :inner_block
def button_link(assigns) do
assigns =
assign(assigns, :theme, button_styles(assigns.kind, assigns.inverse, assigns.size))
~H"""
<.link
class={[
@theme,
@rest[:disabled] && "opacity-60 grayscale pointer-events-none",
@class
]}
{@rest}
>
{render_slot(@inner_block)}
</.link>
"""
end
def button_styles(kind, inverse, size) do
theme =
case {kind, inverse} do
{"base", false} ->
"bg-gray-100"
{"base", true} ->
"border border-gray-500 text-gray-600"
{"primary", false} ->
"bg-primary-600 hover:bg-primary-700 text-white"
{"primary", true} ->
"border border-primary-700 text-primary-700 hover:bg-primary-50 font-semibold"
{"error", false} ->
"bg-error-700 hover:bg-error-800 text-white"
{"error", true} ->
"text-error-600 underline"
_ ->
""
end
[
"phx-submit-loading:opacity-75 rounded-lg font-medium leading-none inline-block",
size == "md" && "py-3 px-5 text-sm",
size == "sm" && "py-2 px-3 text-sm",
size == "xs" && "py-2 px-2 text-xs",
theme
]
end
@doc """
Renders a simple form.