--- name: badge kind: component lang: cpp domain: core version: "1.0.0" purity: pure signature: "void badge(const char* text, BadgeVariant variant = BadgeVariant::Default)" description: "Etiqueta inline tipo badge para estados (tested/untested, pure/impure, active/stale). Equivalente al de @fn_library. 6 variantes: Default, Success, Warning, Error, Info, Outline." tags: [imgui, badge, ui, status, label, design-system] uses_functions: - tokens_cpp_core uses_types: [] returns: [] returns_optional: false error_type: "" imports: [imgui] tested: false tests: [] test_file_path: "" file_path: "cpp/functions/core/badge.cpp" framework: imgui params: - name: text desc: "Texto del badge (ej: 'pure', 'tested', 'active')" - name: variant desc: "Variante semántica: Default | Success | Warning | Error | Info | Outline" output: "Dibuja el badge en la posición actual del cursor y avanza el layout (igual que ImGui::Text)" --- # badge Etiqueta inline con fondo coloreado y texto, para mostrar estado al lado de un ítem. Usa `fn_tokens::colors` y `fn_tokens::radius` para coherencia visual con el resto del dashboard. ## Uso ```cpp #include "core/badge.h" // En una celda de tabla junto al nombre de una función ImGui::TextUnformatted(fn.name); ImGui::SameLine(); badge(fn.purity.c_str(), fn.purity == "pure" ? BadgeVariant::Success : BadgeVariant::Warning); // En un header, junto al título de un proyecto badge("active", BadgeVariant::Success); ImGui::SameLine(); badge("v1.2.0", BadgeVariant::Outline); ``` ## Variantes | Variant | Caso típico | |---------|-------------| | `Default` | Estados neutros (tags, kind) | | `Success` | `tested: yes`, `status: active`, `pure` | | `Warning` | `status: stale`, pendiente | | `Error` | `status: failed`, `corrupted` | | `Info` | Metadata (dominio, version) | | `Outline` | Énfasis bajo, detalles | ## Notas - Es un widget **inline** — ocupa espacio como un `Text` y respeta `SameLine`. - Padding y radio vienen de `fn_tokens` (no hardcodeados). - Sin estado interno: puro render. Se puede llamar miles de veces por frame sin coste significativo.