Packages
phoenix_duskmoon
9.4.2
9.9.2
9.9.1
9.9.0
9.8.0
9.7.1
9.7.0
9.6.4
9.6.3
9.6.2
9.6.1
9.6.0
9.5.4
9.5.3
9.5.2
9.5.1
9.5.0
9.4.3
9.4.2
9.4.1
9.4.0
9.3.0
9.2.0
9.1.4
9.1.3
9.1.1
9.1.1-rc.1
retired
9.0.1
9.0.0-rc.3
9.0.0-rc.2
9.0.0-rc.1
8.0.0
7.2.1
7.2.0
7.1.3
7.1.2
7.1.1
6.3.2
6.3.1
6.3.0
6.2.0
6.1.3
6.1.2
6.1.1
6.1.0
6.0.10
6.0.9
6.0.8
6.0.7
6.0.6
6.0.5
6.0.4
6.0.3
6.0.2
6.0.1
6.0.0
5.2.0-beta.5
5.2.0-beta.4
5.2.0-beta.3
5.2.0-beta.2
5.2.0-beta.1
5.1.0
5.0.6
5.0.5
5.0.4
5.0.3
5.0.2
5.0.1
5.0.0
4.6.6
4.6.5
4.6.4
4.6.3
4.6.2
4.6.1
4.6.0
4.5.2
4.5.1
4.5.0
4.4.4
4.4.3
4.4.2
4.4.1
4.4.0
4.3.2
4.3.1
4.3.0
4.2.0
4.1.1
4.1.0
4.0.0
Duskmoon UI component library for Phoenix LiveView
Current section
Files
Jump to
Current section
Files
lib/phoenix_duskmoon/component/data_display/list.ex
defmodule PhoenixDuskmoon.Component.DataDisplay.List do
@moduledoc """
List component using CSS classes from `@duskmoon-dev/core`.
Renders structured lists with items that can include icons, titles,
subtitles, and action slots. Supports bordered, compact, dense,
hoverable, and multi-line layouts.
## Examples
<.dm_list>
<:item title="Profile" icon="account">View your profile</:item>
<:item title="Settings" icon="cog">App settings</:item>
</.dm_list>
<.dm_list bordered hoverable>
<:item title="Inbox" subtitle="3 new messages" active />
<:item title="Sent" subtitle="No new messages" />
</.dm_list>
"""
use Phoenix.Component
import PhoenixDuskmoon.Component.Icon.Icons
@doc """
Renders a list container with items.
## Examples
<.dm_list compact>
<:item title="Item 1" />
<:item title="Item 2" />
</.dm_list>
"""
@doc type: :component
attr(:id, :any, default: nil, doc: "HTML id attribute")
attr(:class, :any, default: nil, doc: "additional CSS classes")
attr(:bordered, :boolean, default: false, doc: "add border and item separators")
attr(:compact, :boolean, default: false, doc: "compact spacing")
attr(:dense, :boolean, default: false, doc: "dense spacing (smaller than compact)")
attr(:hoverable, :boolean, default: false, doc: "show hover effects on items")
attr(:two_line, :boolean, default: false, doc: "two-line layout for title + subtitle")
attr(:three_line, :boolean, default: false, doc: "three-line layout for longer content")
attr(:rest, :global)
slot :item, required: true, doc: "List items" do
attr(:title, :string, doc: "item primary text")
attr(:subtitle, :string, doc: "item secondary text")
attr(:icon, :string, doc: "Material Design icon name")
attr(:active, :boolean, doc: "highlight the item as active")
attr(:disabled, :boolean, doc: "disable the item")
attr(:interactive, :boolean, doc: "enable hover/focus effects")
attr(:class, :any, doc: "item CSS classes")
end
slot(:subheader, doc: "Optional section header")
def dm_list(assigns) do
~H"""
<ul
id={@id}
role="list"
class={[
"list",
@bordered && "list-bordered",
@compact && "list-compact",
@dense && "list-dense",
@hoverable && "list-hoverable",
@two_line && "list-two-line",
@three_line && "list-three-line",
@class
]}
{@rest}
>
<li :for={sh <- @subheader} class="list-subheader">
{render_slot(sh)}
</li>
<li
:for={item <- @item}
class={[
"list-item",
item[:active] && "list-item-active",
item[:disabled] && "list-item-disabled",
item[:interactive] && "list-item-interactive",
item[:class]
]}
aria-current={item[:active] && "true"}
aria-disabled={item[:disabled] && "true"}
>
<span :if={item[:icon]} class="list-item-icon" aria-hidden="true">
<.dm_mdi name={item[:icon]} class="w-6 h-6" />
</span>
<div class="list-item-content">
<div :if={item[:title]} class="list-item-title">{item[:title]}</div>
<div :if={item[:subtitle]} class="list-item-subtitle">{item[:subtitle]}</div>
{if item.inner_block, do: render_slot(item)}
</div>
</li>
</ul>
"""
end
end