Created
October 27, 2018 19:17
-
-
Save madiodio/3560cfee91e3d6ba433085956e24847e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8" /> | |
<title>Add Omi in One Minute</title> | |
</head> | |
<body> | |
<div><like-button /></div> | |
<script src="https://unpkg.com/omi"></script> | |
<script> | |
const { WeElement, h, render, define } = Omi | |
class LikeButton extends WeElement { | |
install() { | |
this.data = { liked: false } | |
} | |
render() { | |
if (this.data.liked) { | |
return 'You liked this.' | |
} | |
return h( | |
'button', | |
{ | |
onClick: () => { | |
this.data.liked = true | |
this.update() | |
} | |
}, | |
'Like' | |
) | |
} | |
} | |
define('like-button', LikeButton) | |
render(h('like-button'), 'body') | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment