Current section
Files
Jump to
Current section
Files
lib/components/containers.ex
defmodule SigmaKit.Components.Containers do
use Phoenix.LiveComponent
attr :shadow, :boolean, default: true, doc: "When true uses a shadow for emphasis"
attr :title, :string, default: nil, doc: "The title of the container"
attr :class, :any, default: "", doc: "Additional classes to apply to the container"
slot :action_bar, doc: "A slot for action buttons"
slot :inner_block, doc: "The main content of the container"
slot :footer, doc: "Content for a bottom section"
def box(assigns) do
~H"""
<div class={[
"rounded-lg border",
@shadow && "shadow-lg border-zinc-100",
!@shadow && "border-zinc-200",
@class
]}>
<div :if={!Enum.empty?(@action_bar) || @title} class="flex justify-between my-2 h-8 px-4 mt-4">
<div class="font-medium text-lg">
{@title}
</div>
<div class="flex gap-4 justify-end">
{render_slot(@action_bar)}
</div>
</div>
<div class="flex flex-col divide-y">
<div class="p-4">
{render_slot(@inner_block)}
</div>
<div :if={@footer != []} class="p-4">
{render_slot(@footer)}
</div>
</div>
</div>
"""
end
end