This repository has been archived by the owner on Jun 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
72 lines (60 loc) · 1.78 KB
/
index.js
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
var choo = require('choo')
var html = require('choo/html')
var css = require('sheetify')
var map = require('./map.component.js')()
var app = choo()
css('tachyons')
css('./style.css')
var invisible = css`:host { opacity: 0; }`
var mapContainer = css`position: relative; max-width: 900px; min-height: 100vh;`
app.route('*', function (state, emit) {
return html`
<body class="sans-serif">
${navbar(state, emit)}
<main class="flex w-100 items-center justify-center">
<div class=" flex w-100 items-center justify-center">
<div
class="flex justify-center items-center w-100 ${mapContainer}">
<div class="spinner"><div></div><div></div><div></div><div></div></div>
<div class="w-100 ${!state.map.loaded ? invisible : ''}">${map.render(state, emit)}</div>
</div>
</div>
</main>
</body>
`
})
app.use(function (state, emitter) {
state.map = {
loaded: false
}
emitter.on('DOMContentLoaded', function () {
emitter.on('map:load', function () {
setTimeout(() => {
state.map.loaded = true
emitter.emit('render')
}, 500)
})
})
})
app.mount('body')
function navbar (state, emit) {
return html`
<nav class="z-3 flex justify-between items-center h3 ph1">
<div class="fw8 pv2 flex-auto">
${html`<span class="ma2">J'aime NDG</span>`}
</div>
<div class="pa3 items-center justify-center">
${searchbar(state, emit)}
</div>
<div class="flex flex-auto justify-end items-center">
</div>
</nav>`
}
function searchbar (state, emit) {
return html`
<input
type="text"
class="pa2 mh2 dn"
style="max-width: 450px;"
placeholder="Search for a service, a place, an organization..." />`
}