Skip to content

Instantly share code, notes, and snippets.

@Nejat
Created December 25, 2015 15:07
Show Gist options
  • Save Nejat/c37e4f508556224fa161 to your computer and use it in GitHub Desktop.
Save Nejat/c37e4f508556224fa161 to your computer and use it in GitHub Desktop.
Polymer ES6 Element Webstorm File Template
<link rel="import" href="../../bower_components/polymer/polymer.html">
<link rel="import" href="../../bower_components/paper-material/paper-material.html">
<link rel="import" href="../../bower_components/paper-behaviors/paper-button-behavior.html">
<dom-module id="${NAME}">
<template strip-whitespace>
<style include="paper-material">
:root {
}
:host {
display: inline-block;
box-sizing: border-box;
@apply(--${NAME}-content)
}
</style>
<content select=""></content>
</template>
<!--suppress JSMethodCanBeStatic -->
<script type='text/ecmascript-6'>
(function () {
class ${Element}#[[$END$]]# {
get is() {
return '${NAME}';
}
//noinspection JSUnusedGlobalSymbols
get behaviors() {
return this._behaviors || (this._behaviors = [Polymer.PaperButtonBehavior]);
}
//noinspection JSUnusedGlobalSymbols
set behaviors(value) {
this._behaviors = value;
}
//noinspection JSUnusedGlobalSymbols
get properties() {
return {
name: {
computed: '_getName()',
notify: false,
observer: '_nameChanged',
readOnly: false,
reflectToAttribute: false,
type: String, //Boolean, Date, Number, String, Array or Object
value: ''
}
}
}
//noinspection JSUnusedGlobalSymbols
attached() {
console.log('${NAME} attached');
}
//noinspection JSUnusedGlobalSymbols
created() {
console.log('${NAME} created');
}
//noinspection JSUnusedGlobalSymbols
detached() {
console.log('${NAME} detached');
}
//noinspection JSUnusedGlobalSymbols
ready() {
console.log('${NAME} ready');
}
//noinspection JSUnusedGlobalSymbols
_getName (...args) {
console.log(`${NAME} get name [${args.length}] \${args}`);
}
_nameChanged (...args) {
console.log(`${NAME} name changed [${args.length}] \${args}`);
}
}
Polymer(${Element});
}).call();
</script>
</dom-module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment