-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize the app using the Polymer 2.0 Starter Kit
- Loading branch information
0 parents
commit 8d28ee0
Showing
27 changed files
with
871 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"extends": ["eslint:recommended", "google"], | ||
"parserOptions": { | ||
"ecmaVersion": 6 | ||
}, | ||
"env": { | ||
"browser": true | ||
}, | ||
"plugins": [ | ||
"html" | ||
], | ||
"rules": { | ||
"brace-style": "off", | ||
"new-cap": ["error", { "capIsNewExceptions": ["Polymer"] }], | ||
"no-var": "off", | ||
"require-jsdoc": "off" | ||
}, | ||
"globals": { | ||
"Polymer": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
bower_components/ | ||
build/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
# Polymer App Toolbox - Starter Kit | ||
|
||
[![Build Status](https://travis-ci.org/PolymerElements/polymer-starter-kit.svg?branch=master)](https://travis-ci.org/PolymerElements/polymer-starter-kit) | ||
|
||
This template is a starting point for building apps using a drawer-based | ||
layout. The layout is provided by `app-layout` elements. | ||
|
||
This template, along with the `polymer-cli` toolchain, also demonstrates use | ||
of the "PRPL pattern" This pattern allows fast first delivery and interaction with | ||
the content at the initial route requested by the user, along with fast subsequent | ||
navigation by pre-caching the remaining components required by the app and | ||
progressively loading them on-demand as the user navigates through the app. | ||
|
||
The PRPL pattern, in a nutshell: | ||
|
||
* **Push** components required for the initial route | ||
* **Render** initial route ASAP | ||
* **Pre-cache** components for remaining routes | ||
* **Lazy-load** and progressively upgrade next routes on-demand | ||
|
||
### Migrating from Polymer Starter Kit v1? | ||
|
||
[Check out our blog post that covers what's changed in PSK2 and how to migrate!](https://www.polymer-project.org/1.0/blog/2016-08-18-polymer-starter-kit-or-polymer-cli.html) | ||
|
||
### Quickstart | ||
|
||
We've recorded a Polycast to get you up and running with PSK2 fast! | ||
|
||
<p align="center"> | ||
<a href="https://www.youtube.com/watch?v=HgJ0XCyBwzY&list=PLNYkxOF6rcIDdS7HWIC_BYRunV6MHs5xo&index=10"> | ||
<img src="https://img.youtube.com/vi/HgJ0XCyBwzY/0.jpg" alt="Polymer Starter Kit 2 video"> | ||
</a> | ||
</p> | ||
|
||
### Setup | ||
|
||
##### Prerequisites | ||
|
||
First, install [Polymer CLI](https://github.com/Polymer/polymer-cli) using | ||
[npm](https://www.npmjs.com) (we assume you have pre-installed [node.js](https://nodejs.org)). | ||
|
||
npm install -g polymer-cli | ||
|
||
Second, install [Bower](https://bower.io/) using [npm](https://www.npmjs.com) | ||
|
||
npm install -g bower | ||
|
||
##### Initialize project from template | ||
|
||
mkdir my-app | ||
cd my-app | ||
polymer init polymer-2-starter-kit | ||
|
||
### Start the development server | ||
|
||
This command serves the app at `http://127.0.0.1:8081` and provides basic URL | ||
routing for the app: | ||
|
||
polymer serve | ||
|
||
### Build | ||
|
||
The `polymer build` command builds your Polymer application for production, using build configuration options provided by the command line or in your project's `polymer.json` file. | ||
|
||
You can configure your `polymer.json` file to create multiple builds. This is necessary if you will be serving different builds optimized for different browsers. You can define your own named builds, or use presets. See the documentation on [building your project for production](https://www.polymer-project.org/2.0/toolbox/build-for-production) for more information. | ||
|
||
The Polymer Starter Kit is configured to create three builds using [the three supported presets](https://www.polymer-project.org/2.0/toolbox/build-for-production#build-presets): | ||
|
||
``` | ||
"builds": [ | ||
{ | ||
"preset": "es5-bundled" | ||
}, | ||
{ | ||
"preset": "es6-bundled" | ||
}, | ||
{ | ||
"preset": "es6-unbundled" | ||
} | ||
] | ||
``` | ||
|
||
Builds will be output to a subdirectory under the `build/` directory as follows: | ||
|
||
``` | ||
build/ | ||
es5-bundled/ | ||
es6-bundled/ | ||
es6-unbundled/ | ||
``` | ||
|
||
* `es5-bundled` is a bundled, minified build with a service worker. ES6 code is compiled to ES5 for compatibility with older browsers. | ||
* `es6-bundled` is a bundled, minified build with a service worker. ES6 code is served as-is. This build is for browsers that can handle ES6 code - see [building your project for production](https://www.polymer-project.org/2.0/toolbox/build-for-production#compiling) for a list. | ||
* `es6-unbundled` is an unbundled, minified build with a service worker. ES6 code is served as-is. This build is for browsers that support HTTP/2 push. | ||
|
||
Run `polymer help build` for the full list of available options and optimizations. Also, see the documentation on the [polymer.json specification](https://www.polymer-project.org/2.0/docs/tools/polymer-json) and [building your Polymer application for production](https://www.polymer-project.org/2.0/toolbox/build-for-production). | ||
|
||
### Preview the build | ||
|
||
This command serves your app. Replace `build-folder-name` with the folder name of the build you want to serve. | ||
|
||
polymer serve build/build-folder-name/ | ||
|
||
### Run tests | ||
|
||
This command will run [Web Component Tester](https://github.com/Polymer/web-component-tester) | ||
against the browsers currently installed on your machine: | ||
|
||
polymer test | ||
|
||
If running Windows you will need to set the following environment variables: | ||
|
||
- LAUNCHPAD_BROWSERS | ||
- LAUNCHPAD_CHROME | ||
|
||
Read More here [daffl/launchpad](https://github.com/daffl/launchpad#environment-variables-impacting-local-browsers-detection) | ||
|
||
### Adding a new view | ||
|
||
You can extend the app by adding more views that will be demand-loaded | ||
e.g. based on the route, or to progressively render non-critical sections of the | ||
application. Each new demand-loaded fragment should be added to the list of | ||
`fragments` in the included `polymer.json` file. This will ensure those | ||
components and their dependencies are added to the list of pre-cached components | ||
and will be included in the build. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "polymer-starter-kit", | ||
"authors": [ | ||
"The Polymer Authors" | ||
], | ||
"license": "https://polymer.github.io/LICENSE.txt", | ||
"dependencies": { | ||
"app-layout": "PolymerElements/app-layout#^2.0.0", | ||
"app-route": "PolymerElements/app-route#^2.0.0", | ||
"iron-flex-layout": "PolymerElements/iron-flex-layout#^2.0.0", | ||
"iron-iconset-svg": "PolymerElements/iron-iconset-svg#^2.0.0", | ||
"iron-media-query": "PolymerElements/iron-media-query#^2.0.0", | ||
"iron-pages": "PolymerElements/iron-pages#^2.0.0", | ||
"iron-selector": "PolymerElements/iron-selector#^2.0.0", | ||
"paper-icon-button": "PolymerElements/paper-icon-button#^2.0.0", | ||
"polymer": "Polymer/polymer#^2.0.0", | ||
"webcomponentsjs": "webcomponents/webcomponentsjs#^1.0.0" | ||
}, | ||
"resolutions": { | ||
"polymer": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"web-component-tester": "Polymer/web-component-tester#^6.0.0" | ||
}, | ||
"private": true | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<!-- | ||
@license | ||
Copyright (c) 2016 The Polymer Project Authors. All rights reserved. | ||
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | ||
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | ||
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt | ||
Code distributed by Google as part of the polymer project is also | ||
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt | ||
--> | ||
|
||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="generator" content="Polymer Starter Kit"> | ||
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes"> | ||
|
||
<title>My App</title> | ||
<meta name="description" content="My App description"> | ||
|
||
<!-- | ||
The `<base>` tag below is present to support two advanced deployment options: | ||
1) Differential serving. 2) Serving from a non-root path. | ||
Instead of manually editing the `<base>` tag yourself, you should generally either: | ||
a) Add a `basePath` property to the build configuration in your `polymer.json`. | ||
b) Use the `--base-path` command-line option for `polymer build`. | ||
Note: If you intend to serve from a non-root path, see [polymer-root-path] below. | ||
--> | ||
<base href="/"> | ||
|
||
<link rel="icon" href="images/favicon.ico"> | ||
|
||
<!-- See https://goo.gl/OOhYW5 --> | ||
<link rel="manifest" href="manifest.json"> | ||
|
||
<!-- See https://goo.gl/qRE0vM --> | ||
<meta name="theme-color" content="#3f51b5"> | ||
|
||
<!-- Add to homescreen for Chrome on Android. Fallback for manifest.json --> | ||
<meta name="mobile-web-app-capable" content="yes"> | ||
<meta name="application-name" content="My App"> | ||
|
||
<!-- Add to homescreen for Safari on iOS --> | ||
<meta name="apple-mobile-web-app-capable" content="yes"> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent"> | ||
<meta name="apple-mobile-web-app-title" content="My App"> | ||
|
||
<!-- Homescreen icons --> | ||
<link rel="apple-touch-icon" href="images/manifest/icon-48x48.png"> | ||
<link rel="apple-touch-icon" sizes="72x72" href="images/manifest/icon-72x72.png"> | ||
<link rel="apple-touch-icon" sizes="96x96" href="images/manifest/icon-96x96.png"> | ||
<link rel="apple-touch-icon" sizes="144x144" href="images/manifest/icon-144x144.png"> | ||
<link rel="apple-touch-icon" sizes="192x192" href="images/manifest/icon-192x192.png"> | ||
|
||
<!-- Tile icon for Windows 8 (144x144 + tile color) --> | ||
<meta name="msapplication-TileImage" content="images/manifest/icon-144x144.png"> | ||
<meta name="msapplication-TileColor" content="#3f51b5"> | ||
<meta name="msapplication-tap-highlight" content="no"> | ||
|
||
<script> | ||
/** | ||
* [polymer-root-path] | ||
* | ||
* By default, we set `Polymer.rootPath` to the server root path (`/`). | ||
* Leave this line unchanged if you intend to serve your app from the root | ||
* path (e.g., with URLs like `my.domain/` and `my.domain/view1`). | ||
* | ||
* If you intend to serve your app from a non-root path (e.g., with URLs | ||
* like `my.domain/my-app/` and `my.domain/my-app/view1`), edit this line | ||
* to indicate the path from which you'll be serving, including leading | ||
* and trailing slashes (e.g., `/my-app/`). | ||
*/ | ||
window.Polymer = {rootPath: '/'}; | ||
|
||
// Load and register pre-caching Service Worker | ||
if ('serviceWorker' in navigator) { | ||
window.addEventListener('load', function() { | ||
navigator.serviceWorker.register('service-worker.js', { | ||
scope: Polymer.rootPath, | ||
}); | ||
}); | ||
} | ||
</script> | ||
|
||
<!-- Load webcomponents-loader.js to check and load any polyfills your browser needs --> | ||
<script src="bower_components/webcomponentsjs/webcomponents-loader.js"></script> | ||
|
||
<!-- Load your application shell --> | ||
<link rel="import" href="src/my-app.html"> | ||
|
||
<!-- Add any global styles for body, document, etc. --> | ||
<style> | ||
body { | ||
margin: 0; | ||
font-family: 'Roboto', 'Noto', sans-serif; | ||
line-height: 1.5; | ||
min-height: 100vh; | ||
background-color: #eeeeee; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<my-app></my-app> | ||
<noscript> | ||
Please enable JavaScript to view this website. | ||
</noscript> | ||
<!-- Built with love using Polymer Starter Kit --> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "My App", | ||
"short_name": "My App", | ||
"description": "My App description", | ||
"start_url": "./?homescreen=1", | ||
"display": "standalone", | ||
"theme_color": "#3f51b5", | ||
"background_color": "#3f51b5", | ||
"icons": [ | ||
{ | ||
"src": "images/manifest/icon-192x192.png", | ||
"sizes": "192x192", | ||
"type": "image/png" | ||
}, | ||
{ | ||
"src": "images/manifest/icon-512x512.png", | ||
"sizes": "512x512", | ||
"type": "image/png" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "polymer-starter-kit", | ||
"license": "BSD-3-Clause", | ||
"devDependencies": { | ||
"eslint": "^3.19.0", | ||
"eslint-config-google": "^0.7.0", | ||
"eslint-plugin-html": "^2.0.0" | ||
}, | ||
"scripts": { | ||
"lint": "npm run lint:javascript && polymer lint", | ||
"lint:javascript": "eslint . --ext js,html --ignore-path .gitignore", | ||
"test": "polymer test", | ||
"test:integration": "polymer build # test that psk builds without error with the CLI" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"entrypoint": "index.html", | ||
"shell": "src/my-app.html", | ||
"fragments": [ | ||
"src/my-view1.html", | ||
"src/my-view2.html", | ||
"src/my-view3.html", | ||
"src/my-view404.html" | ||
], | ||
"sources": [ | ||
"src/**/*", | ||
"images/**/*", | ||
"bower.json" | ||
], | ||
"extraDependencies": [ | ||
"manifest.json", | ||
"bower_components/webcomponentsjs/*.js" | ||
], | ||
"lint": { | ||
"rules": ["polymer-2"] | ||
}, | ||
"builds": [ | ||
{ | ||
"preset": "es5-bundled" | ||
}, | ||
{ | ||
"preset": "es6-bundled" | ||
}, | ||
{ | ||
"preset": "es6-unbundled" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* @license | ||
* Copyright (c) 2016 The Polymer Project Authors. All rights reserved. | ||
* This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt | ||
* The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | ||
* The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt | ||
* Code distributed by Google as part of the polymer project is also | ||
* subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt | ||
*/ | ||
|
||
/* eslint no-console: ["error", { allow: ["info"] }] */ | ||
|
||
console.info( | ||
'Service worker disabled for development, will be generated at build time.' | ||
); |
Oops, something went wrong.