forked from googlearchive/component-download-button
-
Notifications
You must be signed in to change notification settings - Fork 0
/
component-download-view.html
243 lines (203 loc) · 6.54 KB
/
component-download-view.html
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!--
Copyright (c) 2014 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
-->
<link rel="import" href="../core-icons/core-icons.html">
<link rel="import" href="../core-selector/core-selector.html">
<link rel="import" href="../paper-button/paper-button.html">
<link rel="import" href="../paper-tabs/paper-tabs.html">
<!--
The `component-download-view` element presents a tabbed UI,
providing instructions for downloaing a Web Component.
The UI provides instructions for downloading via a ZIP file (via the
<em>bowerarchiver.appspot.com</em> web service), Bower, and Github.
The component remembers the tab the user last selected (via a global localStorage
property) so as to present the user's preferred download method on subsequent
uses of any instance of this component.
If the component is not hosted under the `Polymer` github org, specify
a different org using the `org` attribute.
Example:
<component-download-view component="core-ajax"></component-download-view>
<component-download-view org="PolymerLabs" component="google-map">
</component-download-view>
@element component-download-view
@status beta
@homepage github.io
-->
<polymer-element name="component-download-view" attributes="component org version">
<template>
<style>
:host {
display: block;
background-color: #f1f1f1;
}
#tabs {
background-color: #ffffff;
}
paper-tabs {
width: 350px;
color: #4555a5;
fill: currentcolor;
text-transform: uppercase;
}
paper-tabs::shadow #selectionBar {
background-color: currentcolor;
}
paper-tab::shadow #ink {
color: currentcolor;
}
.icon {
margin-right: 10px;
}
.cta {
background-color: #0f9d58;
color: white;
fill: white;
}
.cta[disabled] {
background-color: #cccccc;
color: #444;
fill: #444;
}
code {
border-radius: 3px;
background: #cccccc;
font-size: 0.8em;
padding: 6px;
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
code.block {
display: block;
padding: 8px 10px;
background: #0f9d58;
color: white;
}
.note {
font-style: italic;
font-size: 0.8em;
line-height: normal;
}
.important {
color: red;
}
core-selector {
display: block;
}
section {
display: none;
padding: 24px;
line-height: 2em;
}
section.core-selected {
display: block;
}
ol {
margin-left: -1em;
}
.label {
vertical-align: middle;
margin-left: 1ch;
margin-right: 2ch;
}
</style>
<div id="tabs">
<paper-tabs selected="{{selected}}">
<paper-tab>ZIP</paper-tab>
<paper-tab>Bower</paper-tab>
<paper-tab>Github</paper-tab>
</paper-tabs>
</div>
<core-selector selected="{{selected}}">
<section>
<paper-button class="cta" on-tap="{{downloadZIP}}">
<core-icon icon="file-download"></core-icon>
<span class="label">Download ZIP</span>
</paper-button>
<ol>
<li>Unzip ZIP file to your project root (merge with any existing components folder)</li>
<li>Import the component by adding this to your HTML file:<br>
<code><link rel="import" href="components/{{component}}/{{component}}.html"></code>
</li>
</ol>
<div class="note">
<strong>Quick start</strong>. The ZIP file contains all dependencies for this component and is
a great way to get started. For easier management and version control,
we recommend using
<a href="http://polymer-project.org/docs/start/getting-the-code.html#using-bower">Bower</a> instead.
</div>
</section>
<section>
<code class="block">bower install {{org}}/{{component}}#{{version}}</code>
<ol>
<li>Run the command above from your project root</li>
<li>Import the component by adding this to your HTML file:<br>
<code><link rel="import" href="components/{{component}}/{{component}}.html"></code>
</li>
</ol>
<div class="note">
<strong>Recommended.</strong> For details on getting set up using Bower with Polymer, see
<a href="http://polymer-project.org/docs/start/getting-the-code.html#using-bower">Installing with Bower</a>.
</div>
</section>
<section>
<code class="block">git clone https://github.com/{{org}}/{{component}}.git components/{{component}}</code>
<ol>
<li>Run the command above from your project root</li>
<li>Import the component by adding this to your HTML file:<br>
<code><link rel="import" href="components/{{component}}/{{component}}.html"></code>
</li>
</ol>
<div class="note">
<strong>Advanced users.</strong> Git repositories don't contain source code for component
dependencies. For most users, we recommend using
<a href="http://polymer-project.org/docs/start/getting-the-code.html#installing-components">ZIP or Bower</a>.
</div>
</section>
</core-selector>
</template>
<script>
Polymer({
selected: 0,
/**
* The name of the component in Github/Bower (required).
* @attribute component
* @type String
*/
component: null,
/**
* Optional: Github org (defaults to 'Polymer').
* @attribute org
* @default 'Get the Source'
* @type String
*/
org: "Polymer",
/**
* Bower version. Required.
* @attribute version
* @type String
*/
version: '',
ready: function() {
var s = parseInt(localStorage.getItem('polymer-download-pref'));
if (s == null || isNaN(s) || s < 0 || s > 2) {
s = 0;
}
this.selected = s;
},
selectedChanged: function() {
localStorage.setItem('polymer-download-pref', this.selected);
},
downloadZIP: function() {
window.location = 'https://bowerarchiver.appspot.com/archive?' + this.component + "=" + this.org +
"/" + this.component + "%23" + this.version;
}
});
</script>
</polymer-element>