diff --git a/installer/templates/phx_web/components/core_components.ex b/installer/templates/phx_web/components/core_components.ex index 8f397b91de..d18398a842 100644 --- a/installer/templates/phx_web/components/core_components.ex +++ b/installer/templates/phx_web/components/core_components.ex @@ -163,53 +163,23 @@ defmodule <%= @web_namespace %>.CoreComponents do def button(assigns) do ~H""" - """ end @doc """ - Renders a link styled as a button. + Returns the default button classes. ## Examples - <.link_button href={~p"/items/new"}> + <.link class={button_classes()} href={~p"/items/new"}> New Item - + """ - attr :class, :string, default: nil - - attr :rest, :global, - include: - ~w(patch navigate href replace method csrf_token download hreflang referrerpolicy rel target type), - doc: """ - Additional HTML attributes added to the `a` tag. - """ - - slot :inner_block, required: true - - def link_button(assigns) do - ~H""" - <.link - class={[ - "inline-block phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3", - "text-sm font-semibold leading-6 text-white active:text-white/80", - @class - ]} - {@rest} - > - {render_slot(@inner_block)} - - """ + def button_classes do + "inline-block phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3 text-sm font-semibold leading-6 text-white active:text-white/80" end @doc """ diff --git a/priv/templates/phx.gen.html/index.html.heex b/priv/templates/phx.gen.html/index.html.heex index d5965228a3..3e70d52aa3 100644 --- a/priv/templates/phx.gen.html/index.html.heex +++ b/priv/templates/phx.gen.html/index.html.heex @@ -1,9 +1,9 @@ <.header> Listing <%= schema.human_plural %> <:actions> - <.link_button href={~p"<%= schema.route_prefix %>/new"}> + <.link class={button_classes()} href={~p"<%= schema.route_prefix %>/new"}> New <%= schema.human_singular %> - + diff --git a/priv/templates/phx.gen.html/show.html.heex b/priv/templates/phx.gen.html/show.html.heex index a0cfe831cb..60c76670ba 100644 --- a/priv/templates/phx.gen.html/show.html.heex +++ b/priv/templates/phx.gen.html/show.html.heex @@ -2,9 +2,12 @@ <%= schema.human_singular %> {@<%= schema.singular %>.id} <:subtitle>This is a <%= schema.singular %> record from your database. <:actions> - <.link_button href={~p"<%= schema.route_prefix %>/#{@<%= schema.singular %>}/edit"}> + <.link + class={button_classes()} + href={~p"<%= schema.route_prefix %>/#{@<%= schema.singular %>}/edit"} + > Edit <%= schema.singular %> - + diff --git a/priv/templates/phx.gen.live/core_components.ex b/priv/templates/phx.gen.live/core_components.ex index 8f397b91de..d18398a842 100644 --- a/priv/templates/phx.gen.live/core_components.ex +++ b/priv/templates/phx.gen.live/core_components.ex @@ -163,53 +163,23 @@ defmodule <%= @web_namespace %>.CoreComponents do def button(assigns) do ~H""" - """ end @doc """ - Renders a link styled as a button. + Returns the default button classes. ## Examples - <.link_button href={~p"/items/new"}> + <.link class={button_classes()} href={~p"/items/new"}> New Item - + """ - attr :class, :string, default: nil - - attr :rest, :global, - include: - ~w(patch navigate href replace method csrf_token download hreflang referrerpolicy rel target type), - doc: """ - Additional HTML attributes added to the `a` tag. - """ - - slot :inner_block, required: true - - def link_button(assigns) do - ~H""" - <.link - class={[ - "inline-block phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3", - "text-sm font-semibold leading-6 text-white active:text-white/80", - @class - ]} - {@rest} - > - {render_slot(@inner_block)} - - """ + def button_classes do + "inline-block phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3 text-sm font-semibold leading-6 text-white active:text-white/80" end @doc """ diff --git a/priv/templates/phx.gen.live/index.ex b/priv/templates/phx.gen.live/index.ex index 910adccb2d..8c16389d76 100644 --- a/priv/templates/phx.gen.live/index.ex +++ b/priv/templates/phx.gen.live/index.ex @@ -9,9 +9,9 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web <.header> Listing <%= schema.human_plural %> <:actions> - <.link_button navigate={~p"<%= schema.route_prefix %>/new"}> + <.link class={button_classes()} navigate={~p"<%= schema.route_prefix %>/new"}> New <%= schema.human_singular %> - + diff --git a/priv/templates/phx.gen.live/show.ex b/priv/templates/phx.gen.live/show.ex index f618f8e623..933244fd96 100644 --- a/priv/templates/phx.gen.live/show.ex +++ b/priv/templates/phx.gen.live/show.ex @@ -10,9 +10,12 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web <%= schema.human_singular %> {@<%= schema.singular %>.<%= schema.opts[:primary_key] || :id %>} <:subtitle>This is a <%= schema.singular %> record from your database. <:actions> - <.link_button navigate={~p"<%= schema.route_prefix %>/#{@<%= schema.singular %>}/edit?return_to=show"}> + <.link + class={button_classes()} + navigate={~p"<%= schema.route_prefix %>/#{@<%= schema.singular %>}/edit?return_to=show"} + > Edit <%= schema.singular %> - +