Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@niklaskorz
Created June 7, 2014 20:17
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 niklaskorz/f34e32e398ca9b2bda6a to your computer and use it in GitHub Desktop.
Save niklaskorz/f34e32e398ca9b2bda6a to your computer and use it in GitHub Desktop.
Polymer 'proto-element',
name: 'Me'
age: 20
color: '#0000ff'
publish:
valueless:
value: false
reflect: true
nameChanged: ->
if @name
@name = @name[0].toUpperCase() + @name.slice 1
ready: ->
@$.el.textContent = @name + ' is ready!'
setFocus: ->
@$.nameInput.focus()
<link rel="import" href="bower_components/polymer/polymer.html">
<polymer-element name="proto-element" attributes="name color age">
<template>
<p>
This is <b>{{name}}</b>'s proto-element.
He likes the color <span style="color: {{color}}">{{color}}</span>
and is <b>{{age}}</b> years old.
Attribute valueless: {{valueless}}
</p>
<button on-click="{{setFocus}}">Set focus on name input</button>
<p>
<label for="ageInput">Age:</label>
<input type="range" id="ageInput" value="{{age}}">
<label for="nameInput">Name:</label>
<input id="nameInput" placeholder="Enter name..." value="{{name}}">
<label for="colorInput">Favorite color:</label>
<input type="color" id="colorInput" value="{{color}}">
</p>
<span id="el">Not ready...</span>
</template>
</polymer-element>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment