Skip to content

Instantly share code, notes, and snippets.

@marionebl
Created January 18, 2021 11:33
Show Gist options
  • Save marionebl/c3fcf3af0711511a75a2819a400bd37e to your computer and use it in GitHub Desktop.
Save marionebl/c3fcf3af0711511a75a2819a400bd37e to your computer and use it in GitHub Desktop.
Editor
Editor
Cursor
focus -> Cursor and Caret
Cursor and Caret
blur -> Cursor
type -> Caret
Caret
blur -> Cursor
mousemove -> Cursor and Caret
function render(model) {
mod = model;
const state = model.active_states[0].name;
const onMouseMove = () => model.emit("mousemove");
const onFocus = () => model.emit("focus");
const onBlur = () => model.emit("blur");
const onInput = () => model.emit("type");
return $("div", { onMouseMove, style: { padding: 12 }}, [
$("div", { style: { display: 'flex', alignItems: 'middle', marginBottom: 20 }}, [
cursor(state),
$("h1", { style: { margin: 0 } }, state),
]),
$("textarea", { onFocus, onBlur, onInput }),
]);
}
function cursor(state) {
switch (state) {
case 'Cursor':
return [$("img", { style: { display: "inline-block", height: 30 }, src: "https://pronto-core-cdn.prontomarketing.com/2/wp-content/uploads/sites/1256/2015/09/cursor1.png" })]
case 'Caret':
return [$("img", { style: { display: "inline-block", height: 25 }, src: "https://pronto-core-cdn.prontomarketing.com/2/wp-content/uploads/sites/1256/2015/09/cursor2.png" })];
case 'Cursor and Caret':
return [
$("img", { style: { display: "inline-block", height: 30 }, src: "https://pronto-core-cdn.prontomarketing.com/2/wp-content/uploads/sites/1256/2015/09/cursor1.png" }),
$("img", { style: { display: "inline-block", height: 25 }, src: "https://pronto-core-cdn.prontomarketing.com/2/wp-content/uploads/sites/1256/2015/09/cursor2.png" })
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment