Skip to content

Instantly share code, notes, and snippets.

@DylanPiercey
Created August 18, 2020 17:23
Show Gist options
  • Save DylanPiercey/f4c4203d71011edbeaf01cc36ee6a32f to your computer and use it in GitHub Desktop.
Save DylanPiercey/f4c4203d71011edbeaf01cc36ee6a32f to your computer and use it in GitHub Desktop.
Simple Marko counter component.
<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