freedive/lib/liliform/media.ex

80 lines
1.3 KiB
Elixir

defmodule Liliform.Media do
use Liliform.Component
@doc """
Renders a media object.
"""
attr :class, :string, default: "", doc: "additional classes"
attr :rest, :global
slot :inner_block, required: true
def media(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<article class={["media", @class]} {@rest}>
<%= render_slot(@inner_block) %>
</article>
"""
end
@doc """
Renders a media-left.
"""
attr :rest, :global
slot :inner_block, required: true
def media_left(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<figure class="media-left" {@rest}>
<%= render_slot(@inner_block) %>
</figure>
"""
end
@doc """
Renders a media-content.
"""
attr :rest, :global
slot :inner_block, required: true
def media_content(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<div class="media-content" {@rest}>
<%= render_slot(@inner_block) %>
</div>
"""
end
@doc """
Renders a media-right.
"""
attr :rest, :global
slot :inner_block, required: true
def media_right(assigns) do
assigns =
assigns
|> set_bulma_classes()
~H"""
<div class="media-right" {@rest}>
<%= render_slot(@inner_block) %>
</div>
"""
end
end