Search code examples
polymerweb-componentpolymer-1.0plunker

How do I import Polymer elements into code playgrounds like plunker (plnkr.co), jsBin and jsFiddle?


Question:

In this Plunk, I want to import the Polymer 1.0 elements <paper-button> and <paper-menu>.

How do I do that?

In other words, what is the proper set of <script> and <link> tags and their respective src and href attributes that will allow my <paper-button> and <paper-menu> elements to properly function?

Attempts:

In the right margin, there is an option to search and import external libraries. I used that to search for Polymer 1.0 and I imported the following.

<script data-require="[email protected]" data-semver="1.0.0" src="http://www.polymer-project.org/1.0/samples/components/webcomponentsjs/webcomponents-lite.js"></script>
<script data-require="[email protected]" data-semver="1.0.0" src="http://www.polymer-project.org/1.0/samples/components/polymer/polymer.html"></script>

Note: Here is a JS Bin that imports Polymer elements.


Solution

  • Example here

    <!DOCTYPE html>
    <html>  
    <head>
      <meta charset="utf-8">
      <title>Polymer Bin</title>
      <base href="http://element-party.xyz/">
      <script src="bower_components/webcomponentsjs/webcomponents-lite.js"></script>
      <link rel="import" href="all-elements.html">
    </head>
    <body class="fullbleed layout vertical">
    <x-element></x-element>
    <dom-module id="x-element">
      <template>
        <style>...</style>
        <!-- Element markup goes here -->  
      </template>
      <script>
        (function(){
          Polymer({
            is: 'x-element'
          });
        })();
      </script>
    </dom-module>
    </body>
    </html>