@@ -89,34 +89,41 @@ 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 = { [
99104
100- assigns =
101- assign_new ( assigns , :class , fn ->
102- [ "btn" , Map . fetch! ( variants , assigns [ :variant ] ) ]
103- end )
105+ @ class ,
106+ variant_classes ( @ variant )
104107
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
108+
109+ ] }
110+ { @ rest }
111+ >
112+ <%= render_slot ( @ inner_block ) %>
113+ </ button >
114+ """
115+ end
116+
117+ # Variant classes
118+ defp variant_classes ( "primary" ) do
119+ "rounded-xl bg-[#ee7749] p-4 font-semibold tracking-wider text-white cursor-pointer"
118120 end
119121
122+ defp variant_classes ( "secondary" ) do
123+ "rounded-4xl bg-white p-4 font-semibold tracking-wider text-[#ee7749] cursor-pointer"
124+ end
125+
126+
120127 @ doc """
121128 Renders an input with label and error messages.
122129
0 commit comments