Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.

Commit 36248de

Browse files
author
Elliott Marquez
authored
Merge pull request #2537 from Polymer/stack-blitz
Stackblitz demos for 3.x elements
2 parents 8a33d5a + f013d65 commit 36248de

40 files changed

+21966
-13511
lines changed

app/3.0/start/quick-tour.md

+19-27
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ of the samples in an interactive sandbox.
3434
Tap the buttons following each feature to learn more.
3535

3636
**The Plunker samples won't work in Internet Explorer 11.** These code samples need to
37-
be transpiled from ES6 to ES5 to work in Internet Explorer. This is usually done as a
38-
build step. At the moment, we don't have a way to transpile the interactive samples on
37+
be transpiled from ES6 to ES5 to work in Internet Explorer. This is usually done as a
38+
build step. At the moment, we don't have a way to transpile the interactive samples on
3939
Plunker. The samples will work in browsers that support ES6 - for example, the latest
4040
versions of Chrome, Edge, Firefox and Safari.
4141
{: .alert .alert-info }
@@ -49,7 +49,7 @@ an element name with a class, so you can add properties and methods to your cust
4949
element. The custom element's name **must start with an ASCII letter and
5050
contain a dash (-)**.
5151

52-
<demo-tabs selected="0" name="qt-1-register" src="http://plnkr.co/edit/FYhDkkAuD4TEnsgeZuc7?p=preview">
52+
<demo-tabs selected="0" name="qt-1-register" editor-open-file="custom-element.js" project-path="/3.0/start/samples/custom-element">
5353
<paper-tab slot="tabs">custom-element.js</paper-tab>
5454
<div>
5555

@@ -66,13 +66,12 @@ contain a dash (-)**.
6666
```
6767

6868
</div>
69-
<iframe slot="results" frameborder="0" src="samples/custom-element/index.html" width="100%" height="40"></iframe>
7069
</demo-tabs>
7170

7271
Try it out in **Plunker**:
73-
* Try modifying the contents of `this.textContent`.
72+
* Try modifying the contents of `this.textContent`.
7473
* If you’re familiar with your browser’s developer tools, try printing the
75-
custom element’s `tagName` property to the console.
74+
custom element’s `tagName` property to the console.
7675
Hint: add `console.log(this.tagName);` to the constructor method!
7776

7877
This sample uses a lifecycle callback
@@ -93,7 +92,7 @@ You can use the `ready` callback for one-time initialization work after the elem
9392
Many elements include some internal DOM nodes to implement the element's UI and behavior.
9493
You can use Polymer's DOM templating to create a shadow DOM tree for your element.
9594

96-
<demo-tabs selected="0" name="qt-2-shadow-dom" src="http://plnkr.co/edit/IvBQDkwRlLuG6P1fIMLr?p=preview">
95+
<demo-tabs selected="0" name="qt-2-shadow-dom" editor-open-file="dom-element.js" project-path="/3.0/start/samples/dom-element">
9796
<paper-tab slot="tabs">dom-element.js</paper-tab>
9897
<div>
9998

@@ -110,7 +109,6 @@ You can use Polymer's DOM templating to create a shadow DOM tree for your elemen
110109
```
111110

112111
</div>
113-
<iframe slot="results" frameborder="0" src="samples/dom-element/index.html" width="100%" height="40"></iframe>
114112
</demo-tabs>
115113

116114
Try it out in **Plunker**:
@@ -128,7 +126,7 @@ so they render as if they were inserted into the shadow DOM tree.
128126
This example creates a simple tag that decorates an image by wrapping it
129127
with a styled `<div>` tag.
130128

131-
<demo-tabs selected="0" name="qt-3-compose" src="http://plnkr.co/edit/RhauVxmC96dSKRgSn04Y?p=preview">
129+
<demo-tabs selected="0" name="qt-3-compose" editor-open-file="picture-frame.js" project-path="/3.0/start/samples/picture-frame">
132130
<paper-tab slot="tabs">picture-frame.js</paper-tab>
133131
<div>
134132

