pub fn div[M](
style~ : Array[String] = [],
id? : String,
klass? : String,
click? : M,
children : Array[Html[M]]
) -> Html[M] let html = p([text("hello world")])fn bar(path : Path, tag : Option[Tag]){
let path = foo(path)
let tag = match tag {
None => []
Some(x) => [view(x)] // Yuck!
}
div([path] + tag) // Don't do this
}fn bar(path : Path, tag : Option[Tag]){
let path = foo(path)
let tag = match tag {
None => nothing()
Some(x) => view(x)
}
div([path, tag]) // Use @html.nothing
}let html = node(
"div",
[style("key","value"), property("id","key")],
[child1, child2],
) pub(all) enum InputType {
Button
Checkbox
Color
Date
DateTimeLocal
Email
File
Hidden
Image
Month
Number
Password
Radio
Range
Reset
Search
Submit
Tel
Text
Time
Url
Week
}type Mousetype Scrolltypealias Model = String
enum Msg {
Open
Closed(String)
YesNo(Bool)
}
fn update(msg : Msg, model : Model) -> (Cmd[Msg], Model) {
match msg {
Open => (@dialog.show("confirm"), model)
YesNo(answer) => (@dialog.close("confirm", return_value=answer.to_string()), model)
Closed(value) => (none(), value)
}
}
fn view(model : Model) -> Html[Msg] {
div([
h1([text(model)]),
button(click=Msg::Open, [text("open")]),
dialog(id="confirm", close=Msg::Closed, [
p([text("Are you sure?")]),
button(click=YesNo(true), [text("Yes")]),
button(click=YesNo(false), [text("No")]),
]),
])
}fn[M] input(input_type? : InputType, name? : String, value? : String, checked? : Bool, read_only? : Bool, multiple? : Bool, accept? : String, placeholder? : String, auto_complete? : AutoComplete, style? : Array[String], max? : Int, min? : Int, step? : Int, maxlength? : Int, minlength? : Int, pattern? : String, size? : Int, width? : Int, height? : Int, id? : String, class? : String, children? : Array[Html[M]], change? : (String) -> M, input? : (String) -> M) -> Html[M]TEA web UI framework for MoonBit
Dependencies