freedive/lib/liliform/panel.ex

137 lines
2.6 KiB
Elixir
Raw Normal View History

2024-05-14 21:58:42 +02:00
defmodule Liliform.Panel do
use Liliform.Component
import Liliform.Media
2024-05-14 21:58:42 +02:00
@doc """
Renders a panel.
"""
attr :class, :string, default: "", doc: "additional classes"
attr :rest, :global
slot :inner_block, required: true
def panel(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<nav class={["panel", @class]} {@rest}>
<%= render_slot(@inner_block) %>
</nav>
"""
end
@doc """
Renders a panel-heading.
"""
attr :class, :string, default: "", doc: "additional classes"
attr :rest, :global
slot :inner_block, required: true
def panel_heading(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<p class={["panel-heading", @class]} {@rest}>
<%= render_slot(@inner_block) %>
</p>
"""
end
@doc """
Renders a panel-block.
"""
attr :class, :string, default: "", doc: "additional classes"
attr :rest, :global
slot :inner_block, required: true
def panel_block(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<a class={["panel-block", @class]} {@rest}>
<%= render_slot(@inner_block) %>
</a>
"""
end
@doc """
Renders a panel-block-div.
"""
attr :class, :string, default: "", doc: "additional classes"
attr :rest, :global
slot :inner_block, required: true
def panel_block_div(assigns) do
assigns =
assigns
|> set_bulma_classes()
2024-05-14 21:58:42 +02:00
~H"""
<div class={["panel-block", @class]} {@rest}>
<%= render_slot(@inner_block) %>
</div>
"""
end
@doc """
Renders panel-media.
"""
attr :class, :string, default: "", doc: "additional classes"
attr :rest, :global
slot :icon, required: true
slot :actions, required: true
slot :inner_block, required: true
def panel_media(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<div class={["panel-block", @class]} {@rest}>
2024-05-18 14:06:14 +02:00
<.media>
<.media_left>
<%= render_slot(@icon) %>
</.media_left>
2024-05-18 14:06:14 +02:00
<.media_content>
<%= render_slot(@inner_block) %>
</.media_content>
<.media_right>
<%= render_slot(@actions) %>
</.media_right>
</.media>
</div>
"""
end
2024-05-14 21:58:42 +02:00
@doc """
Renders a panel-tabs.
"""
attr :class, :string, default: "", doc: "additional classes"
attr :rest, :global
slot :inner_block, required: true
def panel_tabs(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<p class={["panel-tabs", @class]} {@rest}>
<%= render_slot(@inner_block) %>
</p>
"""
end
end