// Button Click Test - Proves Event Handlers Work
// This demonstrates that:
// - Buttons can be clicked
// - Event handlers execute
// - Signals update (visible in console)
// - UI rendering works
use std::ui::*
@export
fn start() {
println!("🔘 Starting Button Test")
// Create a signal to track clicks
let click_count = Signal::new(0)
// Create render function for reactivity
let render = move || {
let click_count_handler = click_count.clone()
let count_display = click_count.clone()
Container::new()
.max_width("600px")
.child(Panel::new("Button Click Test")
.child(
Flex::new()
.direction(FlexDirection::Column)
.gap("20px")
.child(Text::new("Click the button below and check the browser console!"))
.child(Text::new(format!("Clicks so far: {}", count_display.get()))
.size(TextSize::Large))
.child(
Button::new("Click Me!")
.variant(ButtonVariant::Primary)
.size(ButtonSize::Large)
.on_click(move || {
let current = click_count_handler.get()
let new_count = current + 1
click_count_handler.set(new_count)
println!("🎉 Button clicked! Count: {}", new_count)
})
)
.child(Alert::info("Check the console AND watch the count update!"))
)
)
.to_vnode()
}
println!("✅ UI created, mounting...")
ReactiveApp::new("Button Test", render).run()
println!("✅ UI mounted! Click the button to test.")
}
fn main() {
start()
}