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