File tree Expand file tree Collapse file tree 6 files changed +20
-80
lines changed
installer/templates/phx_web/components Expand file tree Collapse file tree 6 files changed +20
-80
lines changed Original file line number Diff line number Diff line change @@ -163,53 +163,23 @@ 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
180172 @ doc """
181- Renders a link styled as a button.
173+ Returns the default button classes .
182174
183175 ## Examples
184176
185- <.link_button href={~p"/items/new"}>
177+ <.link class={button_classes()} href={~p"/items/new"}>
186178 New Item
187- </.link_button >
179+ </.link >
188180 """
189- attr :class , :string , default: nil
190-
191- attr :rest , :global ,
192- include:
193- ~w( patch navigate href replace method csrf_token download hreflang referrerpolicy rel target type) ,
194- doc: """
195- Additional HTML attributes added to the `a` tag.
196- """
197-
198- slot :inner_block , required: true
199-
200- def link_button ( assigns ) do
201- ~H"""
202- < . link
203- class = { [
204- "inline-block phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3" ,
205- "text-sm font-semibold leading-6 text-white active:text-white/80" ,
206- @ class
207- ] }
208- { @ rest }
209- >
210- { render_slot ( @ inner_block ) }
211- </ . link >
212- """
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"
213183 end
214184
215185 @ doc """
Original file line number Diff line number Diff line change 11< . header >
22 Listing <%= schema . human_plural %>
33 <: actions >
4- < . link_button href = { ~p" <%= schema.route_prefix %>/new" } >
4+ < . link class = { button_classes ( ) } href = { ~p" <%= schema.route_prefix %>/new" } >
55 New <%= schema . human_singular %>
6- </ . link_button >
6+ </ . link >
77 </: actions >
88</ . header >
99
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- < . link_button href = { ~p"<%= schema.route_prefix %>/#{@< % = schema . singular % > } /edit"} >
5+ < . link class = { button_classes ( ) } href = { ~p"<%= schema.route_prefix %>/#{@< % = schema . singular % > } /edit"} >
66 Edit <%= schema . singular %>
7- </ . link_button >
7+ </ . link >
88 </: actions >
99</ . header >
1010
Original file line number Diff line number Diff line change @@ -163,53 +163,23 @@ 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
180172 @ doc """
181- Renders a link styled as a button.
173+ Returns the default button classes .
182174
183175 ## Examples
184176
185- <.link_button href={~p"/items/new"}>
177+ <.link class={button_classes()} href={~p"/items/new"}>
186178 New Item
187- </.link_button >
179+ </.link >
188180 """
189- attr :class , :string , default: nil
190-
191- attr :rest , :global ,
192- include:
193- ~w( patch navigate href replace method csrf_token download hreflang referrerpolicy rel target type) ,
194- doc: """
195- Additional HTML attributes added to the `a` tag.
196- """
197-
198- slot :inner_block , required: true
199-
200- def link_button ( assigns ) do
201- ~H"""
202- < . link
203- class = { [
204- "inline-block phx-submit-loading:opacity-75 rounded-lg bg-zinc-900 hover:bg-zinc-700 py-2 px-3" ,
205- "text-sm font-semibold leading-6 text-white active:text-white/80" ,
206- @ class
207- ] }
208- { @ rest }
209- >
210- { render_slot ( @ inner_block ) }
211- </ . link >
212- """
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"
213183 end
214184
215185 @ doc """
Original file line number Diff line number Diff line change @@ -9,9 +9,9 @@ defmodule <%= inspect context.web_module %>.<%= inspect Module.concat(schema.web
99 < . header >
1010 Listing <%= schema . human_plural %>
1111 <: actions >
12- < . link_button navigate = { ~p" <%= schema.route_prefix %>/new" } >
12+ < . link class = { button_classes ( ) } navigate = { ~p" <%= schema.route_prefix %>/new" } >
1313 New <%= schema . human_singular %>
14- </ . link_button >
14+ </ . link >
1515 </: actions >
1616 </ . header >
1717
Original file line number Diff line number Diff line change @@ -10,9 +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- < . link_button navigate = { ~p"<%= schema.route_prefix %>/#{@< % = schema . singular % > } /edit? return_to =show "} >
13+ < . link class = { button_classes ( ) } navigate = { ~p"<%= schema.route_prefix %>/#{@< % = schema . singular % > } /edit? return_to =show "} >
1414 Edit <%= schema . singular %>
15- </ . link_button >
15+ </ . link >
1616 </: actions >
1717 </ . header >
1818
You can’t perform that action at this time.
0 commit comments