bucklescript-tea
Version:
TEA for Bucklescript
87 lines (78 loc) • 2.52 kB
JavaScript
// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
;
var Vdom = require("../src-ocaml/vdom.js");
var Block = require("bs-platform/lib/js/block.js");
var Tea_app = require("../src-ocaml/tea_app.js");
var Tea_html = require("../src-ocaml/tea_html.js");
function update(model, param) {
if (typeof param === "number") {
switch (param) {
case /* Increment */0 :
return model + 1 | 0;
case /* Decrement */1 :
return model - 1 | 0;
case /* Reset */2 :
return 0;
}
} else {
return param[0];
}
}
function view_button(title, msg) {
return Tea_html.button(undefined, undefined, /* :: */[
Vdom.onMsg("click", msg),
/* [] */0
], /* :: */[
/* Text */Block.__(1, [title]),
/* [] */0
]);
}
function view(model) {
return Tea_html.div(undefined, undefined, /* [] */0, /* :: */[
Tea_html.span(undefined, undefined, /* :: */[
Vdom.style("text-weight", "bold"),
/* [] */0
], /* :: */[
/* Text */Block.__(1, [String(model)]),
/* [] */0
]),
/* :: */[
Tea_html.br(/* [] */0),
/* :: */[
view_button("Increment", model >= 3 ? /* Decrement */1 : /* Increment */0),
/* :: */[
Tea_html.br(/* [] */0),
/* :: */[
view_button("Decrement", /* Decrement */1),
/* :: */[
Tea_html.br(/* [] */0),
/* :: */[
view_button("Set to 42", /* Set */[42]),
/* :: */[
Tea_html.br(/* [] */0),
/* :: */[
model !== 0 ? view_button("Reset", /* Reset */2) : Tea_html.noNode,
/* [] */0
]
]
]
]
]
]
]
]
]);
}
var partial_arg = {
model: 4,
update: update,
view: view
};
function main(param, param$1) {
return Tea_app.beginnerProgram(partial_arg, param, param$1);
}
exports.update = update;
exports.view_button = view_button;
exports.view = view;
exports.main = main;
/* Tea_html Not a pure module */