Created
August 18, 2020 17:23
-
-
Save DylanPiercey/f4c4203d71011edbeaf01cc36ee6a32f to your computer and use it in GitHub Desktop.
Simple Marko counter component.
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
<div.count class=(state.count > 0 ? "positive" : "negative")> | |
${state.count} | |
</div> | |
<button on-click('increment', -1)> | |
-1 | |
</button> | |
<button on-click('increment', 1)> | |
+1 | |
</button> | |
class { | |
onCreate() { | |
this.state = { count: 0 }; | |
} | |
increment(delta) { | |
this.state.count += delta; | |
} | |
} | |
style { | |
.count.positive { | |
background: rgb(86, 239, 165); | |
} | |
.count.negative { | |
background: rgb(235, 182, 176); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment