Files
fn_registry/cpp/functions/core/tokens.cpp
T
egutierrez fda89ca3ba 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>
2026-04-24 14:52:09 +02:00

51 lines
2.1 KiB
C++

#include "tokens.h"
namespace fn_tokens {
void apply_dark_theme() {
ImGuiStyle& s = ImGui::GetStyle();
// Colors
s.Colors[ImGuiCol_WindowBg] = colors::bg;
s.Colors[ImGuiCol_ChildBg] = colors::surface;
s.Colors[ImGuiCol_PopupBg] = colors::surface;
s.Colors[ImGuiCol_FrameBg] = colors::surface;
s.Colors[ImGuiCol_FrameBgHovered] = colors::surface_hover;
s.Colors[ImGuiCol_FrameBgActive] = colors::surface_hover;
s.Colors[ImGuiCol_Border] = colors::border;
s.Colors[ImGuiCol_BorderShadow] = ImVec4(0, 0, 0, 0);
s.Colors[ImGuiCol_Text] = colors::text;
s.Colors[ImGuiCol_TextDisabled] = colors::text_dim;
s.Colors[ImGuiCol_Button] = colors::primary;
s.Colors[ImGuiCol_ButtonHovered] = colors::primary_hover;
s.Colors[ImGuiCol_ButtonActive] = colors::primary;
s.Colors[ImGuiCol_Header] = colors::surface_hover;
s.Colors[ImGuiCol_HeaderHovered] = colors::primary;
s.Colors[ImGuiCol_HeaderActive] = colors::primary_hover;
s.Colors[ImGuiCol_Tab] = colors::surface;
s.Colors[ImGuiCol_TabHovered] = colors::primary_hover;
s.Colors[ImGuiCol_TabActive] = colors::primary;
s.Colors[ImGuiCol_Separator] = colors::border;
s.Colors[ImGuiCol_TableHeaderBg] = colors::surface_hover;
s.Colors[ImGuiCol_TableBorderLight]= colors::border;
s.Colors[ImGuiCol_TableBorderStrong]= colors::border;
// Radius
s.FrameRounding = radius::sm;
s.ChildRounding = radius::md;
s.WindowRounding = radius::md;
s.PopupRounding = radius::md;
s.TabRounding = radius::sm;
s.GrabRounding = radius::sm;
s.ScrollbarRounding = radius::md;
// Spacing
s.ItemSpacing = ImVec2(spacing::sm, spacing::sm);
s.ItemInnerSpacing = ImVec2(spacing::xs, spacing::xs);
s.FramePadding = ImVec2(spacing::sm, spacing::xs + 2.0f);
s.WindowPadding = ImVec2(spacing::md, spacing::md);
s.CellPadding = ImVec2(spacing::sm, spacing::xs);
}
} // namespace fn_tokens