From 1a3b30e2516e5758abd311a32395ada599c3741b Mon Sep 17 00:00:00 2001 From: KKlochko Date: Wed, 26 Mar 2025 15:28:35 +0200 Subject: [PATCH] Add the styled buttons for the forms. --- .../components/my_components.ex | 4 ++ .../components/my_components/buttons.ex | 65 +++++++++++++++++++ .../live/author_live/form_component.ex | 8 ++- 3 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 lib/decentralised_book_index_web/components/my_components/buttons.ex diff --git a/lib/decentralised_book_index_web/components/my_components.ex b/lib/decentralised_book_index_web/components/my_components.ex index b1cb0ae..8fc17d5 100644 --- a/lib/decentralised_book_index_web/components/my_components.ex +++ b/lib/decentralised_book_index_web/components/my_components.ex @@ -7,6 +7,10 @@ defmodule DecentralisedBookIndexWeb.Components.MyComponents do import MyComponents.AuthorSearch, only: [author_search: 1] import MyComponents.Pagination, only: [pagination: 1] + import MyComponents.Buttons, only: [ + success_button: 1, + primary_button: 1, + ] end end end diff --git a/lib/decentralised_book_index_web/components/my_components/buttons.ex b/lib/decentralised_book_index_web/components/my_components/buttons.ex new file mode 100644 index 0000000..52eb900 --- /dev/null +++ b/lib/decentralised_book_index_web/components/my_components/buttons.ex @@ -0,0 +1,65 @@ +defmodule DecentralisedBookIndexWeb.Components.MyComponents.Buttons do + use Phoenix.Component + + import DecentralisedBookIndexWeb.CoreComponents + + @doc """ + Renders a success button. + + ## Examples + + <.success_button>Send! + <.success_button phx-click="go" class="ml-2">Send! + """ + attr :type, :string, default: nil + attr :class, :string, default: nil + attr :rest, :global, include: ~w(disabled form name value) + + slot :inner_block, required: true + + def success_button(assigns) do + ~H""" + + """ + end + + @doc """ + Renders a primary button. + + ## Examples + + <.primary_button>Send! + <.primary_button phx-click="go" class="ml-2">Send! + """ + attr :type, :string, default: nil + attr :class, :string, default: nil + attr :rest, :global, include: ~w(disabled form name value) + + slot :inner_block, required: true + + def primary_button(assigns) do + ~H""" + + """ + end +end diff --git a/lib/decentralised_book_index_web/live/author_live/form_component.ex b/lib/decentralised_book_index_web/live/author_live/form_component.ex index 35e540e..d3500db 100644 --- a/lib/decentralised_book_index_web/live/author_live/form_component.ex +++ b/lib/decentralised_book_index_web/live/author_live/form_component.ex @@ -47,8 +47,12 @@ defmodule DecentralisedBookIndexWeb.AuthorLive.FormComponent do <% end %> <:actions> - <.button phx-disable-with="Saving...">Save Author - <.button phx-click="cancel" phx-target={@myself} class="me-auto">Cancel + <.success_button phx-disable-with="Saving..."> + Save Author + + <.primary_button phx-click="cancel" phx-target={@myself}> + Cancel +