@@ -145,7 +143,6 @@ with a styled `<div>` tag.
145143
```
146144

147145
</div>
148-
<iframe slot="results" frameborder="0" src="samples/picture-frame/index.html" width="100%" height="60"></iframe>
149146
</demo-tabs>
150147

151148
Try it out in **Plunker**:
@@ -168,7 +165,7 @@ Data binding is a great way to quickly propagate changes in your element and red
168165
You can bind properties in your component using the "double-mustache" syntax (`{%raw%}{{}}{%endraw%}`).
169166
The `{%raw%}{{}}{%endraw%}` is replaced by the value of the property referenced between the brackets.
170167

171-
<demo-tabs selected="0" name="qt-4-data-binding" src="http://plnkr.co/edit/dobBH1EwNvnymIrs0yMd?p=preview">
168+
<demo-tabs selected="0" name="qt-4-data-binding" editor-open-file="name-tag.js" project-path="/3.0/start/samples/name-tag">
172169
<paper-tab slot="tabs">name-tag.js</paper-tab>
173170
<div>
174171

@@ -185,14 +182,13 @@ The `{%raw%}{{}}{%endraw%}` is replaced by the value of the property referenced
185182
```
186183

187184
</div>
188-
<iframe slot="results" frameborder="0" src="samples/name-tag/index.html" width="100%" height="40"></iframe>
189185
</demo-tabs>
190186

191187
Try it out in **Plunker**:
192188
* Try editing the value of the `owner` property.
193-
* Try adding another property and binding it in your component.
189+
* Try adding another property and binding it in your component.
194190
Hint: Add `this.propertyName = 'Property contents';` to the constructor
195-
and add something like `<p>{{propertyName}}</p>` to the element’s template.
191+
and add something like `<p>{{propertyName}}</p>` to the element’s template.
196192

197193
<p><a href="/3.0/docs/devguide/data-binding" class="blue-button">
198194
Learn more: data binding</a></p>
@@ -206,7 +202,7 @@ values, configuring properties from markup, observing property changes, and more
206202
The following example declares the `owner` property from the last example.
207203
It also shows configuring the owner property from markup in `index.html`.
208204

209-
<demo-tabs selected="0" name="qt-5-declare-property" src="http://plnkr.co/edit/nnEna7Sp3HoT8ndablOp?p=preview">
205+
<demo-tabs selected="0" name="qt-5-declare-property" editor-open-file="configurable-name-tag.js" project-path="/3.0/start/samples/configurable-name-tag">
210206
<paper-tab slot="tabs">configurable-name-tag.js</paper-tab>
211207
<div>
212208

@@ -223,7 +219,6 @@ It also shows configuring the owner property from markup in `index.html`.
223219
```
224220

225221
</div>
226-
<iframe slot="results" frameborder="0" src="samples/configurable-name-tag/index.html" width="100%" height="40"></iframe>
227222
</demo-tabs>
228223

229224
Try it out in **Plunker**:
@@ -239,10 +234,10 @@ In addition to text content, you can bind to an element's _properties_ (using
239234
can optionally support two-way binding, using curly braces (`property-name="{{binding}}"`).
240235

241236
This example uses two-way binding: binding the value of a property on a parent element to a property
242-
on the child element. When the child element updates the property, the changes are bound to the
237+
on the child element. When the child element updates the property, the changes are bound to the
243238
parent element.
244239

245-
<demo-tabs selected="0" name="qt-6-bind-property" src="http://plnkr.co/edit/ixopefPZUV96R6SzEJun?p=preview">
240+
<demo-tabs selected="0" name="qt-6-bind-property" editor-open-file="parent-element.js" project-path="/3.0/start/samples/parent-element">
246241
<paper-tab slot="tabs">parent-element.js</paper-tab>
247242
<div>
248243

@@ -267,21 +262,20 @@ parent element.
267262
```
268263

269264
</div>
270-
<iframe slot="results" frameborder="0" src="samples/parent-element/index.html" width="100%" height="100"></iframe>
271265
</demo-tabs>
272266

273267
**Note:** `<child-element>` exposes its property to be used in two-way binding by setting the
274-
`reflectToAttribute` and `notify` attributes when the property is declared.
268+
`reflectToAttribute` and `notify` attributes when the property is declared.
275269
{: .alert .alert-info }
276270

277271
<p><a href="/3.0/docs/devguide/data-binding#two-way-bindings" class="blue-button">
278272
Learn more: Two-way binding</a></p>
279273

