defmodule Shadix.Website.Components.Docs.Avatar do @moduledoc false use Shadix.Website.Components.ComponentDoc use Phoenix.Component import Shadix.Components.Avatar @impl true def description, do: "Displays a user avatar with an image and an initials fallback." @impl true def slot_example do """ <.avatar_image id="preview-avatar-image" src="data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2264%22 height=%2264%22%3E%3Crect width=%2264%22 height=%2264%22 fill=%22%23334155%22/%3E%3C/svg%3E" alt="Example avatar" /> <.avatar_fallback id="example-avatar-fallback-2">CN """ end @impl true def hidden_controls, do: [:rest] @impl true def preview(assigns) do ~H""" <.avatar {@props}> <.avatar_image id="preview-avatar-image" src="data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2264%22 height=%2264%22%3E%3Crect width=%2264%22 height=%2264%22 fill=%22%23334155%22/%3E%3C/svg%3E" alt="Example avatar" /> <.avatar_fallback id="example-avatar-fallback-2">CN """ end demo( "With image", [description: "An avatar that loads an image with initials as fallback."], """ <.avatar> <.avatar_image id="demo-avatar-image" src="data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2264%22 height=%2264%22%3E%3Crect width=%2264%22 height=%2264%22 fill=%22%23334155%22/%3E%3C/svg%3E" alt="Example avatar" /> <.avatar_fallback id="example-avatar-fallback-3">CN """ ) demo( "Fallback only", [description: "When the image fails to load, the initials fallback is shown."], """