/**
* UI Demo/Test - Para probar componentes localmente sin hacer release
*
* Ejecutar:
* 1. Crear un archivo index.html que importe este archivo
* 2. O usar con Vite: bun add -d vite && bun vite UI/app.js
*
* Alternativamente, simplemente copiar las partes que necesitas a tu proyecto
*/
import { $, html, effect } from "../../index.js";
import { Button, Input, Card, Drawer, Menu, Dropdown, Fab, Dialog, Loading } from "./index.js";
// Importar la función helper de loading
import { loading } from "./components/Loading.js";
// Estado para la demo
const state = {
inputValue: $(""),
checkboxValue: $(false),
radioValue: $("option1"),
rangeValue: $(50),
showDialog: $(false),
openDrawer: $(false),
};
// Menú de navegación
const menuItems = [
{ label: "Home", icon: "icon-[lucide--home]", href: "#/home" },
{ label: "About", icon: "icon-[lucide--info]", href: "#/about" },
{
label: "Components",
icon: "icon-[lucide--box]",
open: false,
sub: [
{ label: "Button", href: "#/button" },
{ label: "Input", href: "#/input" },
{ label: "Card", href: "#/card" },
{ label: "Forms", href: "#/forms" },
]
},
];
// Demo page principal
export default function App() {
effect(() => {
console.log("Input value:", state.inputValue());
});
return html`
Buttons
console.log("Primary clicked")}>Primary
Secondary
Accent
Ghost
Link
Loading
Disabled
With Badge
With Tooltip
Input
state.inputValue(v)}
placeholder="Enter username"
>
Current input value: "${state.inputValue()}"
Card
Card Title
This is a basic card with some content.
Accept
Cancel
Card with Image
Beautiful flower image
Buy Now
Form Controls
state.checkboxValue(v)}
>
Checkbox value: ${() => state.checkboxValue() ? "checked" : "unchecked"}
state.radioValue() === "option1"}
.value=${"option1"}
label="Option 1"
@change=${(v) => state.radioValue(v)}
>
state.radioValue() === "option2"}
.value=${"option2"}
label="Option 2"
@change=${(v) => state.radioValue(v)}
>
state.radioValue() === "option3"}
.value=${"option3"}
label="Option 3"
@change=${(v) => state.radioValue(v)}
>
Radio value: "${state.radioValue()}"
state.rangeValue(Number(v))}
>
Range value: ${state.rangeValue()}
Loading
loading(true, "Loading...")}>
Show Loading
loading(false)}>
Hide Loading
Dialog
state.showDialog(true)}>Open Dialog
state.showDialog(false)}>
Confirm Action
Are you sure you want to proceed?
state.showDialog(false)}>Cancel
{ console.log("Confirmed!"); state.showDialog(false); }}>Confirm
FAB (Floating Action Button)
`;
}
// Mount the app
if (typeof document !== "undefined") {
const root = document.getElementById("app");
if (root) {
root.appendChild(App());
}
}