{% extends "djust_theming/gallery/storybook_base.html" %} {% load theme_tags theme_components %} {% block title %}{{ display_name }} — Component Storybook{% endblock %} {% block content %} {# ===== Header ===== #}

{{ display_name }}

{% if component_type == "template" %} {{ required_context|length }} required {{ optional_context|length }} optional {{ available_slots|length }} slot{{ available_slots|length|pluralize }} {{ accessibility|length }} a11y rule{{ accessibility|length|pluralize }} {% else %} python component {% if category %}{{ category }}{% endif %} {% if python_params %}{{ python_params|length }} param{{ python_params|length|pluralize }}{% endif %} {% endif %}
{# ===== 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 }}
{% for p in python_params %} {% endfor %}
NameTypeDefault
{{ p.name }} {{ p.annotation|default:"—" }} {{ p.default }}
{% endif %} {# ===== Props — Required (template components) ===== #} {% if component_type == "template" and required_context %}
PROPS — REQUIRED {{ required_context|length }}
{% for p in required_context %} {% endfor %}
NameTypeDefault
{{ p.name }} {{ p.type }} {{ p.default|default:"—" }}
{% endif %} {# ===== Props — Optional (template components) ===== #} {% if component_type == "template" and optional_context %}
PROPS — OPTIONAL {{ optional_context|length }}
{% for p in optional_context %} {% endfor %}
NameTypeDefault
{{ p.name }} {{ p.type }} {{ p.default|default:"—" }}
{% endif %} {# ===== Accessibility ===== #} {% if accessibility %}
ACCESSIBILITY {{ accessibility|length }}
{% for a in accessibility %} {% endfor %}
RequirementElementAttributeValue
{{ a.description }} {{ a.selector_hint }} {{ a.attr }} {{ a.value|default:"(present)" }}
{% endif %} {# ===== Available Slots ===== #} {% if available_slots %}
AVAILABLE SLOTS {{ available_slots|length }}
{% for slot in available_slots %} {{ slot }} {% endfor %}
{% endif %} {# ===== CSS Variables ===== #} {% if css_variables %}
CSS VARIABLES {{ css_variables|length }}
{% for var in css_variables %} {{ var }} {% endfor %}
{% endif %} {# ===== Template Source ===== #} {% if template_source %}
TEMPLATE SOURCE
{{ name }}.html
{{ template_source }}
{% endif %} {% endblock %}