Transcript
Page 1: 20150729 polymer超入門

Polymer超入門品質管理課 後藤 和良

Page 2: 20150729 polymer超入門

自己紹介

後藤 和良

品質管理課(QC)

KazuyoshiGoto

Page 3: 20150729 polymer超入門

Fallout4はよってくらいにはゲーマー

Page 4: 20150729 polymer超入門

Polymerとは?

Page 5: 20150729 polymer超入門

今年5月のGoogle IO で

1.0がリリースされたばかり。

Page 6: 20150729 polymer超入門

Googleが作ったJavaScriptのUIフレームワーク

!

Web ComponentsをChrome以外でも扱えるようにしてくれる。

Page 7: 20150729 polymer超入門

Web Components? うぇぶこんぽーねんと?

Page 8: 20150729 polymer超入門

Web Components

Webページのパーツをコンポーネント化し、再利用しやすくできる。

今後のWeb標準になる予定の技術。

Page 9: 20150729 polymer超入門

Web Components

HTML/CSS/JavaScript

コンポーネントをHTMLタグとして作れる

カプセル化したコンポーネントは外部汚染しない

だから再利用しやすい

Page 10: 20150729 polymer超入門

簡単な例

Page 11: 20150729 polymer超入門

index.html<!DOCTYPE html> <html> <head> <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="name-tag.html"> </head> <body> <name-tag></name-tag> </body> </html>

Page 12: 20150729 polymer超入門

name-tag.html<link rel="import" href="bower_components/polymer/polymer.html"> <dom-module id="name-tag"> <template> ここに値を「<b>{{text}}</b>」と表示します。

</template> <script> Polymer({ is: "name-tag", ready: function () { this.text = "オッケー";

} }); </script> </dom-module>

Page 13: 20150729 polymer超入門

表示結果

Page 14: 20150729 polymer超入門

少しカスタマイズ

Page 15: 20150729 polymer超入門

index.html<!DOCTYPE html> <html> <head> <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="configurable-name-tag.html"> </head> <body> <name-tag text="デフォじゃない"></name-tag> </body> </html>

Page 16: 20150729 polymer超入門

configurable-name-tag.html<link rel="import" href="bower_components/polymer/polymer.html"> <dom-module id="name-tag"> <template> ここに値を「<b>{{text}}</b>」と表示します。

</template> <script> Polymer({ is: "name-tag", properties: { text: { type: String, value: "デフォルト値"

} } }); </script> </dom-module>

Page 17: 20150729 polymer超入門

表示結果

Page 18: 20150729 polymer超入門

スタイルがカプセル化される

Page 19: 20150729 polymer超入門

style-sample.html<link rel="import" href="bower_components/polymer/polymer.html"> <dom-module id="style-sample"> <style> p { color: #f00; font-weight: bold; } </style> <template> <p>色付きのPタグ</p>

</template> <script> Polymer({ is: "style-sample" }); </script> </dom-module>

Page 20: 20150729 polymer超入門

index.html<!DOCTYPE html> <html> <head> <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="style-sample.html"> </head> <body> <style-sample></style-sample> <p>Pタグだけど色付かない</p>

</body> </html>

Page 21: 20150729 polymer超入門

表示結果

Page 22: 20150729 polymer超入門

デモ紹介

Page 23: 20150729 polymer超入門

Polymer がスゴいというよりWeb Components がスゴい

Page 24: 20150729 polymer超入門

ご静聴ありがとうございました。


Top Related