feat(cpp/core): primitivas UI estilo Mantine
Anade 9 primitivas reutilizables al registry C++ que replican el comportamiento de los componentes correspondientes de @fn_library / Mantine v9, todas estilizadas con tokens_cpp_core (colores Mantine dark + indigo): - button_cpp_core (component, pure) variantes primary/secondary/subtle/danger + sm/md/lg - icon_button_cpp_core (component, pure) cuadrado 28x28 con glyph centrado + tooltip - toolbar_cpp_core (component, pure) grupo horizontal de acciones con separadores - modal_dialog_cpp_core (component, pure) popup modal centrada + close con Escape - text_input_cpp_core (component, impure) InputText con label muted + placeholder - select_cpp_core (component, impure) dropdown con label + opcion '(none)' opcional - toast_cpp_core (component, impure) notificaciones efimeras + inbox con badge - tree_view_cpp_core (component, impure) jerarquia low-level con tree_node_clicked helper - process_runner_cpp_core (component, impure) tarea en std::thread + spinner inline Cada primitiva tiene su .md con frontmatter completo (params/output) y se indexa via fn index. Son la base del primitives_gallery y de cualquier app fn_ui futura.
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
---
|
||||
name: button
|
||||
kind: component
|
||||
lang: cpp
|
||||
domain: core
|
||||
version: "1.0.0"
|
||||
purity: pure
|
||||
signature: "bool fn_ui::button(const char* label, fn_ui::ButtonVariant variant = Secondary, fn_ui::ButtonSize size = Md)"
|
||||
description: "Boton ImGui con variantes (primary/secondary/subtle/danger) y tamanos (sm/md/lg) usando fn_tokens. Replica Mantine Button / fn_library Button."
|
||||
tags: [imgui, button, ui, form, tokens]
|
||||
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/button.cpp"
|
||||
framework: imgui
|
||||
params:
|
||||
- name: label
|
||||
desc: "Texto visible del boton (tambien se usa como id ImGui; prefijar con ## para solo-id)"
|
||||
- name: variant
|
||||
desc: "ButtonVariant: Primary (indigo), Secondary (surface+border, default), Subtle (transparente), Danger (rojo)"
|
||||
- name: size
|
||||
desc: "ButtonSize: Sm (compacto), Md (default), Lg (grande, font x1.1)"
|
||||
output: "true el frame en que se hace click, false en caso contrario"
|
||||
---
|
||||
|
||||
# button
|
||||
|
||||
Boton con variantes semanticas y tamanos fijos. Usa tokens (`primary`, `surface`, `error`, `border`, `text`) y padding/radius consistentes — mismo estilo visual en cualquier app C++ que lo use.
|
||||
|
||||
## Variantes
|
||||
|
||||
| Variant | Uso | Colores |
|
||||
|---------|-----|---------|
|
||||
| `Primary` | Accion principal (Save, Submit) | `colors::primary` + hover |
|
||||
| `Secondary` | Accion neutra (Cancel) | `surface` + `border` |
|
||||
| `Subtle` | Accion discreta (ver mas) | transparente + hover surface |
|
||||
| `Danger` | Accion destructiva (Delete) | `colors::error` |
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```cpp
|
||||
#include "core/button.h"
|
||||
using fn_ui::button;
|
||||
using V = fn_ui::ButtonVariant;
|
||||
|
||||
if (button("Reindex", V::Primary)) { ... }
|
||||
if (button("Cancel", V::Subtle)) { ... }
|
||||
if (button("Delete", V::Danger)) { ... }
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
- No gestiona layout: usar `ImGui::SameLine()` o `toolbar` para alinear varios.
|
||||
- Para botones solo-icono sin texto, usar `icon_button`.
|
||||
Reference in New Issue
Block a user