-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathheader.js
202 lines (168 loc) · 3.58 KB
/
header.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
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
import { style, color, routes, font, device } from './constants'
view Header {
prop nobg
<wrap>
<Contain maxWidth={890}>
<Logo small />
<Nav large />
<Social tiny noSlack />
</Contain>
</wrap>
$ = {
padding: 0,
position: 'absolute',
top: 0,
left: 0,
right: 0,
zIndex: 100,
[device.small]: {
marginBottom: -150,
boxShadow: 'none',
position: 'relative'
}
}
$wrap = {
flexFlow: 'row',
alignItems: 'center',
justifyContent: 'center',
background: nobg ? 'rgba(0,0,0,0.05)' : style.gradient,
boxShadow: nobg ? 'transparent' : '0 0 4px rgba(0,0,0,0.25)',
transition: 'all ease-in 300ms',
[device.small]: {
flexFlow: 'column'
}
}
$Nav = {
flexGrow: 1,
marginLeft: 10,
marginTop: -3
}
$Social = {
justifyContent: 'flex-end'
}
$Logo = {
[device.small]: {
marginTop: 15
}
}
}
const routeProps = path => ({
href: path,
onClick: Motion.router.link(path),
className: { active: Motion.router.isActive(path) }
})
view Nav {
const items = [
{ label: 'Start', route: '/start' },
{ label: 'Docs', route: routes.docs + '/intro' },
{ label: 'Examples', route: '/learn' },
// { label: 'Migrate', route: '/transition' },
]
<a repeat={items} {...routeProps(_.route)}>{_.label}</a>
$ = {
userSelect: 'none',
margin: [0, 'auto'],
flexFlow: 'row',
zIndex: 100,
[device.small]: {
marginBottom: 0,
margin: [10, 'auto', 0]
}
}
$a = {
border: '1px solid transparent',
color: 'rgba(255,255,255,0.8)',
textShadow: '0 1px 1px rgba(0,0,0,0.15)',
fontWeight: 300,
borderBottom: 'none',
fontSize: 16,
padding: [0, 10],
cursor: 'pointer',
textDecoration: 'none',
hover: {
color: 'rgba(255,255,255,1)',
}
}
$active = {
fontWeight: 600,
color: '#fff'
}
}
function showInstall(e) {
if (Motion.router.isActive(routes.home))
util.linkScroll(e)
else
Motion.router.go(routes.home)
}
view Logo {
<img root onClick={Motion.router.link(routes.home)} src="/assets/images/motion-small.png" />
const width = 256
const height = 61
const multiplier = view.props.small ? .33333 : .28
$img = {
width: Math.round(width * multiplier),
height: Math.round(height * multiplier),
margin: 'auto',
cursor: 'pointer',
[device.small]: {
alignSelf: 'center'
}
}
}
let finished = false
let already = false
view Desc {
prop already, start
const betweenPhrase = 3000
const typeSpeed = 130
let started = start
let how = ''
let phrases = ['faster', 'creatively', 'with ease']
let phrasePos = 0
let charPos = 0
on.mount(run)
on.unmount(stop)
on.props(() => {
if (already && finished) {
how = phrases[2]
return
}
if (start && !started) {
started = true
run()
}
})
function run() {
if (started) setTimeout(step, 1000)
}
function stop() {
finished = true
}
function step() {
if (phrasePos == phrases.length)
return stop()
// if typed to end of word
if (charPos === phrases[phrasePos].length) {
charPos = -1
phrasePos += 1
setTimeout(step, betweenPhrase)
}
// if typing word
else {
charPos += 1
how = phrases[phrasePos].slice(0, charPos)
setTimeout(step, typeSpeed)
}
}
<desc>Web apps, {how}</desc>
$desc = {
textAlign: 'center',
fontSize: 18,
fontWeight: 300,
lineHeight: '1.6rem',
padding: [0, 0, 18],
margin: [0, 'auto'],
display: 'block',
color: '#fff'
}
}