defmodule PineUi.Card do
@moduledoc """
Provides card components for organizing content with various behaviors.
The Card module offers three main variants:
- `basic/1` - Simple card with title, subtitle, content area, and optional footer
- `interactive/1` - Card with hover animation effects
- `collapsible/1` - Expandable/collapsible card with toggle functionality
## Examples
Card content here This card has hover effects This content can be hidden
Content goes here
<.basic title="Card with Footer" subtitle="With explanation" footer="Last updated: Yesterday">Content goes here
## Options * `:title` - Card title text (optional) * `:subtitle` - Card subtitle text (optional) * `:footer` - Footer content (optional) * `:padded` - Whether to add padding to the body (optional, defaults to true) * `:class` - Additional CSS classes for the card container (optional) """ def basic(assigns) do assigns = assigns |> assign_new(:class, fn -> "" end) |> assign_new(:padded, fn -> true end) ~H"""<%= @subtitle %>
<% end %>Hover over me to see effects
<.interactive title="Interactive Card" subtitle="With animations">Content with hover effects
## Options * `:title` - Card title text (optional) * `:subtitle` - Card subtitle text (optional) * `:footer` - Footer content (optional) * `:padded` - Whether to add padding to the body (optional, defaults to true) * `:class` - Additional CSS classes for the card container (optional) """ def interactive(assigns) do assigns = assigns |> assign_new(:class, fn -> "" end) |> assign_new(:padded, fn -> true end) ~H"""<%= @subtitle %>
<% end %>This content can be hidden
<.collapsible title="Initially expanded" open={true}>This content is visible by default
## Options * `:title` - Card title text (optional) * `:subtitle` - Card subtitle text (optional) * `:footer` - Footer content (optional) * `:padded` - Whether to add padding to the body (optional, defaults to true) * `:open` - Whether the card is expanded on initial render (optional, defaults to false) * `:class` - Additional CSS classes for the card container (optional) """ def collapsible(assigns) do assigns = assigns |> assign_new(:class, fn -> "" end) |> assign_new(:padded, fn -> true end) |> assign_new(:open, fn -> false end) ~H"""<%= @subtitle %>
<% end %>