@@ -89,32 +89,35 @@ defmodule YearbookWeb.CoreComponents do
8989 <.button phx-click="go" variant="primary">Send!</.button>
9090 <.button navigate={~p"/"}>Home</.button>
9191 """
92- attr :rest , :global , include: ~w( href navigate patch method download name value disabled)
93- attr :class , :string
94- attr :variant , :string , values: ~w( primary)
92+ attr :type , :string , default: "button"
93+ attr :class , :string , default: ""
94+ attr :variant , :string , default: "primary" , values: ~w( primary secondary)
95+ attr :rest , :global , include: ~w( disabled form name value)
96+
9597 slot :inner_block , required: true
9698
97- def button ( % { rest: rest } = assigns ) do
98- variants = % { "primary" => "btn-primary" , nil => "btn-primary btn-soft" }
99+ def button ( assigns ) do
100+ ~H"""
101+ < button
102+ type = { @ type }
103+ class = { [
104+ @ class ,
105+ variant_classes ( @ variant )
106+ ] }
107+ { @ rest }
108+ >
109+ { render_slot ( @ inner_block ) }
110+ </ button >
111+ """
112+ end
99113
100- assigns =
101- assign_new ( assigns , :class , fn ->
102- [ "btn" , Map . fetch! ( variants , assigns [ :variant ] ) ]
103- end )
114+ # Variant classes
115+ defp variant_classes ( "primary" ) do
116+ "rounded-xl bg-primary p-4 font-semibold tracking-wider text-white cursor-pointer"
117+ end
104118
105- if rest [ :href ] || rest [ :navigate ] || rest [ :patch ] do
106- ~H"""
107- < . link class = { @ class } { @ rest } >
108- { render_slot ( @ inner_block ) }
109- </ . link >
110- """
111- else
112- ~H"""
113- < button class = { @ class } { @ rest } >
114- { render_slot ( @ inner_block ) }
115- </ button >
116- """
117- end
119+ defp variant_classes ( "secondary" ) do
120+ "rounded-4xl bg-white p-4 font-semibold tracking-wider text-primary cursor-pointer"
118121 end
119122
120123 @ doc """
0 commit comments