Skip to content

Instantly share code, notes, and snippets.

@thawkin3
Created July 9, 2020 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thawkin3/3e6a30e2c0d960344a0fa319435a5761 to your computer and use it in GitHub Desktop.
Save thawkin3/3e6a30e2c0d960344a0fa319435a5761 to your computer and use it in GitHub Desktop.
Stencil Web Component Example
* {
font-size: 200%;
}
span {
width: 4rem;
display: inline-block;
text-align: center;
}
button {
width: 64px;
height: 64px;
border: none;
border-radius: 10px;
background-color: seagreen;
color: white;
}
/* @jsx h */
import { h, Component, State, Host } from "@stencil/core";
@Component({
tag: "my-counter",
styleUrl: "index.css",
shadow: true
})
export class MyCounter {
@State() count: number = 0;
inc() {
this.count++;
}
dec() {
this.count--;
}
render() {
return (
<Host>
<button onClick={this.dec.bind(this)}>-</button>
<span>{this.count}</span>
<button onClick={this.inc.bind(this)}>+</button>
</Host>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment