{#- chirp-ui: ASCII Progress Terminal-style progress bar using block characters and box-drawing. Usage: from "chirpui/ascii_progress.html" import ascii_progress ascii_progress(value=75) ascii_progress(value=40, variant="accent", label="Loading") ascii_progress(value=100, variant="success") Values: 0-100 (percentage) -#} {% def ascii_progress(value=0, label="", variant="", width=20, cls="") %} {% set variant = variant | validate_variant(("", "default", "accent", "success", "warning"), "") %} {% set variant_class = " chirpui-ascii-progress--" ~ variant if variant else "" %} {% set bounded_value = 100 if value > 100 else (0 if value < 0 else value) %} {% set filled = ((bounded_value / 100) * width) | int %} {% set filled = width if filled > width else (0 if filled < 0 else filled) %} {% set empty = width - filled %}