Created
July 9, 2020 21:23
-
-
Save thawkin3/3e6a30e2c0d960344a0fa319435a5761 to your computer and use it in GitHub Desktop.
Stencil Web Component Example
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
* { | |
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; | |
} |
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
/* @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