280-
<!--
274+
<!--
281275
This example uses two-way binding: binding the value of a custom input element (`iron-input`)
282276
to the element's `owner` property, so it's updated as the user types.
283277
284-
<demo-tabs selected="0" name="qt-6-bind-property" src="http://plnkr.co/edit/VdazK3ub45MrwYU1GTRM?p=preview">
278+
<demo-tabs selected="0" name="qt-6-bind-property" editor-open-file="editable-name-tag.js" project-path="/3.0/start/samples/editable-name-tag"">
285279
<paper-tab slot="tabs">editable-name-tag.js</paper-tab>
286280
<div>
287281
@@ -298,7 +292,6 @@ to the element's `owner` property, so it's updated as the user types.
298292
```
299293
300294
</div>
301-
<iframe slot="results" frameborder="0" src="samples/editable-name-tag/index.html" width="100%" height="100"></iframe>
302295
</demo-tabs>
303296
304297
Try it out in **Plunker**:
@@ -314,7 +307,7 @@ data binding and input validation.
314307

315308
The template repeater (`dom-repeat`) is a specialized template that binds to an array. It creates one instance of the template's contents for each item in the array.
316309

317-
<demo-tabs selected="0" name="qt-7-dom-repeat" src="http://plnkr.co/edit/9qFNzWTiytFEqJjRNxNi?p=preview">
310+
<demo-tabs selected="0" name="qt-7-dom-repeat" editor-open-file="employee-list.js" project-path="/3.0/start/samples/employee-list">
318311
<paper-tab slot="tabs">employee-list.js</paper-tab>
319312
<div>
320313

@@ -331,16 +324,15 @@ The template repeater (`dom-repeat`) is a specialized template that binds to an
331324
```
332325

333326
</div>
334-
<iframe slot="results" frameborder="0" src="samples/employee-list/index.html" width="100%" height="100"></iframe>
335327
</demo-tabs>
336328

337329
Try it out in **Plunker**:
338330
* Change the first and last names inside this.employees
339331
* Add another employee by inserting the following item into the array definition:<br/>
340332
```js
341-
{first: 'Shawna', last: 'Williams'}
333+
{first: 'Shawna', last: 'Williams'}
342334
```
343-
335+
344336
Don't forget to make sure your commas are correct!
345337

346338
<p><a href="/3.0/docs/devguide/templates" class="blue-button">

app/3.0/start/samples/configurable-name-tag/configurable-name-tag.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {Element as PolymerElement, html} from 'https://unpkg.com/@polymer/polymer@3.0.0-pre.7/polymer-element.js'
1+
import {PolymerElement, html} from '@polymer/polymer/polymer-element.js'
22

