Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions installer/templates/phx_web/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,25 @@ defmodule <%= @web_namespace %>.CoreComponents do

def button(assigns) do
~H"""
<button
type={@type}
class={[
"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}
>
<button type={@type} class={[button_classes(), @class]} {@rest}>
{render_slot(@inner_block)}
</button>
"""
end

@doc """
Returns the default button classes.

## Examples

<.link class={button_classes()} href={~p"/items/new"}>
New Item
</.link>
"""
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 """
Renders an input with label and error messages.

Expand Down
8 changes: 3 additions & 5 deletions priv/templates/phx.gen.html/index.html.heex
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<.header>
Listing <%= schema.human_plural %>
<:actions>
<.button phx-click={JS.dispatch("click", to: {:inner, "a"})}>
<.link href={~p"<%= schema.route_prefix %>/new"}>
New <%= schema.human_singular %>
</.link>
</.button>
<.link class={button_classes()} href={~p"<%= schema.route_prefix %>/new"}>
New <%= schema.human_singular %>
</.link>
</:actions>
</.header>

Expand Down
8 changes: 3 additions & 5 deletions priv/templates/phx.gen.html/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
<%= schema.human_singular %> {@<%= schema.singular %>.id}
<:subtitle>This is a <%= schema.singular %> record from your database.</:subtitle>
<:actions>
<.button phx-click={JS.dispatch("click", to: {:inner, "a"})}>
<.link href={~p"<%= schema.route_prefix %>/#{@<%= schema.singular %>}/edit"}>
Edit <%= schema.singular %>
</.link>
</.button>
<.link class={button_classes()} href={~p"<%= schema.route_prefix %>/#{@<%= schema.singular %>}/edit"}>
Edit <%= schema.singular %>
</.link>
</:actions>
</.header>

Expand Down
23 changes: 14 additions & 9 deletions priv/templates/phx.gen.live/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -163,20 +163,25 @@ defmodule <%= @web_namespace %>.CoreComponents do

def button(assigns) do
~H"""
<button
type={@type}
class={[
"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}
>
<button type={@type} class={[button_classes(), @class]} {@rest}>
{render_slot(@inner_block)}
</button>
"""
end

@doc """
Returns the default button classes.

## Examples

<.link class={button_classes()} href={~p"/items/new"}>
New Item
</.link>
"""
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 """
Renders an input with label and error messages.

Expand Down
8 changes: 3 additions & 5 deletions priv/templates/phx.gen.live/index.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
<.header>
Listing <%= schema.human_plural %>
<:actions>
<.button phx-click={JS.dispatch("click", to: {:inner, "a"})}>
<.link navigate={~p"<%= schema.route_prefix %>/new"}>
New <%= schema.human_singular %>
</.link>
</.button>
<.link class={button_classes()} navigate={~p"<%= schema.route_prefix %>/new"}>
New <%= schema.human_singular %>
</.link>
</:actions>
</.header>

Expand Down
8 changes: 3 additions & 5 deletions priv/templates/phx.gen.live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ 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.</:subtitle>
<:actions>
<.button phx-click={JS.dispatch("click", to: {:inner, "a"})}>
<.link navigate={~p"<%= schema.route_prefix %>/#{@<%= schema.singular %>}/edit?return_to=show"}>
Edit <%= schema.singular %>
</.link>
</.button>
<.link class={button_classes()} navigate={~p"<%= schema.route_prefix %>/#{@<%= schema.singular %>}/edit?return_to=show"}>
Edit <%= schema.singular %>
</.link>
</:actions>
</.header>

Expand Down
Loading