Code Monkey home page Code Monkey logo

polycasts's Introduction

Polymer

Build Status Published on npm Published on webcomponents.org

ℹ️ Note: This is the current stable version of the Polymer library. At Google I/O 2018 we announced a new Web Component base class, LitElement, as a successor to the PolymerElement base class in this library.

If you're starting a new project, we recommend that you consider using LitElement instead.

If you have a project you've built with an earlier version of the Polymer library, we recommend that you migrate to 3.0 for best compatibility with the JavaScript ecosystem. Thanks to the interoperability of Web Components, elements built with Polymer 3.0 and LitElement can be mixed and matched in the same app, so once you have updated your project to Polymer 3.0, you can migrate to LitElement incrementally, one element at a time. See our blog post on the Polymer Project roadmap for more information.

Polymer lets you build encapsulated, reusable Web Components that work just like standard HTML elements, to use in building web applications. Using a Web Component built with Polymer is as simple as importing its definition then using it like any other HTML element:

<!-- Import a component -->
<script src="https://unpkg.com/@polymer/paper-checkbox@next/paper-checkbox.js?module" type="module" ></script>

<!-- Use it like any other HTML element -->
<paper-checkbox>Web Components!</paper-checkbox>

Web Components are now implemented natively on Safari and Chrome (~70% of installed browsers), and run well on Firefox, Edge, and IE11 using polyfills. Read more below.

Getting started

  • The easiest way to try out Polymer is to use one of these online tools:

  • You can also save this HTML file to a local file and run it in any browser that supports JavaScript Modules.

  • When you're ready to use Polymer in a project, install it via npm. To run the project in the browser, a module-compatible toolchain is required. We recommend installing the Polymer CLI to and using its development server as follows.

    1. Add Polymer to your project:

      npm i @polymer/polymer

    2. Create an element by extending PolymerElement and calling customElements.define with your class (see the examples below).

    3. Install the Polymer CLI:

      npm i -g polymer-cli

    4. Run the development server and open a browser pointing to its URL:

      polymer serve --npm

    Polymer 3.0 is published on npm using JavaScript Modules. This means it can take advantage of the standard native JavaScript module loader available in all current major browsers.

    However, since Polymer uses npm conventions to reference dependencies by name, a light transform to rewrite specifiers to URLs is required to run in the browser. The polymer-cli's development server polymer serve, as well as polymer build (for building an optimized app for deployment) automatically handles this transform.

    Tools like webpack and Rollup can also be used to serve and/or bundle Polymer elements.

Minimal Example

  1. Create a class that extends PolymerElement.
  2. Implement a static properties getter that describes the element's public property/attribute API (these automatically become observed attributes).
  3. Then implement a template getter that returns an HTMLTemplateElement describing the element's rendering, including encapsulated styling and any property bindings.
  <script src="node_modules/@webcomponents/webcomponents-loader.js"></script>
  <script type="module">
    import {PolymerElement, html} from '@polymer/polymer';

    class MyElement extends PolymerElement {
      static get properties() { return { mood: String }}
      static get template() {
        return html`
          <style> .mood { color: green; } </style>
          Web Components are <span class="mood">[[mood]]</span>!
        `;
      }
    }

    customElements.define('my-element', MyElement);
  </script>

  <my-element mood="happy"></my-element>

Overview

Web components are an incredibly powerful new set of primitives baked into the web platform, and open up a whole new world of possibility when it comes to componentizing front-end code and easily creating powerful, immersive, app-like experiences on the web.

Polymer is a lightweight library built on top of the web standards-based Web Components APIs, and makes it easier to build your very own custom HTML elements. Creating reusable custom elements - and using elements built by others - can make building complex web applications easier and more efficient.

By being based on the Web Components APIs built in the browser (or polyfilled where needed), elements built with Polymer are:

  • Built from the platform up
  • Self-contained
  • Re-usable
  • Interoperable across frameworks

Among many ways to leverage custom elements, they can be particularly useful for building reusable UI components. Instead of continually re-building a specific navigation bar or button in different frameworks and for different projects, you can define this element once using Polymer, and then reuse it throughout your project or in any future project.

