forked from unbug/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlearn-tabs.html
More file actions
149 lines (145 loc) · 6.88 KB
/
learn-tabs.html
File metadata and controls
149 lines (145 loc) · 6.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<link rel="import" href="../components/polymer/polymer.html">
<link rel="import" href="../components/core-media-query/core-media-query.html">
<link rel="import" href="../components/code-explainer/code-explainer.html">
<link rel="import" href="../components/paper-button/paper-button.html">
<link rel="import" href="demo-tabs.html">
<polymer-element name="learn-tabs">
<template>
<style>
:host {
color: #1f2036;
}
.card {
color: rgb(31, 32, 54);
background-color: #f8f8f8;
}
.card p {
margin: 1em 0 !important;
}
.card h2 {
font-weight: 300;
letter-spacing: -0.01em;
line-height: 48px;
margin: 0;
}
.card .summary {
padding: 24px;
}
.card a {
text-decoration: none;
color: inherit;
}
.card .unquote-image {
background-image: url(/images/unquote.png);
background-size: cover;
background-position: top;
background-color: #e5e5e5;
width: 400px;
}
demo-tabs code-explainer-info code {
color: white;
}
</style>
<core-media-query query="min-width: 640px" queryMatches="{{wide}}"></core-media-query>
<demo-tabs theme="dark" style="width:100%;">
<demo-tab heading="{{wide ? 'Use Elements (30 sec) ➜' : 'Use ➜'}}">
<code-explainer>
<script type="text/template">[dim-start]<!-- Polyfill Web Components support for older browsers -->
<script src="components/platform/platform.js"></script>[dim-end]
<!-- Import element -->
[start-create]<link rel="import" href="google-map.html">[end-use]
<!-- Use element -->
[start-use]<google-map lat="37.790" long="-122.390"></google-map>[end-create]
</script>
<h2>Using Polymer Elements</h2>
<div>Using Polymer elements (like all Web Components) is absurdly simple:</div>
<code-explainer-info sec="create" bullet="1" label="Import element">
Find a component and import its definition into your page using
an HTML Import (<code><link rel="import"></code>).
</code-explainer-info>
<code-explainer-info sec="use" bullet="2" label="Use the new element">
Once imported, custom elements become first-class HTML elements and can be used like any other.
</code-explainer-info>
</code-explainer>
</demo-tab>
<demo-tab heading="{{wide ? 'Create Elements (5 min) ➜' : 'Create ➜' }}">
<code-explainer>
<script type="text/template"><!-- Define element -->
[start-def]<polymer-element name="my-counter" [start-publish]attributes="counter"[end-publish]>[end-def]
[start-scope]<template>[end-scope]
<style> /*...*/ </style>
<div id="label"><content></content></div>
Value: <span [start-nodefind]id="counterVal"[end-nodefind]>[start-data]{{counter}}[end-data]</span><br>
<button [start-events]on-tap="{{increment}}[end-events]">Increment</button>
[start-scope]</template>[end-scope]
<script>
Polymer({
[start-publish][start-data]counter[end-data]: 0[end-publish], // Default value
[start-publish]counterChanged[end-publish]: function() {
[start-nodefind]this.$.counterVal[end-nodefind].classList.add('highlight');
},
[start-events]increment[end-events]: function() {
this.counter++;
}
});
</script>
[start-def]</polymer-element>[end-def]
<!-- Use element -->
<my-counter [start-publish]counter="10"[end-publish]>Points</my-counter>
</script>
<h2>Creating Polymer Elements</h2>
<div>Polymer sugars Web Components standards with awesome features for creating custom elements:</div>
<code-explainer-info sec="def" label="Declarative custom element definition">
Define custom elements declaratively using <code><polymer-element></code>
</code-explainer-info>
<code-explainer-info sec="scope" label="Markup and style encapsulation">
Shadow DOM encapsulates your element's internals. Template markup is
compartmentalized, and styles don't leak in or out.
</code-explainer-info>
<code-explainer-info sec="publish" label="Published properties">
Properties that are <em>published</em> can be initialized via markup and invoke change
handlers when modified.
</code-explainer-info>
<code-explainer-info sec="data" label="Declarative data binding">
Properties on the element can be bound directly into the view, with robust support for
expressions.
</code-explainer-info>
<code-explainer-info sec="events" label="Declarative event binding">
Event handlers can be bound to functions on the element declaratively using
<code>on-<i>event</i></code> attributes.
</code-explainer-info>
<code-explainer-info sec="nodefind" label="Automatic node finding">
Any template children can be referenced by <code>id</code> on <code>this.$</code>, eliminating
boilerplate querySelector's.
</code-explainer-info>
</code-explainer>
</demo-tab>
<demo-tab heading="{{wide ? 'Build an app (30 min)' : 'Tutorial' }}">
<div class="card">
<div layout horizontal?="{{wide}}" vertical?="{{!wide}}">
<div class="summary" flex layout vertical>
<h2>Build an app</h2>
<div flex>
<p>Ready to dive deeper? In this tutorial, you'll build a small Polymer application --
a very basic client for a social networking service<span hidden?="{{!wide}}"> like the one at right</span>.
It'll give you a good feel for both using pre-made Polymer elements as well as building custom
elements of your own.</p>
<a href="/docs/start/tutorial/intro.html"><paper-button raisedButton icon="arrow-forward" label="Go to tutorial"></paper-button></a>
<p>If you'd rather keep reading, head to the Polymer docs page to dive deeper.</p>
<a href="/docs/start/usingelements.html"><paper-button raisedButton icon="arrow-forward" label="Go to docs"></paper-button></a>
</div>
</div>
<a href="/docs/start/tutorial/intro.html" layout vertical>
<div class="unquote-image" hidden?="{{!wide}}" flex></div>
</a>
</div>
</div>
</demo-tab>
</demo-tabs>
</template>
<script>
Polymer('learn-tabs', {
wide: false
});
</script>
</polymer-element>