Created
May 4, 2018 19:10
-
-
Save kevinpschaaf/8a5acbea7b25d2bb5e82eeea2b105669 to your computer and use it in GitHub Desktop.
Polymer 3.0 example
This file contains hidden or 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
<html> | |
<head> | |
<!-- Polyfills only needed for Firefox and Edge. --> | |
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@next/webcomponents-loader.js"></script> | |
</head> | |
<body> | |
<!-- Loads natively on browsers that support Javascript modules like | |
Chrome, Safari, Firefox 60, Edge 16. For all others, use a | |
module-compatible toolchain like Polymer CLI, WebPack, or Rollup --> | |
<script type="module"> | |
import {PolymerElement, html} from 'https://unpkg.com/@polymer/polymer@next/polymer-element.js?module'; | |
class MyElement extends PolymerElement { | |
static get properties() { return { mood: String }} | |
static get template() { | |
return html` | |
<style> .mood { color: green; } </style> | |
Web Components are <span class="mood">[[mood]]</span>! | |
`; | |
} | |
} | |
customElements.define('my-element', MyElement); | |
</script> | |
<my-element mood="awesome"></my-element> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment