bucklescript-tea
Version:
TEA for Bucklescript
135 lines (121 loc) • 3.54 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_html = require("../src-ocaml/tea_html.js");
var Tea_debug = require("../src-ocaml/tea_debug.js");
function string_of_msg(param) {
if (typeof param === "number") {
switch (param) {
case /* Increment */0 :
return "Increment";
case /* Decrement */1 :
return "Decrement";
case /* Reset */2 :
return "Reset";
}
} else {
return "Set";
}
}
function init(param) {
return /* tuple */[
4,
/* NoCmd */0
];
}
function subscriptions(param) {
return /* NoSub */0;
}
function update(model, param) {
if (typeof param === "number") {
switch (param) {
case /* Increment */0 :
return /* tuple */[
model + 1 | 0,
/* NoCmd */0
];
case /* Decrement */1 :
return /* tuple */[
model - 1 | 0,
/* NoCmd */0
];
case /* Reset */2 :
return /* tuple */[
0,
/* NoCmd */0
];
}
} else {
return /* tuple */[
param[0],
/* NoCmd */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
]
]
]
]
]
]
]
]
]);
}
function partial_arg_shutdown(_model) {
return /* NoCmd */0;
}
var partial_arg = {
init: init,
update: update,
view: view,
subscriptions: subscriptions,
shutdown: partial_arg_shutdown
};
function main(param, param$1) {
return Tea_debug.program(partial_arg, string_of_msg, param, param$1);
}
exports.string_of_msg = string_of_msg;
exports.init = init;
exports.subscriptions = subscriptions;
exports.update = update;
exports.view_button = view_button;
exports.view = view;
exports.main = main;
/* Tea_html Not a pure module */