I choose the display-rss component because it’s simple and has most of the use cases you would find in a web component.
What the component does basically loads any RSS feed and displays it
Starting up
We’ll be using Polymer as the library for the polyfills and creation of the element, and the help of Yeoman the tool I told you about in another post, and you will need to have NodeJS installed too.
We’ll begin by stalling Yeoman:
npm install -g yo
Then we’ll install the Polymer Generator
npm install -g generator-polymer
Then create a new folder mkdir my-element && cd $_
And start the generator yo polymer
This will create the base app structure, and will also install grunt and bower, go make a cup of tea.
Once all dependencies are downloaded we can create our element using:
yo polymer:element my-element
This command will ask us if we want to include a constructor, we mark the check, and we also mark that we want to import to our index.html using HTML imports.
Then it will ask if we want to import local elements, we leave blank.
Then it will ask if we want to import installed Bower elements, we are going to write polymer-json
since we’ll be using it later.
Finally this will create our element in app/elements/my-element.html
.
Since we said we wanted the polymer-jsonp
element we have to install it: bower install --save Polymer/polymer-jsonp
The --save
option ensure that this gets added to your bower.json file, if you are asked to choose a suitable version for polymer, I usually choose the one that specifies a version number.