{# ===== Live Preview (template components) ===== #}
{% if component_type == "template" and examples %}
LIVE PREVIEW {{ examples|length }}
{% for ex in examples %}
{% if name == "button" %}{% theme_button ex.text variant=ex.variant size=ex.size %}
{% elif name == "badge" %}{% theme_badge ex.text variant=ex.variant %}
{% elif name == "card" %}{% theme_card title=ex.title description=ex.description %}
{% elif name == "alert" %}{% theme_alert ex.message variant=ex.variant %}
{% elif name == "input" %}{% theme_input ex.name label=ex.label placeholder=ex.placeholder type=ex.type %}
{% elif name == "checkbox" %}{% theme_checkbox ex.name label=ex.label description=ex.description %}
{% elif name == "textarea" %}{% theme_textarea ex.name label=ex.label placeholder=ex.placeholder rows=ex.rows %}
{% elif name == "select" %}{% theme_select ex.name label=ex.label options=ex.options placeholder=ex.placeholder %}
{% elif name == "modal" %}{% theme_modal ex.id title=ex.title size=ex.size %}
{% elif name == "dropdown" %}{% theme_dropdown ex.id label=ex.label align=ex.align %}
{% elif name == "radio" %}{% theme_radio ex.name label=ex.label options=ex.options selected=ex.selected %}
{% else %}
{{ name }}({% for key, val in ex.items %}{{ key }}={{ val }}{% if not forloop.last %}, {% endif %}{% endfor %})
{% endif %}
{% endfor %}
{% endif %}
{# ===== Python Component Preview ===== #}
{% if component_type == "python" %}
{% if python_examples_html %}
EXAMPLES {{ python_examples_html|length }}
{% for ex in python_examples_html %}
{% if ex.html %}
{{ ex.html|safe }}
{% endif %}
python
{{ name }}({{ ex.kwargs_display }})
{% endfor %}
{% else %}
PREVIEW
Preview not available — component requires runtime dependencies or no examples defined.
{% endif %}
{% endif %}
{# ===== Usage ===== #}
USAGE
{% if component_type == "template" %}template{% else %}python{% endif %}
{% if component_type == "template" %}
{% verbatim %}{%{% endverbatim %} load theme_components {% verbatim %}%}{% endverbatim %}
{% verbatim %}{%{% endverbatim %} theme_{{ name }}{% for p in required_context %} {{ p.name }}{% endfor %}{% for p in optional_context %} {{ p.name }}={{ p.default|default:"..." }}{% endfor %} {% verbatim %}%}{% endverbatim %}
{% else %}
from djust_components.components.{{ name }} import {{ display_name|cut:" " }}
component = {{ display_name|cut:" " }}({% for p in python_params %}{% if not forloop.first %}
{% endif %}{{ p.name }}{% if p.default != "—" %}={{ p.default }}{% endif %}{% if not forloop.last %},{% endif %}{% endfor %})
html = component.render()
{% endif %}
{# ===== Python Params ===== #}
{% if component_type == "python" and python_params %}
PARAMETERS {{ python_params|length }}
Name
Type
Default
{% for p in python_params %}
{{ p.name }}
{{ p.annotation|default:"—" }}
{{ p.default }}
{% endfor %}
{% endif %}
{# ===== Props — Required (template components) ===== #}
{% if component_type == "template" and required_context %}
PROPS — REQUIRED {{ required_context|length }}
Name
Type
Default
{% for p in required_context %}
{{ p.name }}
{{ p.type }}
{{ p.default|default:"—" }}
{% endfor %}
{% endif %}
{# ===== Props — Optional (template components) ===== #}
{% if component_type == "template" and optional_context %}