Skip to content

Instantly share code, notes, and snippets.

@Scarygami
Last active September 5, 2017 22:20
Show Gist options
  • Save Scarygami/501a5d9f8c35c4a85380cbbf8203aca1 to your computer and use it in GitHub Desktop.
Save Scarygami/501a5d9f8c35c4a85380cbbf8203aca1 to your computer and use it in GitHub Desktop.
Samples and code snippets for my Polymer in Production article series
<!-- Polymer 1.x -->
<link rel="import" href="../polymer/polymer.html">
<dom-module id="my-name">
<template>
<style>
/* Amazing CSS to make my-name shine goes here */
</style>
<span>[[firstname]] [[lastname]]</span>
<template>
<script>
Polymer({
is: 'my-name',
properties: {
firstname: String,
lastname: String
}
});
</script>
</dom-module>
<!-- Polymer 2.x -->
<link rel="import" href="../polymer/polymer-element.html">
<dom-module id="my-name">
<template>
<style>
/* Amazing CSS to make my-name shine goes here */
</style>
<span>[[firstname]] [[lastname]]</span>
<template>
<script>
class MyName extends Polymer.Element {
static get is() { return 'my-name'; }
static get properties() {
return {
firstname: String,
lastname: String
};
}
}
window.customElements.define(MyName.is, MyName);
</script>
</dom-module>
/* Polymer 3.x - warning, early preview, things might change */
import { Element } from '../../@polymer/polymer/polymer-element.js';
class MyName extends Element {
static get template() {
return `
<style>
/* Amazing CSS to make my-name shine goes here */
</style>
<span>[[firstname]] [[lastname]]</span>
`;
}
static get is() { return 'my-name'; }
static get properties() {
return {
firstname: String,
lastname: String
};
}
}
window.customElements.define(MyName.is, MyName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment