File tree Expand file tree Collapse file tree 6 files changed +40
-38
lines changed
installer/templates/phx_web/components Expand file tree Collapse file tree 6 files changed +40
-38
lines changed Original file line number Diff line number Diff line change @@ -163,20 +163,25 @@ defmodule <%= @web_namespace %>.CoreComponents do
163163
164164 def button ( assigns ) do
165165 ~H"""
166- < button
167- type = { @ type }
168- class = { [
169- "phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3" ,
170- "text-sm font-semibold leading-6 text-white active:text-white/80" ,
171- @ class
172- ] }
173- { @ rest }
174- >
166+ < button type = { @ type } class = { [ button_classes ( ) , @ class ] } { @ rest } >
175167 { render_slot ( @ inner_block ) }
176168 </ button >
177169 """
178170 end
179171
172+ @ doc """
173+ Returns the default button classes.
174+
175+ ## Examples
176+
177+ <.link class={button_classes()} href={~p"/items/new"}>
178+ New Item
179+ </.link>
180+ """
181+ def button_classes do
182+ "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"
183+ end
184+
180185 @ doc """
181186 Renders an input with label and error messages.
182187
Original file line number Diff line number Diff line change 11< . header >
22 Listing <%= schema . human_plural %>
33 <: actions >
4- < . button phx-click = { JS . dispatch ( "click" , to: { :inner , "a" } ) } >
5- < . link href = { ~p" <%= schema.route_prefix %>/new" } >
6- New <%= schema . human_singular %>
7- </ . link >
8- </ . button >
4+ < . link class = { button_classes ( ) } href = { ~p" <%= schema.route_prefix %>/new" } >
5+ New <%= schema . human_singular %>
6+ </ . link >
97 </: actions >
108</ . header >
119
Original file line number Diff line number Diff line change 22 <%= schema . human_singular %> { @< % = schema . singular % > .id}
33 <: subtitle > This is a <%= schema . singular %> record from your database.</: subtitle >
44 <: actions >
5- < . button phx-click = { JS . dispatch ( "click" , to: { :inner , "a" } ) } >
6- < . link href = { ~p"<%= schema.route_prefix %>/#{@< % = schema . singular % > } /edit"} >
7- Edit <%= schema . singular %>
8- </ . link >
9- </ . button >
5+ < . link class = { button_classes ( ) } href = { ~p"<%= schema.route_prefix %>/#{@< % = schema . singular % > } /edit"} >
6+ Edit <%= schema . singular %>
7+ </ . link >
108 </: actions >
119</ . header >
1210
Original file line number Diff line number Diff line change @@ -163,20 +163,25 @@ defmodule <%= @web_namespace %>.CoreComponents do
163163
164164 def button ( assigns ) do
165165 ~H"""
166- < button
167- type = { @ type }
168- class = { [
169- "phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3" ,
170- "text-sm font-semibold leading-6 text-white active:text-white/80" ,
171- @ class
172- ] }
173- { @ rest }
174- >
166+ < button type = { @ type } class = { [ button_classes ( ) , @ class ] } { @ rest } >
175167 { render_slot ( @ inner_block ) }
176168 </ button >
177169 """
178170 end
179171
172+ @ doc """
173+ Returns the default button classes.
174+
175+ ## Examples
176+
177+ <.link class={button_classes()} href={~p"/items/new"}>
178+ New Item
179+ </.link>
180+ """
181+ def button_classes do
182+ "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"
183+ end
184+
180185 @ doc """
181186 Renders an input with label and error messages.
182187
Original file line number Diff line number Diff line change @@ -9,11 +9,9 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
99 < . header >
1010 Listing <%= schema . human_plural %>
1111 <: actions >
12- < . button phx-click = { JS . dispatch ( "click" , to: { :inner , "a" } ) } >
13- < . link navigate = { ~p" <%= schema.route_prefix %>/new" } >
14- New <%= schema . human_singular %>
15- </ . link >
16- </ . button >
12+ < . link class = { button_classes ( ) } navigate = { ~p" <%= schema.route_prefix %>/new" } >
13+ New <%= schema . human_singular %>
14+ </ . link >
1715 </: actions >
1816 </ . header >
1917
Original file line number Diff line number Diff line change @@ -10,11 +10,9 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
1010 <%= schema . human_singular %> { @< % = schema . singular % > . < % = schema . opts [ :primary_key ] || :id % >}
1111 <: subtitle > This is a <%= schema . singular %> record from your database.</: subtitle >
1212 <: actions >
13- < . button phx-click = { JS . dispatch ( "click" , to: { :inner , "a" } ) } >
14- < . link navigate = { ~p"<%= schema.route_prefix %>/#{@< % = schema . singular % > } /edit? return_to =show "} >
15- Edit <%= schema . singular %>
16- </ . link >
17- </ . button >
13+ < . link class = { button_classes ( ) } navigate = { ~p"<%= schema.route_prefix %>/#{@< % = schema . singular % > } /edit? return_to =show "} >
14+ Edit <%= schema . singular %>
15+ </ . link >
1816 </: actions >
1917 </ . header >
2018
You can’t perform that action at this time.
0 commit comments