209 lines
3.9 KiB
Elixir
209 lines
3.9 KiB
Elixir
defmodule Liliform.Navbar do
|
|
use Liliform.Component
|
|
|
|
@doc """
|
|
Renders a navbar.
|
|
"""
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
slot :inner_block, required: true
|
|
|
|
def navbar(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<nav class={["navbar", @class]} {@rest}>
|
|
<%= render_slot(@inner_block) %>
|
|
</nav>
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-brand.
|
|
"""
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
slot :inner_block, required: true
|
|
|
|
def navbar_brand(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<div class={["navbar-brand", @class]} {@rest}>
|
|
<%= render_slot(@inner_block) %>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-menu.
|
|
"""
|
|
attr :id, :string, required: true
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
slot :inner_block, required: true
|
|
|
|
def navbar_menu(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<div id={@id} class={["navbar-menu", @class]} {@rest}>
|
|
<%= render_slot(@inner_block) %>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-start.
|
|
"""
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
slot :inner_block, required: true
|
|
|
|
def navbar_start(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<div class={["navbar-start", @class]} {@rest}>
|
|
<%= render_slot(@inner_block) %>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-end.
|
|
"""
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
slot :inner_block, required: true
|
|
|
|
def navbar_end(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<div class={["navbar-end", @class]} {@rest}>
|
|
<%= render_slot(@inner_block) %>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-item.
|
|
"""
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
slot :inner_block, required: true
|
|
|
|
def navbar_item(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<div class={["navbar-item", @class]} {@rest}>
|
|
<%= render_slot(@inner_block) %>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-dropdown.
|
|
"""
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
slot :inner_block, required: true
|
|
|
|
def navbar_dropdown(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<div class={["navbar-dropdown", @class]} {@rest}>
|
|
<%= render_slot(@inner_block) %>
|
|
</div>
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-link.
|
|
"""
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
slot :inner_block, required: true
|
|
|
|
def navbar_link(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<a class={["navbar-link", @class]} {@rest}>
|
|
<%= render_slot(@inner_block) %>
|
|
</a>
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-divider.
|
|
"""
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
def navbar_divider(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<hr class={["navbar-divider", @class]} {@rest} />
|
|
"""
|
|
end
|
|
|
|
@doc """
|
|
Renders a navbar-burger.
|
|
"""
|
|
attr :target, :string, required: true
|
|
attr :class, :string, default: "", doc: "additional classes"
|
|
attr :rest, :global
|
|
|
|
def navbar_burger(assigns) do
|
|
assigns =
|
|
assigns
|
|
|> set_bulma_classes()
|
|
|
|
~H"""
|
|
<a
|
|
role="button"
|
|
class={["navbar-burger", @class]}
|
|
aria-label="menu"
|
|
aria-expanded="false"
|
|
data-target={@target}
|
|
{@rest}
|
|
>
|
|
<span aria-hidden="true"></span>
|
|
<span aria-hidden="true"></span>
|
|
<span aria-hidden="true"></span>
|
|
<span aria-hidden="true"></span>
|
|
</a>
|
|
"""
|
|
end
|
|
end
|