@@ -175,14 +175,15 @@ defmodule LiveDebugger.App.Web.Components do
175175 """
176176 attr ( :id , :string , doc: "the optional id of flash container" )
177177 attr ( :flash , :map , default: % { } , doc: "the map of flash messages to display" )
178+ attr ( :kind , :atom , values: [ :info , :error ] , doc: "used for styling and flash lookup" )
178179 attr ( :rest , :global , doc: "the arbitrary HTML attributes to add to the flash container" )
179180
180181 def flash ( assigns ) do
181- message = Phoenix.Flash . get ( assigns . flash , :error )
182+ message = Phoenix.Flash . get ( assigns . flash , assigns . kind )
182183
183184 assigns =
184185 assigns
185- |> assign_new ( :id , fn -> "flash" end )
186+ |> assign_new ( :id , fn -> "flash- #{ assigns . kind } " end )
186187 |> assign ( :message , message )
187188
188189 ~H"""
@@ -193,13 +194,16 @@ defmodule LiveDebugger.App.Web.Components do
193194 role = "alert "
194195 class = { [
195196 "fixed left-2 bottom-2 w-80 sm:w-96 z-50 rounded-sm p-4 flex justify-between items-center gap-3" ,
196- "bg-error-bg text-error-text border-error-text border"
197+ @ kind == :error && "bg-error-bg text-error-text border-error-text border" ,
198+ @ kind == :info &&
199+ "bg-info-bg text-info-text border-info-border border"
197200 ] }
198201 { @ rest }
199202 >
200203 < div class = "flex gap-3 items-start " >
201204 < div >
202- < . icon name = "icon-x-circle " class = "text-error-icon w-3 h-3 " />
205+ < . icon :if = { @ kind == :error } name = "icon-x-circle " class = "text-error-icon w-3 h-3 " />
206+ < . icon :if = { @ kind == :info } name = "icon-info " class = "text-info-icon w-3 h-3 " />
203207 </ div >
204208 < p >
205209 <%= @ message %>
@@ -208,7 +212,7 @@ defmodule LiveDebugger.App.Web.Components do
208212 < button
209213 phx-click = {
210214 "lv:clear-flash"
211- |> JS . push ( value: % { key: :error } )
215+ |> JS . push ( value: % { key: @ kind } )
212216 |> JS . hide (
213217 to: "##{ @ id } " ,
214218 time: 200 ,
@@ -223,6 +227,25 @@ defmodule LiveDebugger.App.Web.Components do
223227 """
224228 end
225229
230+ @ doc """
231+ Shows the flash group with standard titles and content.
232+
233+ ## Examples
234+
235+ <.flash_group flash={@flash} />
236+ """
237+ attr ( :flash , :map , required: true , doc: "the map of flash messages" )
238+ attr ( :id , :string , default: "flash-group" , doc: "the optional id of flash container" )
239+
240+ def flash_group ( assigns ) do
241+ ~H"""
242+ < div id = { @ id } >
243+ < . flash kind = { :info } flash = { @ flash } />
244+ < . flash kind = { :error } flash = { @ flash } />
245+ </ div >
246+ """
247+ end
248+
226249 attr ( :id , :string , required: true )
227250 attr ( :title , :string , required: true )
228251 attr ( :class , :any , default: nil )
0 commit comments