Giter Site home page Giter Site logo

polymer-patterns's Introduction

Polymer Snippets

Small, useful snippets/samples that show how to do things the Polymer way.

Setup

bower install

Run the tests

  1. Fire up a web server in the root of this repo. For example:

    python -m SimpleHTTPServer

  2. Hit http://localhost:8000/tests/.

Contributing

See the contribution guide.

Table of Contents

Basics

Control Flow

Inheritance

Forms

Observing Changes

Events

Insertion Points

Filters

Styling Elements

Layout attributes

Core Elements

Snippets using Polymer core elements.

Core Toolbar

polymer-patterns's People

Contributors

addyosmani avatar ebidel avatar kwalrath avatar robdodson avatar shailen avatar vivekimsit avatar wibblymat 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

polymer-patterns's Issues

Noticed some odd failures in test runner

When I open the test runner I see 42 pass and 3 failures reported in the top right. However, the page itself shows all green and clicking on 'failures' filters the list down to nothing. Not sure what's up :\

0.8, 0.9 or 1.0 too ?

This repo is great, curious if there is something similar for newer versions, or will be?

7 links in the TOC are bad

How to properly use JS with Polymer?

I'm trying to integrate bricks.js (https://jsfiddle.net/939ppbj4/13/) into a polymer project, but I can't quite figure out how to do it..

I've tried to go through the snippets in this repo but it seems javascript is always written as:

Polymer({
      is: 'test',
      properties: {
        blablabla
      },
});

which I find a little confusing..

I believe the closest thing I've gotten to being correct is as its written below, but it results in a bricks.min.js error saying

Uncaught TypeError: Cannot read property 'style' of null

(I don't get this error if I run same code outside polymer (like in the jsfiddle)

<dom-module id="test">
  <template>
    <section class="grid" >
      <div data-packed>
        <img src="http://lorempixel.com/150/340/">
      </div>
      <div data-packed>
        <img src="http://lorempixel.com/150/240/">
      </div>
      <div data-packed>
        <img src="http://lorempixel.com/150/540/">
      </div>
      <div data-packed>
        <img src="http://lorempixel.com/150/140/">
      </div>
      <div data-packed>
        <img src="http://lorempixel.com/150/320/">
      </div>
      <div data-packed>
        <img src="http://lorempixel.com/150/108/">
      </div>
      <div data-packed>
        <img src="http://lorempixel.com/150/340/">
      </div>
    </section>
  </template>

  <script src="../../scripts/bricks.min.js"></script>

  <script type="text/javascript">
    var sizes = [
      { columns: 2, gutter: 10 },
      { mq: '48em', columns: 3, gutter: 10 },
      { mq: '64em', columns: 4, gutter: 10 }
    ];

    var brickInstance = Bricks({
      container: '.grid',
      packed: 'data-packed',
      sizes: sizes,
    });

    window.onresize = function() {
      brickInstance.pack()
    };
  </script>
</dom-module>

Any help/suggestions would be much appreciated :3

Polymer "inheritance" proposal - expose more mixins!!

I fully understand why you wen't away from full components inheritance. A crude weapon indeed.
However it would be VERY convenient if all elements exposed their style, properties and behaviour as mixins for other elements to build on.

This IS currently possible, so it is only a matter of enhancing existing elements to follow this pattern to allow for better composition.

This would also help to solve the "problem" with the content selector limitation: googlearchive/core-selector#39

Example paper-scroll-header-panel

var mixinElement = Polymer.registry('paper-scroll-header-panel')

Polymer.extend({
  properties: [
    mixinElement.properties, 
    AnotherSetOfproperties, 
  ],
  behaviors: [
    myOtherMixinElement.behaviors,
    someNiceBehavior,
    mixinElement.behaviors
  ]
}, {
  // my specific element overrides and customizations
});

You could of course see a behavior as a full set of properties and methods which form a logical unit. Then expose methods and properties as separate mixin units as well. Then allow full inheritance as a convenience, which simply inherits all behaviors and the shared styles exposed by the elements as well.
Provide full flexibility and granular control.

Cheers!

Write a core-ajax sample

Write a sample that defines a Polymer element that reads JSON data from some API at load time using the core-ajax element.

e.target.templateInstance.model

I just found the documentation on finding the model that goes w/ the target of an event handler. I haven't seen this in any of the examples and think it is worth demonstrating.

Often, you’ll want to identify the event with the model data used to generate the template instance, either to update the model data or to access a piece of data that isn’t rendered by the template.

You can get the model data from the event’s target.templateInstance.model property. Any identifiers that you could access inside the template are available as properties on the .model object.

Content element selectors - loosen up please!

As I understand it and from own experience, a content element can only select direct children. This makes sense in most simple scenarios, but as soon as you have a custom element in the mix it falls apart. The custom element acts as a wrapper around the "real" child elements, now in the shadow dom, but then the children are not there for selection and you can't really compose this way with custom elements which should be the whole point?
Am I missing something here!? I can't believe this design constraint.

https://github.com/Polymer/core-selector/blob/master/core-selector.html#L292

IMO, the nodes should be mapped, so that if a node is a custom element, it should add its children to the list of nodes as well (only at the top level, not recursively!). I understand why you have the current limitation, but sometimes (often), the custom elements acts as a wrapper, a structural element container without any (intended) UI influence, just a way to decompose a logical entity.

PS: How do you test if a given node is a custom element? Simply by naming convention? or is there a better way? Thanks.

Need a second core-selector example

https://github.com/PolymerLabs/polymer-snippets/blob/master/snippets/forms/selecting-items-using-the-core-selector-element.html should be split into two samples.

  • Rename the current sample "Selecting many items using the core selector element".
  • Create a second sample "Selecting one item the core selector element" that let's the user select only a single item from a collection. In this sample, do not use valueattr as an argument. Instead, work with the indices of the selected element.

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.