33
class ConfigurableNameTag extends PolymerElement {
44
static get properties () {
@@ -9,7 +9,7 @@ class ConfigurableNameTag extends PolymerElement {
99
value: 'Daniel',
1010
}
1111
};
12-
}
12+
}
1313
static get template () {
1414
return html`
1515
<!-- bind to the "owner" property -->

app/3.0/start/samples/configurable-name-tag/index.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<script src="https://polygit.org/components/webcomponentsjs/webcomponents-loader.js"></script>
5-
<script type="module" src="configurable-name-tag.js"></script>
4+
<script src="./node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
5+
<script src="./node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
66
</head>
77
<body>
88
<!-- configure a property from markup by setting
9-
the corresponding attribute:
9+
the corresponding attribute:
1010
-->
1111
<configurable-name-tag owner="Scott"></configurable-name-tag>
1212
<!--
13-
TODO: Try editing the initial value of `owner` in
13+
TODO: Try editing the initial value of `owner` in
1414
index.html. Observe how this sets the property directly
1515
from your HTML.
1616
-->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './configurable-name-tag.js';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"files": [
3+
"configurable-name-tag.js",
4+
"index.html",
5+
"index.js"
6+
],
7+
"dependencies": {
8+
"@polymer/polymer": "next",
9+
"@webcomponents/webcomponentsjs": "^1.0.0"
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import {Element as PolymerElement} from 'https://unpkg.com/@polymer/polymer@3.0.0-pre.7/polymer-element.js'
1+
import {PolymerElement} from '@polymer/polymer/polymer-element.js';
22

33
// Define the class for a new element called custom-element
44
class CustomElement extends PolymerElement {
5-
65
constructor() {
76
super();
87
this.textContent = 'I\'m a custom-element.';
@@ -13,6 +12,6 @@ customElements.define('custom-element', CustomElement);
1312

1413
/*
1514
If you’re familiar with your browser’s developer tools, try printing the
16-
custom element’s `tagName` property to the console.
15+
custom element’s `tagName` property to the console.
1716
Hint: add `console.log(this.tagName);` to the constructor method!
1817
*/
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<script src="https://polygit.org/components/webcomponentsjs/webcomponents-loader.js"></script>
5-
<script type="module" src="custom-element.js"></script>
4+
<script src="./node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
5+
<script src="./node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
66
</head>
7-
<body></body>
7+
<body>
88
<custom-element></custom-element>
99
</body>
10-
</html>
10+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './custom-element.js';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"files": [
3+
"custom-element.js",
4+
"index.html",
5+
"index.js"
6+
],
7+
"dependencies": {
8+
"@polymer/polymer": "next",
9+
"@webcomponents/webcomponentsjs": "^1.0.0"
10+
}
11+
}

app/3.0/start/samples/dom-element/dom-element.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import {Element as PolymerElement, html} from 'https://unpkg.com/@polymer/polymer@3.0.0-pre.7/polymer-element.js'
1+
import {PolymerElement, html} from '@polymer/polymer/polymer-element.js'
22

33
// Define the class for a new element called custom-element
44
class DomElement extends PolymerElement {
5-
5+
66
static get template () {
77
return html`
88
<p>I'm a DOM element. This is my shadow DOM!</p>
9-
10-
<!-- TODO: Try adding some other html elements inside the
11-
template. For example, add <h1>A heading!</h1> or
9+
10+
<!-- TODO: Try adding some other html elements inside the
11+
template. For example, add <h1>A heading!</h1> or
1212
<a href="stuff.html">A link!</a>
13-
-->
13+
-->
1414
`;
1515
}
1616
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<script src="https://polygit.org/components/webcomponentsjs/webcomponents-loader.js"></script>
5-
<script type="module" src="dom-element.js"></script>
4+
<script src="./node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
5+
<script src="./node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
66
</head>
7-
<body></body>
7+
<body>
88
<dom-element></dom-element>
99
</body>
1010
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './dom-element.js';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"files": [
3+
"dom-element.js",
4+
"index.html",
5+
"index.js"
6+
],
7+
"dependencies": {
8+
"@polymer/polymer": "next",
9+
"@webcomponents/webcomponentsjs": "^1.0.0"
10+
}
11+
}

app/3.0/start/samples/editable-name-tag/editable-name-tag.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {Element as PolymerElement, html} from 'https://unpkg.com/@polymer/polymer@3.0.0-pre.7/polymer-element.js';
2-
import 'https://unpkg.com/@polymer/iron-input@3.0.0-pre.7/iron-input.js';
1+
import {PolymerElement, html} from '@polymer/polymer/polymer-element.js';
2+
import '@polymer/iron-input/iron-input.js';
33

44
class EditableNameTag extends PolymerElement {
55
static get properties () {
@@ -14,13 +14,13 @@ class EditableNameTag extends PolymerElement {
1414
return html`
1515
<!-- bind to the 'owner' property -->
1616
<p>This is <b>[[owner]]</b>'s name-tag element.</p>
17-
17+
1818
<!-- iron-input exposes a two-way bindable input value -->
1919
<iron-input bind-value="{{owner}}">
20-
<!--
20+
<!--
2121
TODO: Edit the placeholder text to see two-way data
2222
binding at work.
23-
-->
23+
-->
2424
<input is="iron-input" placeholder="Your name here...">
2525
</iron-input>
2626
`;

app/3.0/start/samples/editable-name-tag/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!DOCTYPE html>
22
<html lang="en">
33
<head>
4-
<script src="https://polygit.org/components/webcomponentsjs/webcomponents-loader.js"></script>
5-
<script type="module" src="editable-name-tag.js"></script>
4+
<script src="./node_modules/@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js"></script>
5+
<script src="./node_modules/@webcomponents/webcomponentsjs/webcomponents-lite.js"></script>
66
</head>
77
<body>
88
<editable-name-tag></editable-name-tag>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import './editable-name-tag.js';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"files": [
3+
"editable-name-tag.js",
4+
"index.html",
5+
"index.js"
6+
],
7+
"dependencies": {
8+
"@polymer/polymer": "next",
9+
"@webcomponents/webcomponentsjs": "^1.0.0",
10+
"@polymer/iron-input": "next"
11+
}
12+
}

0 commit comments

Comments
 (0)