feat(cpp/core): design tokens + primitivos UI para dashboards ImGui
Trasladar principios del DESIGN_SYSTEM.md de @fn_library (Mantine/React)
al mundo C++/ImGui sin añadir deps externas:
cpp/functions/core/
tokens — colors/spacing/radius/font_size como constexpr +
apply_dark_theme() al ImGuiStyle global. Dark + indigo
primary (Mantine-inspired).
badge — etiqueta inline 6 variantes (Default/Success/Warning/
Error/Info/Outline). <Badge> de @fn_library en C++.
empty_state — placeholder centrado para tablas/listas vacías.
page_header — header con title + subtitle + separator + hueco
para acciones (patrón begin/end).
Scope limitado (KISS) a fases 1-2 del plan: tokens + 3 primitivos.
No se duplica dashboard_panel con un "card" — el existente ya cumple
el rol. Fases 3-5 (charts ImPlot line/area, app_shell con navbar,
toast/alert) quedan fuera hasta que el dashboard crezca en alcance.
Resultado:
- 869 funciones (+4) en registry.db.
- Dashboard con header homogéneo y empty states en todas las tablas.
- Sin hardcode de ImVec4 disperso en views.cpp.
Diary + CHANGELOG actualizados.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
---
|
||||
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 <Badge> 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.
|
||||
Reference in New Issue
Block a user