defmodule Shino.UI.Breadcrumb do
@moduledoc """
Provides breadcrumb related components.
> Displays the path to the current resource using a hierarchy of links.
## Examples
### Basic
```heex
HomeComponentsBreadcrumb
```
### Collapsed
Use `` component to show a collapsed state when the
breadcrumb is too long.
```heex
<% # ... %>
<% # ... %>
```
## References
* [shadcn/ui - Breadcrumb](https://ui.shadcn.com/docs/components/breadcrumb)
"""
use Shino.UI, :component
@doc """
The root contains all the parts of a breadcrumb.
"""
attr :class, :any, default: nil
attr :rest, :global
slot :inner_block, required: true
def root(assigns) do
~H"""
"""
end
@doc """
Renders a breadcrumb list.
"""
attr :class, :any, default: nil
attr :rest, :global
slot :inner_block, required: true
def list(assigns) do
~H"""
<%= render_slot(@inner_block) %>
"""
end
@doc """
Renders a breadcrumb item.
In theory, you can put anything into a breadcrumb item, such as:
* a link
* a dropdown menu
* ...
"""
attr :class, :any, default: nil
attr :rest, :global
slot :inner_block, required: true
def item(assigns) do
~H"""
<%= render_slot(@inner_block) %>
"""
end
@doc """
Renders a breadcrumb link.
"""
attr :class, :any, default: nil
attr :rest, :global, include: ~w(href navigate patch method)
slot :inner_block, required: true
def anchor(assigns) do
~H"""
<.link class={mc(["transition-colors hover:text-foreground", @class])} {@rest}>
<%= render_slot(@inner_block) %>
"""
end
@doc """
Renders a breadcrumb page which indicates the page that user visits currently.
"""
attr :class, :any, default: nil
attr :rest, :global
slot :inner_block, required: true
def page(assigns) do
~H"""
<%= render_slot(@inner_block) %>
"""
end
@doc """
Renders a breadcrumb separator.
## Customization
To create a custom separator, put the custom content to the `:inner_block` slot:
```heex
<% # custom content %>
```
"""
attr :class, :any, default: nil
attr :rest, :global
slot :inner_block
def separator(assigns) do
~H"""
svg]:size-3.5", @class])} {@rest}>
<%= if @inner_block == [] do %>
<.icon name="tabler-chevron-right" class="size-3.5" />
<% else %>
<%= render_slot(@inner_block) %>
<% end %>
"""
end
defdelegate sep(assigns), to: __MODULE__, as: :separator
@doc """
Renders a breadcrumb ellipsis.
## Customization
To create a custom ellipsis, put the custom content to the `:inner_block` slot:
```heex
<% # custom content %>
```
"""
attr :class, :any, default: nil
attr :rest, :global
slot :inner_block
def ellipsis(assigns) do
~H"""
<%= if @inner_block == [] do %>
<.icon name="tabler-dots" class="size-3.5" />
<% else %>
<%= render_slot(@inner_block) %>
<% end %>
More