This repository has been archived by the owner on Oct 22, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 505
/
Housing.html
331 lines (318 loc) · 11.9 KB
/
Housing.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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<!---
preview: default
--->
<!--
## Introduction
This sample showcases how to build a housing page in AMP HTML. Explore how to use amp components, like `amp-carousel`, `form` and `amp-list` to create a housing page.
-->
<!-- -->
<!doctype html>
<html ⚡>
<head>
<meta charset="utf-8">
<title>Housing</title>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<!-- ## Setup -->
<!--
We use `amp-carousel` to show house images.
-->
<script async custom-element="amp-carousel" src="https://cdn.ampproject.org/v0/amp-carousel-0.1.js"></script>
<!--
We use `amp-accordion` to hide and show additional data about an house product.
-->
<script async custom-element="amp-accordion" src="https://cdn.ampproject.org/v0/amp-accordion-0.1.js"></script>
<!--
We use `amp-list` to show a list of properties.
-->
<script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
<!--
We use `amp-mustache` as a format template for `amp-list`.
-->
<script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
<!--
We use `amp-social-share` for adding platform sharing buttons.
-->
<script async custom-element="amp-social-share" src="https://cdn.ampproject.org/v0/amp-social-share-0.1.js"></script>
<!--
We use `amp-iframe` to embed a map of the house location.
-->
<script async custom-element="amp-iframe" src="https://cdn.ampproject.org/v0/amp-iframe-0.1.js"></script>
<!--
We use `amp-form` to implement a mortgage calculator.
-->
<script async custom-element="amp-form" src="https://cdn.ampproject.org/v0/amp-form-0.1.js"></script>
<!--
We use `amp-fit-text` to fit the title of the house page to the page.
-->
<script async custom-element="amp-fit-text" src="https://cdn.ampproject.org/v0/amp-fit-text-0.1.js"></script>
<!--
We use `amp-analytics` to track page users.
-->
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<link rel="canonical" href="<%host%>/sample_amps/housing/">
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp-custom>
:root {
--color-primary: #005AF0;
--space-1: 0.5rem; /* 8px */
--space-2: 1rem; /* 16px */
--space-3: 1.5rem; /* 24px */
}
.description {
margin: 0;
padding: 0;
}
.description li {
list-style-type: square;
}
.housing-description {
clear: both;
}
.image-gallery {
margin: 0;
}
.additional-data p, .additional-data h2 {
padding: var(--space-2);
}
.additional-data h2 {
font-size: 18px;
}
.related {
background-color: #f5f5f5;
display: block;
color: #111;
height: 100px;
padding: 0;
padding-right: var(--space-1);
}
.related amp-img {
line-height: 24px;
font-weight: 400;
font-size: 24px;
vertical-align: middle;
float: left;
margin-right: 10px;
}
.related:active {
background-color: #ccc;
}
.price-description {
color: var(--color-primary);
font-weight: 400;
}
.price-heading {
margin-bottom: var(--space-2);
margin-top: var(--space-3);
padding: 0 var(--space-2);
}
.price-other {
font-weight: bold;
}
.contact-section {
margin-top: var(--space-2);
display: flex;
flex-wrap: wrap;
}
@media (max-width: 744px) {
.contact-section {
display: block;
}
}
@media (max-width: 744px) {
.contact {
display: flex;
margin-bottom: var(--space-2);
margin-top: var(--space-3);
justify-content: center;
padding: 0 var(--space-2);
}
}
.social-share {
line-height: 36px;
display: flex;
}
.list-overflow {
position: absolute;
bottom: 0;
}
.form-field-right {
border: 1px solid #dfdfdf;
background: white;
width: 200px;
}
.form-field-left {
width: 200px;
}
.ampstart-card {
text-decoration: none;
}
</style>
<style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
</head>
<body>
<!-- ## Price -->
<!--[amp-fit-text](https://www.ampproject.org/docs/reference/extended/amp-fit-text.html) can be used to fit the text to the available space. It works well for titles that vary not too much in length. -->
<div>
<h1>
<amp-fit-text class="price-heading" width="300" height="45" layout="responsive" max-font-size="45">
Cosy House in Central London
</amp-fit-text>
</h1>
<div class="price-description">£430,000</div>
<p class="housing-description">London SW1A 1AA</p>
</div>
<!-- ## Image gallery -->
<!-- The `amp-carousel` works very well for housing image galleries. Learn more about `amp-carousel` [here](/advanced/image_galleries_with_amp-carousel/). -->
<amp-carousel class="image-gallery" width="512" height="384" layout="responsive" type="slides">
<amp-img src="/img/buckingham_palace_building_1280x853.png" layout="fill" alt="Buckingham Palace" attribution="https://pixabay.com"></amp-img>
<amp-img src="/img/buckingham_palace_entrance_1280x853.jpg" layout="fill" alt="Buckingham Palace entrance" attribution="https://pixabay.com"></amp-img>
</amp-carousel>
<!-- ## Detail request section -->
<!-- These buttons are used for requesting details on the property. -->
<div class="contact-section">
<div> Do you like this property?</div>
<div class="contact">
<a href="tel:012 3456789">Call agent</a>
<a href="mailto:someone@example.com">Email agent</a>
</div>
</div>
<!-- ## Social -->
<!-- The Social Share extension provides a common interface for share buttons. Learn more about `amp-social-share` [here](/components/amp-social-share/). -->
<p class="social-share">
<amp-social-share type="twitter"
width="60"
height="44"></amp-social-share>
<amp-social-share type="facebook"
width="60"
height="44"
data-attribution="254325784911610"> </amp-social-share>
<amp-social-share type="gplus"
width="60"
height="44"></amp-social-share>
<amp-social-share type="email"
width="60"
height="44"></amp-social-share>
<amp-social-share type="pinterest"
width="66"
height="44"></amp-social-share>
</p>
<!-- ## Collapsibles/Accordion -->
<!-- Use `amp-accordion` to hide and show additional data about your product. Learn more about `amp-accordion` [here](/components/amp-accordion/). Embedding Google Maps is possible via the [Google Maps Embed API](https://developers.google.com/maps/documentation/embed/guide), see [here](https://ampbyexample.com/components/amp-iframe/#example16) for a sample.-->
<div>
<amp-accordion class="additional-data">
<section>
<h2>Description</h2>
<ul class="description">
<li>Ideally located near tube station</li>
<li>Open plan kitchen</li>
<li>Bicycle storage, visitors parking, communal gardens and roof terraces</li>
</ul>
</section>
<section>
<h2>View on map</h2>
<amp-iframe title="Embedded Google map"
width="600"
height="400"
layout="responsive"
sandbox="allow-scripts allow-same-origin allow-popups"
frameborder="0"
src="https://www.google.com/maps/embed/v1/place?key=AIzaSyCNCZ0Twm_HFRaZ5i-FuPDYs3rLwm4_848&q=London SW1A 1AA">
</amp-iframe>
</section>
<section>
<h2>Floorplan</h2>
<amp-img src="/img/floorplan_518x340.jpg" width="518" height="340"></amp-img>
</section>
</amp-accordion>
</div>
<!-- ## Mortgage calculator -->
<!-- Use `amp-form` to implement a mortgage calculator. Learn more about `amp-form` [here](/components/amp-form/). -->
<div>
<h2>Mortgage Calculator</h2>
<form method="GET" action="/samples_templates/housing/calculate-mortgage" action-xhr="/samples_templates/housing/calculate-mortgage-xhr" target="_top">
<div>
<label>
<input type="number" name="price" maxlength="10" value="2000000" required>
Price
</label>
</div>
<div>
<label>
<input type="number" name="deposit" maxlength="10" value="100000" required>
Deposit
</label>
</div>
<div>
<label>
<input type="number" name="annual_interest" maxlength="10" value="2.5" step="0.01" required>
Annual interest
</label>
</div>
<div>
<label>
<input type="number" name="repayment_period" value="25" required>
Repayment period (years)
</label>
</div>
<div>
<input type="submit" value="Calculate">
</div>
<div submit-success>
<template type="amp-mustache">
Monthly repayment {{monthly_repayment}}
</template>
</div>
<div submit-error>
<template type="amp-mustache">
Error! You entered some incorrect details {{err}}
</template>
</div>
</form>
</div>
<!-- ## Properties sold nearby -->
<!-- Use `amp-list` to show a list of properties sold nearby. Learn more about `amp-list` [here](/components/amp-list/) -->
<div>
<h2>Properties sold nearby</h2>
<amp-list width="auto"
height="150"
layout="fixed-height"
src="/json/other_properties.json">
<template type="amp-mustache">
<a href="#" class="ampstart-card related m1">
<amp-img width="122"
height="100"
src="{{src}}"
alt="{{alt}}"
attribution="{{attribution}}"></amp-img>
<p>{{desc}}</p>
<p>{{address}}</p>
<p class= "price-other">{{price}}</p>
</a>
</template>
<div overflow role="button" aria-label="Show more" class="list-overflow">
Show more
</div>
</amp-list>
</div>
<!-- ## User analytics -->
<!-- Analytics must be configured in the body. Here we use Google Analytics to track pageviews. -->
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"vars": {
"account": "UA-73836974-1"
},
"triggers": {
"default pageview": {
"on": "visible",
"request": "pageview",
"vars": {
"title": "Housing"
}
}
}
}
</script>
</amp-analytics>
</body>
</html>