Polymer provides a declarative syntax to easily create your own custom elements, using all standard web technologies - define the structure of the element with HTML, style it with CSS, and add interactions to the element with JavaScript.

Polymer also provides optional two-way data-binding, meaning:

  1. When properties in the model for an element get updated, the element can update itself in response.
  2. When the element is updated internally, the changes can be propagated back to the model.

Polymer is designed to be flexible, lightweight, and close to the web platform - the library doesn't invent complex new abstractions and magic, but uses the best features of the web platform in straightforward ways to simply sugar the creation of custom elements.

About Polymer 3.0

Polymer 3.0 is now released to stable, and introduces a major change to how Polymer is distributed: from HTML Imports on Bower, to JS modules on npm. Otherwise, the API is almost entirely backward compatible with Polymer 2.0 (the only changes are removing APIs related to HTML Imports like importHref, and converting Polymer's API to be module-based rather than globals-based).

Migrating to Polymer 3.0 by hand is mostly mechanical:

  • Components should be defined in JS modules instead of in HTML
  • Templates should be encoded in JS modules using a static get template() getter on PolymerElement subclasses using the html tagged template literal function (which parses HTMLTemplateElements out of strings in JS) rather than using <template> elements in a <dom-module>
  • All dependencies should be imported JS module imports rather than HTML Imports.

However, the polymer-modulizer tool automates the vast majority of this migration work. Please see details on that repo for automated conversion of Polymer 2.0 apps and elements to Polymer 3.0.

👀 Looking for Polymer v2.x? Please see the v2 branch.

👀 Looking for Polymer v1.x? Please see the v1 branch.

Contributing

The Polymer team loves contributions from the community! Take a look at our contributing guide for more information on how to contribute. Please file issues on the Polymer issue tracker following the issue template and contributing guide issues.

Communicating with the Polymer team

Beyond GitHub, we try to have a variety of different lines of communication available:

License

The Polymer library uses a BSD-like license that is available here

polycasts's People

Contributors

arthurvr avatar e111077 avatar gugiserman avatar kasperpeulen avatar robdodson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

polycasts's Issues

ep14-reusable-elements

It looks like I'm hitting some infinite recursion when using polyserve...
I cloned this repository and did this..

polycsts/ep14-reusable-elements$>  polyserve
Starting Polyserve on port 8080
Serving components from bower_components
File in this directory are available at localhost:8080/components/tiny-badge/...

When I direct the brower to http://localhost:8080/components/tiny-badge/demo.html, The url redirects to http://localhost:8080/components/tiny-badge/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/bower_components/.

An error message is displayed in chrome "ERR_TOO_MANY_REDIRECTS"

Am I doing it wrong?

Wrong import href in `ep17-theming`

Hi Rob.

First of all thanks for your videos! Great work!
You've got a typo (wrong import path) in ep17-theming inside ui-message.html:

Instead of <link rel="import" href="../polymer/polymer.html"> it should be <link rel="import" href="bower_components/polymer/polymer.html">

[ep59-firebase-messaging] How to save tokens from multiple devices w/o overwriting?

<firebase-messaging
id="messaging"
token="{{token}}"
on-message="handleMessage">
</firebase-messaging>
<firebase-document
path="/users/[[user.uid]]/token"
data="[[token]]">
</firebase-document>

What if the user opens the web app and enable notifications on multiple devices? The token from one device will overwrite the token from another device. How to save tokens without overwriting to send push notifications to all devices?

ep46 with app-route: category not updating on page refresh

In this video:
https://www.youtube.com/watch?v=xRONodYEF2A&index=3&list=PLOU2XLYxmsII5c3Mgw6fNYCzaWrsM3sMN

at 7:08,
it seems that on page refresh, "the state has been reflected to the menu".

I'm following the same steps, using app-route, but on page refresh, my menu doesn't update (it works when I click on the links).

Here is my code (blog-app.html)

<link rel="import" href="bower_components/app-route/app-location.html">
<link rel="import" href="bower_components/app-route/app-route.html">
<link rel="import" href="bower_components/iron-selector/iron-selector.html">


<dom-module id="blog-app">
    <template>
        <style>
            :host {
                display: block;
            }

            a {
                color: black;
                text-decoration: none;
                margin-right: 8px;
                font-size: 18px;
            }

            .iron-selected {
                text-decoration: underline;
            }

            nav {
                height: 65px;
                margin: 0 auto;
                text-align: right;
            }

            main {
                width: 900px;
                margin: 0 auto;
                font-size: 21px;
                font-family: Georgia;
            }

            h2 {
                font-family: sans-serif;
            }
        </style>


        <app-location route="{{route}}"
                      use-hash-as-path></app-location>


        <app-route route={{route}}
                   pattern=":/category"
                   data="{{categoryData}}"
                   tail="{{categoryTail}}"></app-route>


        <iron-selector selected="{{categoryData.category}}"
                       attr-for-selected="data-page">

            <a data-page="art" href="#/art/list">Art</a>
            <a data-page="film" href="#/film/list">Film</a>
            <a data-page="photo" href="#/photo/list">Photo</a>

        </iron-selector>


        <div>route path: {{route.path}}</div>
        <div>category: {{categoryData.category}}</div>


        <main>
            <blog-pages category="{{categoryData.category}}"
                        route="{{categoryTail}}"
            ></blog-pages>
        </main>


    </template>

    <script>
        // https://www.youtube.com/watch?v=xRONodYEF2A&index=3&list=PLOU2XLYxmsII5c3Mgw6fNYCzaWrsM3sMN  @7:08
        Polymer({
            is: 'blog-app',
            ready: function () {
                // dirty fix
//              var curCat = this.route.path.substring(1, this.route.path.lastIndexOf('/'));
//              this.set('categoryData.category', curCat);
            }
        });


    </script>

</dom-module>

Am I doing something wrong?

Example 46 not working

Hi, i cloned your repo and tested the example under windows 8. Actually it doesn't work even after the update to the new Polymer version. I can see the list of articles, but on click the request for the post isn't fired

polymer-starter-kit: npm install build error

running npm install I get a build error part of the way through:

C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.Cpp.Platform.targets(42,5): error MSB8020: The builds tools for Visual Studio 2010 (
Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, either click the Project menu or right-click the solution, and then
select "Update VC++ Projects...". Install Visual Studio 2010 to build using the Visual Studio 2010 build tools. [D:\dev\polymer-starter-kit\node_modu
les\browser-sync\node_modules\socket.io\node_modules\engine.io\node_modules\ws\build\bufferutil.vcxproj]

I don't have VS2010, but I do have 2012. Should this be changed to use whatever msbuild is in the env:path?

No more polycasts?

Hi Rob,

Did you stop making Polycasts? I would love to see more of you :D

Thank you!

Merc.

Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app)."

I just watched and followed your polycasts #57 and #58. The integration of firebase-auth went all right but then it broke when I added the element and firebase-query. I could not find the cause so I came here and copied your code but I still get the error.

Uncaught Vcode: "app/duplicate-app"message: "Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app)."name: "[DEFAULT]"stack: "FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app).↵ at Z (http://localhost:5000/bower_components/firebase/firebase-app.js:27:364)↵ at Object.initializeApp (http://localhost:5000/bower_components/firebase/firebase-app.js:26:29)↵ at HTMLElement.__computeApp (http://localhost:5000/bower_components/polymerfire/firebase-app.html:117:36)↵ at HTMLElement._computeEffect (http://localhost:5000/bower_components/polymer/polymer.html:1684:24)↵ at HTMLElement._effectEffects (http://localhost:5000/bower_components/polymer/polymer.html:1507:7)↵ at HTMLElement._propertySetter (http://localhost:5000/bower_components/polymer/polymer.html:1491:6)↵ at HTMLElement.__setProperty (http://localhost:5000/bower_components/polymer/polymer.html:1500:6)↵ at HTMLElement._applyConfig (http://localhost:5000/bower_components/polymer/polymer.html:2110:6)↵ at HTMLElement._afterClientsReady (http://localhost:5000/bower_components/polymer/polymer.html:2104:6)↵ at HTMLElement._ready (http://localhost:5000/bower_components/polymer/polymer-mini.html:70:6)"__proto__: Error

Do you have an idea of how I could fix this?

Uncaught (in promise) DOMException: Registration failed - push service error

Hi,

In chrome firebase messaging throws error on getToken() method in requestPermission() call.
I have tried it in multiple projects and PSK. All fail to get token.

Source code to reproduce
https://github.com/vinvantest/git_issue_firebase_login

Stacktrace
Uncaught (in promise) DOMException: Registration failed - push service error
Promise.then (async)
refreshToken @ firebase-messaging.html:87
activateMessaging @ firebase-messaging.html:125
activate @ firebase-messaging.html:243
_bootstrapApp @ firebase-messaging.html:259
runMethodEffect @ property-effects.html:813
runEffectsForProperty @ property-effects.html:159
runEffects @ property-effects.html:125
_propertiesChanged @ property-effects.html:1703
_flushProperties @ properties-changed.html:338
_flushProperties @ property-effects.html:1551
_invalidateProperties @ property-effects.html:1523
_setProperty @ property-effects.html:1508
Object.defineProperty.set @ properties-changed.html:150
__appNameChanged @ firebase-common-behavior.html:47
runObserverEffect @ property-effects.html:214
runEffectsForProperty @ property-effects.html:159
runEffects @ property-effects.html:125
_propertiesChanged @ property-effects.html:1703
_flushProperties @ properties-changed.html:338
_flushProperties @ property-effects.html:1551
ready @ property-effects.html:1656
ready @ element-mixin.html:546
ready @ dir-mixin.html:140
ready @ legacy-element-mixin.html:198
ready @ class.html:232
ready @ class.html:232
ready @ class.html:232
_enableProperties @ properties-changed.html:321
connectedCallback @ properties-mixin.html:208
connectedCallback @ element-mixin.html:532
connectedCallback @ dir-mixin.html:150
connectedCallback @ legacy-element-mixin.html:105
_attachDom @ element-mixin.html:588
_readyClients @ element-mixin.html:561
_flushClients @ property-effects.html:1565
_propertiesChanged @ property-effects.html:1699
_flushProperties @ properties-changed.html:338
_flushProperties @ property-effects.html:1551
ready @ property-effects.html:1656
ready @ element-mixin.html:546
ready @ my-app.html:540
_enableProperties @ properties-changed.html:321
connectedCallback @ properties-mixin.html:208
connectedCallback @ element-mixin.html:532
(anonymous) @ my-app.html:849

I have attached screenshots of the behaviour. Sequence of events is stored as filename in chronological order just to simplify things. I have also attached 3 files from the PWA namely .. index.html, my-app.html (main element), login.html and firebase-sw.js. Hope it will provide all the context to the issue.

Firebase Product: messaging
bower polymerfire#^2.2.1 cached https://github.com/firebase/polymerfire.git#2.2.1
bower polymerfire#^2.2.1 validate 2.2.1 against https://github.com/firebase/polymerfire.git#^2.2.1
bower firebase#* cached https://github.com/firebase/firebase-bower.git#4.6.1
bower firebase#* validate 4.6.1 against https://github.com/firebase/firebase-bower.git#*
bower firebase#* new version for https://github.com/firebase/firebase-bower.git#*
bower firebase#* resolve https://github.com/firebase/firebase-bower.git#*
bower firebase#* download https://github.com/firebase/firebase-bower/archive/v4.13.0.tar.gz
bower firebase#* extract archive.tar.gz
bower firebase#* resolved https://github.com/firebase/firebase-bower.git#4.13.0
bower firebase#^4.13.0 install firebase#4.13.0
bower polymerfire#^2.2.1 install polymerfire#2.2.1

Environment
Operating System version: Mac High Sierra 10.13.4
Firebase SDK - [email protected]
Firebase Tools version: 3.18.4

Chrome versions:
Google Chrome is up to date
Version 66.0.3359.139 (Official Build) (64-bit)] as well as in Chrome Android - [Application version Chrome 66.0.3359.126

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.