{#- chirp-ui: Logo component
Reusable brand mark with text/image variants and optional link wrapper.
Usage:
from "chirpui/logo.html" import logo
{{ logo(text="ChirpUI", variant="text") }}
{{ logo(image_src="/static/logo.svg", image_alt="ChirpUI", variant="image") }}
{{ logo(text="ChirpUI", image_src="/static/logo.svg", href="/", variant="both") }}
Variants: text, image, both
Sizes: sm, md, lg
Align: start, center, end
-#}
{% def logo(text="", image_src="", image_alt="", href=none, variant="both", size="md", align="center", cls="") %}
{% set variant = variant | validate_variant(("text", "image", "both"), "both") %}
{% set size = size | validate_variant(("sm", "md", "lg"), "md") %}
{% set align = align | validate_variant(("start", "center", "end"), "center") %}
{% set has_text = text | trim %}
{% set has_image = image_src | trim %}
{% set root_cls = "chirpui-logo chirpui-logo--" ~ variant ~ " chirpui-logo--" ~ size ~ " chirpui-logo--" ~ align ~ (" " ~ cls if cls else "") %}
{% set should_show_image = (variant in ("image", "both")) and has_image %}
{% set should_show_text = (variant in ("text", "both")) and has_text %}
{% set has_accessible_text_fallback = variant == "image" and (not image_alt | trim) and has_text %}
{% set resolved_alt = image_alt if image_alt | trim else "" %}
{% if href %}
{% if should_show_image %}
{% end %}
{% if should_show_text %}
{{ text }}
{% elif has_accessible_text_fallback %}
{{ text }}
{% end %}
{% else %}
{% if should_show_image %}
{% end %}
{% if should_show_text %}
{{ text }}
{% elif has_accessible_text_fallback %}
{{ text }}
{% end %}
{% end %}
{% end %}