Giter Site home page Giter Site logo

news'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

news's People

Contributors

abdonrd avatar dstoc avatar felixzapata avatar frankiefu avatar keanulee avatar notwaldorf avatar samuelli avatar shans avatar would-code-again 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

news's Issues

About page

I would like to see an example of how to implement a link to a static page in the menu, like an "about" page.

a11y issues

  • put the text "Opinions ยท September 7, 2016" inside anh1
  • "Most Read", "More Top Stories" and "Opinions" should be inside an h2 instead of h3
  • use h3 for the news articles on the list page

cc @robdodson feel free to add more issues if you find anything that could have be done a little better.

Header jitters when you scroll quickly

If you go to the main article list, scroll way down, and then quickly scroll up, the header drops down and there is a small gap that jitters opened and closed above the header. You see about 1 px of white line about the header. Worse the faster you scroll up.

Feature idea: RSS feed ingestion

Would it be possible to distribute this in such a way so that someone could set an RSS feed for each topic category in their app, and the server and/or client could fetch all the documents in the RSS feed and use them/cache them for the content?

This would allow essentially one-edit setup for anyone with a RSS feeds.

This could also extend to the AMP version, where if you had RSS feeds of AMP docs you could get a PWA essentially for free.

Image resizes when you scroll down

On the article pages on iOS and Chrome Android, as well as the home page on iOS, the hero image appears to resize when the URL bar scrolls out of view. This causes the text to jump down, which can be jarring.

Would it be possible to make sure the hero image doesn't resize when the URL bar scrolls away or scrolls back into view?

Content should be network-first

I feel like, particularly for a news app, we should try to go to the network first for the content. E.g. you go pack to the site, and it tries to fetch the latest content rather than show you old articles.

Consider using fallback-selection for default route

Currently if the route path is empty we set route.path to some default value.

_routePageChanged: function(page) {
  if (!page) {
    // set default route if route path is empty
    this.set('route.path', 'list/mobile-homepage');
    return;
  }

This could be undesirable as it will change the URL.
There is a property fallback-selection in iron-pages that we could use to set the default page. We should see if that makes sense to use in the News app. e.g.

<iron-pages role="main" selected="{{page}}" attr-for-selected="name" fallback-selection='list'>

Share server push strategies

It would be really interesting to know how you guys have setup your server (nginx I assume) to play nicely with Server Push

Here is the list of what I'd like to know:

  • Did you automate the deploy to automatically detect what resources are pushed?
  • Do different routes push same resources?
  • Why nginx this time? (polymer-shop is served through apache-server)

Share with us please ๐Ÿ˜ƒ

Remove the search icon

Since it doesn't do anything, I think we should remove it from the top right so that people don't tap on it and think it's broken.

News-path-warning does not work

If I change the article namer or the category name in the web browser URL field, the news-app should show news-path-warning.html, ie 404 page, but does not.

It seem to show a list view with no items.

App shows blank screen on IE 11

headline styling issue on mobile

  • The headline will get chopped off.

screen shot 2016-08-12 at 11 48 09 am

  • In instances when the headline is so long that it overlaps with the header. We should make sure the Politics box is always at least 100px below the header.

screen shot 2016-08-12 at 7 52 18 am

Link to old version of polymer

It is:

 <footer>
      <a href="https://www.polymer-project.org/1.0/toolbox/">Made by Polymer</a>
    </footer>

It should be:

 <footer>
      <a href="https://www.polymer-project.org/2.0/toolbox/">Made by Polymer</a>
    </footer>

a11y: Using keyboard with Firefox

With Firefox is not possible to use the keyboard to navigate through the elements. The focus jumps to all the document but not inside the elements.

Styling cleanup

  • Remove tap highlight: -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  • Add an extra space on either side of the dot so there's more separation from the date.
    screen shot 2016-08-15 at 10 22 45 am
  • Change all the black type to #383838 and background color to #fafafa

Article content

  • Remove margin in <figure> and make the text be Georgia italic and 54% Black.
  • Make <a> links bold underline (not the default blue).

Desktop

  • Change the logo letter-spacing: 10px and add margin-left: 11px

  • The kicker should be top aligned with the "Most Read" lines
    screen shot 2016-08-15 at 2 25 06 pm

  • "Most Read" lines should be 12% Black like the nav lines

  • Make time-ago white-space: nowrap so this doesn't happen
    screen shot 2016-08-15 at 2 29 44 pm

  • In "Scroll down nav bar", change logo font-size to: 23px; and background color from black to #212121
    screen shot 2016-08-15 at 2 40 25 pm

  • Change nav links in "Scroll down nav bar" to line-height: 32px; font-size: 15px;

  • The bottom nav links should be 40px spacing

    screen shot 2016-08-15 at 2 47 20 pm

Polymer CLI and News App Build Issue

Howdy Folks,

Thanks for the great demo app.

I am just trying to get it up and running and ran into a problem right away.

First of all you should know that I installed polymer-cli with

npm install -g polymer-cli

When I ran

polymer build

I got a warning for each html file in the articles folder

The error is very similar to the one reported here: polymer-cli/issues/546.

On that issue the recommended fix is to

install polymer-cli@next

If you do this, note that you should uninstall the existing polymer-cli

After installing polymer-cli@next the build process runs with two new deprecation warnings and then fails with a notice about the app entry point.

warn: [polymer-project-config]    "sourceGlobs" config option has been renamed to "sources" and will no longer be supported
 in future versions
warn: [polymer-project-config]    "includeDependencies" config option has been renamed to "extraDependencies" and will no l
onger be supported in future versions
error:   cli runtime exception: AssertionError: Polymer Config Error: entrypoint (/) does not resolve within root (/Users/s
merth/Sites/Javascript/Polymer/Polymer v2/news-app/news)
error:   AssertionError: Polymer Config Error: entrypoint (/) does not resolve within root (/Users/smerth/Sites/Javascript/
Polymer/Polymer v2/news-app/news)

You need to fix the polymer.json config file as follows:

{
  "entrypoint": "index.html",
  "shell": "src/news-app.html",
  "fragments": [
    "src/news-list.html",
    "src/news-article.html",
    "src/news-path-warning.html",
    "src/lazy-resources.html"
  ],
  "sources": [
   "src/**/*",
   "images/**/*",
   "data/**/*",
   "app.yaml",
   "bower.json",
   "index.html",
   "main.py"
  ],
  "extraDependencies": [
    "manifest.json",
    "bower_components/webcomponentsjs/webcomponents-lite.min.js"
  ]
}

It seems that polymer-cli@next doesn't accept "entrypoint": "/", but does accept "entrypoint": "index.html",

Now the build works.

I would be nice if the News demo app built using a stable release of polymer-cli. I think polymer-cli@next is the bleeding edge release???

Maybe the polymer.json file should be updated???

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.