Current section
Files
Jump to
Current section
Files
lib/components/alerts.ex
defmodule SigmaKit.Components.Alerts do
use Phoenix.LiveComponent
attr :danger, :boolean, default: false, doc: "Apply the danger style to the alert."
attr :success, :boolean, default: false, doc: "Apply the success style to the alert."
attr :warning, :boolean, default: false, doc: "Apply the warning style to the alert."
attr :info, :boolean, default: false, doc: "Apply the info style to the alert."
attr :title, :string, default: nil, doc: "The title of the alert."
attr :class, :any, default: nil, doc: "Additional classes to apply to the alert."
slot :inner_block, doc: "The content to render inside the alert."
def alert(assigns) do
~H"""
<div class={[
@danger && "bg-red-100 border-red-400 text-red-700",
@success && "bg-green-100 border-green-400 text-green-700",
@warning && "bg-yellow-100 border-yellow-400 text-yellow-700",
@info && "bg-blue-100 border-blue-400 text-blue-700",
"border-l-4 py-2 px-4",
@class
]}>
<div class="font-bold mb">{@title}</div>
<div :if={SigmaKit.Util.present?(@inner_block)} class="text-zinc-600 text-sm">
{render_slot(@inner_block)}
</div>
</div>
"""
end
end