Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web Creation With Polymer

takanorip
February 06, 2018

Web Creation With Polymer

takanorip

February 06, 2018
Tweet

More Decks by takanorip

Other Decks in Technology

Transcript

  1. 自己紹介 • 大木尊紀(オオキタカノリ) / @takanorip • 株式会社スマートドライブ • フロントエンドエンジニア •

    React、Vue.js、Polymer、ウェブ制作全般 • Polymer Japan 翻訳チーム • 「イヌでもわかるWeb Components」
 Boothにて販売中!
  2. $npm install -g polymer-cli $polymer init ? Which starter template

    would you like to use? polymer-2-element - A simple Polymer 2.0 element template polymer-2-application - A simple Polymer 2.0 application › polymer-2-starter-kit - A Polymer 2.x starter application template, with navigation and "PRPL patter n" loading shop - The "Shop" Progressive Web App demo $polymer serve info: Files in this directory are available under the following URLs applications: http://127.0.0.1:8081 reusable components: http://127.0.0.1:8081/components/polymer- starter-kit/
  3. ├── README.md ├── bower.json ├── bower_components ├── images ├── index.html

    ├── manifest.json ├── package.json ├── polymer.json ├── service-worker.js ├── src │ ├── my-app.html │ ├── my-icons.html │ ├── my-view1.html │ ├── my-view2.html │ ├── my-view3.html │ ├── my-view404.html │ └── shared-styles.html ├── sw-precache-config.js └── test
  4. <link rel="import" href=“../bower_components/polymer/polymer-element.html"> <link rel="import" href=“./component/sample-button.html"> <dom-module id="sample-view1"> <template> <style>

    :host { display: block; } </style> <div class="sample"> <h1 class=“sample-titke”>Hello Polymer</h1> <sample-button></sample-button> </div> </template> <script> class SampleView1 extends Polymer.Element { static get is() { return 'sample-view1'; } } window.customElements.define(SampleView1.is, SampleView1); </script> </dom-module>
  5. <dom-module id="sample-view1"> <template> <style> :host { display: block; } </style>

    <div class="sample"> <h1 class=“sample-titke”>Hello Polymer</h1> <sample-button></sample-button> </div> </template> </dom-module>
  6. <dom-module id="sample-view1"> <script> class SampleView1 extends Polymer.Element { static get

    is() { return 'sample-view1'; } } window.customElements.define(SampleView1.is, SampleView1); </script> </dom-module>
  7. <link rel="import" href=“../bower_components/polymer/polymer-element.html"> <dom-module id="sample-view1"> <template> <style> :host { display:

    block; } </style> <div class="sample"> <h1 class=“sample-titke”>Hello Polymer</h1> </div> </template> <script> class SampleView1 extends Polymer.Element { static get is() { return 'sample-view1'; } } window.customElements.define(SampleView1.is, SampleView1); </script> </dom-module>
  8. <link rel="import" href=“../bower_components/polymer/polymer-element.html"> <link rel="import" href=“./component/sample-button.html"> <dom-module id="sample-view1"> <template> <style>

    :host { display: block; } </style> <div class="sample"> <h1 class=“sample-titke”>Hello Polymer</h1> <sample-button></sample-button> </div> </template> <script> class SampleView1 extends Polymer.Element { static get is() { return 'sample-view1'; } } window.customElements.define(SampleView1.is, SampleView1); </script> </dom-module>
  9. <script> class SampleButton extends Polymer.Element { static get is() {

    return "sample-button"; } static get properties() { return { buttonText: { type: String } } } constructor() { super(); } } customElements.define(SampleButton.is, SampleButton); </script>
  10. class SampleButton extends Polymer.Element { static get is() { return

    'sample-button'; } static get properties() { return { num: { type: Number, notify: true, reflectToAttribute: true, value: 1 }, } } count() { this.num++; } } window.customElements.define(SampleButton.is, SampleButton);
  11. body { --sample-color1: #1E88E5; --sample-color2: #333333; } :host { display:

    block; background-color: var(--sample-color1, currentcolor); }
  12. <app-location route="{{route}}" url-space-regex="^[[rootPath]]"> </app-location> <app-route route="{{route}}" pattern="[[rootPath]]:page" data="{{routeData}}" tail="{{subroute}}"> </app-route>

    <sample-layout> <sample-header slot="header" /> <iron-pages selected="[[page]]" attr-for-selected="name" fallback-selection="view404" role="main"> <sample-view1 name="view1"></sample-view1> <sample-view2 name="view2"></sample-view2> <sample-view3 name="view3"></sample-view3> <sample-view404 name="view404"></sample-view404> </iron-pages> <sample-footer slot="footer" /> </sample-layout>
  13. 番外編:PWA • PWA(Progressive Web Apps)の略 • iOS 11.3のSafari 11.1からService Workerに対応!

    • オフライン対応やPush通知などネイティブアプリに近 い挙動を実現する技術の総称 • Service Worker • Push Notification • ネイティブアプリに近いUI