-
Notifications
You must be signed in to change notification settings - Fork 1
/
stitch-order-form.html
241 lines (202 loc) · 5.51 KB
/
stitch-order-form.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
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/iron-form/iron-form.html">
<link rel="import" href="bower_components/paper-styles/shadow.html">
<link rel="import" href="bower_components/paper-input/paper-input.html">
<link rel="import" href="bower_components/iron-image/iron-image.html">
<link rel="import" href="bower_components/paper-button/paper-button.html">
<link rel="import" href="bower_components/vaadin-combo-box/vaadin-combo-box.html">
<link rel="import" href="font-styles.html">
<link rel="import" href="stitch-order-icons.html">
<dom-module id="stitch-order-form">
<template>
<style include="font-styles">
:host {
display: block;
color: var(--primary-text-color);
background-color: var(--primary-background-color);
margin: 10px;
padding: 22px 25px;
border-radius: 2px;
@apply(--shadow-elevation-2dp);
}
.section {
margin-top: 50px;
}
.horizontal {
@apply(--layout-horizontal);
}
[spacer] {
@apply(--layout-flex);
}
form paper-input {
margin: 0 10px;
}
@media (min-width: 768px) {
form paper-input {
margin: 0 25px;
width: 60%;
}
form .horizontal paper-input {
width: 15%;
}
}
#content {
margin: 15px auto;
}
.left iron-image {
display: block;
width: 150px;
height: 150px;
}
.left .checkPrime {
height: 29px;
}
#content .right {
padding-left: 10px;
@apply(--layout-flex);
}
#options {
@apply(--layout-vertical);
@apply(--layout-end);
}
iron-icon[prefix] {
color: var(--secondary-text-color);
margin-right: 10px;
}
#invoiceResume :not(h3) {
margin: 0 25px;
}
#buttons {
margin: 50px 0 20px;
@apply(--layout-horizontal-reverse);
}
paper-button:not([disabled]):hover {
font-weight: bold;
}
#submitButton:not([disabled]) {
color: var(--text-primary-color);
background-color: var(--primary-color);
}
#cancelButton:not([disabled]) {
color: var(--accent-color);
}
</style>
<header>
<h1>Order Product</h1>
<paper-input label="[[label]]" placeholder="[[placeholder]]"
value="{{productUrl}}" type="url" required
error-message="Invalid URL">
<iron-icon icon="stitch-order:shopping-cart" prefix></iron-icon>
</paper-input>
</header>
<form is="iron-form" id="form" method="get" content-type="application/json">
<div id="content" class="horizontal">
<div class="left">
<iron-image sizing="contain" preload fade placeholder="./placeholder.jpg"
src="[[productDetails.image]]">
</iron-image>
<img class="checkPrime" hidden$="[[!productDetails.prime]]"
src="./prime.png" alt="the Prime Logo with a checkmark">
</div>
<div class="right">
<h2>[[productDetails.Title]]</h2>
<h4>Select Options</h4>
<div id="options">
<template is="dom-repeat" items="[[productDetails.options]]" as="option">
<vaadin-combo-box required label="[[option.name]] *"
items="[[option.values]]">
</vaadin-combo-box>
</template>
</div>
</div>
</div>
<div id="shipping" class="section">
<h3>Shipping information</h3>
<paper-input required label="Address Line 1 *"></paper-input>
<paper-input label="Address Line 2"></paper-input>
<div class="horizontal">
<paper-input required label="City *"></paper-input>
<paper-input required label="State *"></paper-input>
<paper-input required label="ZIP *" type="number"></paper-input>
</div>
<paper-input required label="E-Mail *" type="email">
<iron-icon icon="stitch-order:mail" prefix></iron-icon>
</paper-input>
<paper-input required label="Phone Number *" type="tel">
<iron-icon icon="stitch-order:phone" prefix></iron-icon>
</paper-input>
</div>
<div id="invoiceResume" class="section">
<h3>Total Cost</h3>
<div>$ [[productDetails.cost]] + shipping</div>
<p>(Note: shipping is calculated when purchase is made)</p>
</div>
<div id="buttons" class="section">
<paper-button id="submitButton" raised on-tap="_submit">Set up Order</paper-button>
<div spacer></div>
<paper-button id="cancelButton" on-tap="reset">Cancel</paper-button>
</div>
</form>
</template>
<script>
(function(){
'use strict';
Polymer({
is: 'stitch-order-form',
properties: {
label: {
type: String,
value: 'Paste the URL of the Amazon page here'
},
placeholder: {
type: String,
value: 'https://www.amazon.com/...'
},
/*
* USER SETTABLE PROPERTIES
* ========================
*/
productUrl: {
// On change, load new product details
type: String,
value: '',
notify: true
},
/*
* DERIVED PROPERTIES
* ========================
*/
productDetails: {
/* Depends on productUrl.
* Rough idea: parse the URL for the ASIN. Then use the amazon-produt-api NPM
* to grab the product details.
*/
type: Object
}
},
listeners: {
'iron-form-presubmit': '_setAction'
},
attached: function(){
this.reset();
},
reset: function(){
this.productUrl = '';
this.$.form.reset();
},
_setAction: function(){
var params = this.$.form.request.params;
console.log(params);
},
_submit: function(){
if (this._validate()) {
this.$.form.submit();
}
},
_validate: function(){
return true;
}
});
})();
</script>
</dom-module>