1use crate::{Attribute, Node};
2use sauron_vdom::builder::element;
3use std::fmt::Debug;
4
5#[derive(Debug, Clone, PartialEq)]
6pub enum Widget {
7 Vbox,
8 Hbox,
9 Button,
10 Text(String),
11 Block(String),
12 TextBox(String),
13}
14
15pub fn widget<MSG>(
16 widget: Widget,
17 attrs: Vec<Attribute<MSG>>,
18 children: Vec<Node<MSG>>,
19) -> Node<MSG> {
20 element(widget, attrs, children)
21}
22
23pub fn vbox<MSG>(attrs: Vec<Attribute<MSG>>, children: Vec<Node<MSG>>) -> Node<MSG> {
24 widget(Widget::Vbox, attrs, children)
25}
26
27pub fn hbox<MSG>(attrs: Vec<Attribute<MSG>>, children: Vec<Node<MSG>>) -> Node<MSG> {
28 widget(Widget::Hbox, attrs, children)
29}
30
31pub fn button<MSG>(attrs: Vec<Attribute<MSG>>) -> Node<MSG> {
32 widget(Widget::Button, attrs, vec![])
33}
34
35pub fn text<MSG>(txt: &str) -> Node<MSG> {
36 widget(Widget::Text(txt.to_string()), vec![], vec![])
37}
38
39pub fn textbox<MSG>(attrs: Vec<Attribute<MSG>>, txt: &str) -> Node<MSG> {
40 widget(Widget::TextBox(txt.to_string()), attrs, vec![])
41}
42
43pub fn block<MSG>(title: &str) -> Node<MSG> {
44 widget(Widget::Block(title.to_string()), vec![], vec![])
45}
46