defmodule FlintUI.Badge do
@moduledoc false
use FlintUI.Component
# --------------------------------------
# Badge
# --------------------------------------
@doc """
Renders a badge component.
A badge (also known as badge or badge) are used to display small
bits of information (e.g. unread counts, status, etc).
## Examples
<.badge>Badge
<.badge size={:sm}>Badge
<.badge variant={:outline}>Badge
<.badge radius={:full}>Badge
<.badge label="Badge" />
"""
FlintAttr.size()
FlintAttr.color()
FlintAttr.radius()
attr(:variant, :atom,
values: ~w(subtle light outline dashed solid dot)a,
default: theme(:badge).default.variant,
doc: "The badge variant/style."
)
attr(:uppercase, :boolean,
default: false,
doc: "Whether to render the badge text in uppercase."
)
attr(:label, :string,
default: nil,
doc: "The label of the badge, rendered if no inner block is provided."
)
attr(:show_remove_button, :boolean,
default: false,
doc: "Wether to render a remove button."
)
attr(:on_remove, JS,
default: %JS{},
doc: "The remove button on `phx-click` event handler."
)
attr(:class, :string,
default: nil,
doc: "The class of the badge."
)
attr(:rest, :global)
slot(:inner_block,
doc: "The inner block of the badge. If no content is provided,
the value of the attr `label` is used instead."
)
slot :left_addon,
doc: "Render and addon (icon, etc.)
in the left side of the badge content." do
attr(:class, :any)
end
slot :right_addon,
doc: "Render and addon (icon, etc.)
in the right side of the badge content." do
attr(:class, :any)
end
def badge(assigns) do
assigns = assigns |> assign_classes()
~H"""