Skip to content

Commit 038075d

Browse files
committed
Add the initial version.
0 parents  commit 038075d

File tree

99 files changed

+10126
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+10126
-0
lines changed

.gitignore

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# build output
2+
.next
3+
4+
# dependencies
5+
node_modules
6+
7+
# logs
8+
npm-debug.log

components/arrow.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const Arrow = () => (
2+
<svg
3+
style={{ fill: 'inherit' }}
4+
width="27px"
5+
height="14px"
6+
viewBox="0 0 27 14"
7+
version="1.1"
8+
>
9+
<g id="Page-1" stroke="none" strokeWidth="1" fillRule="evenodd">
10+
<polygon
11+
id="Arrow"
12+
fillRule="nonzero"
13+
points="13.4999996 13.9214282 0.6 1.17499997 1.82857139 0.1 13.4999996 11.7714282 25.1714278 0.1 26.3999992 1.17499997"
14+
/>
15+
</g>
16+
</svg>
17+
)
18+
19+
export default Arrow

components/css-config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const FONT_FAMILY_SANS =
2+
'-apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif'
3+
4+
export const FONT_FAMILY_MONO =
5+
'Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace, serif'
6+
7+
export const COLOR_ERROR = '#FF001F'
8+
export const COLOR_SUCCESS = '#067DF7'

components/docs/navbar/desktop.js

+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
import React from 'react'
2+
import data from '../../../lib/data/docs'
3+
import Link from 'next/link'
4+
import qs from 'query-string'
5+
6+
export class NavLink extends React.Component {
7+
getCurrentHref() {
8+
const { url } = this.props
9+
const query = qs.stringify(url.query)
10+
let href = url.pathname
11+
12+
if (query !== '') {
13+
href = `${href}?${query}`
14+
}
15+
16+
return href
17+
}
18+
19+
isSelected() {
20+
const { href, aliases = [] } = this.props.info
21+
const currentHref = this.getCurrentHref()
22+
23+
if (href === currentHref) return true
24+
if (aliases.indexOf(currentHref) >= 0) return true
25+
26+
return false
27+
}
28+
29+
render() {
30+
const { info } = this.props
31+
32+
return (
33+
<div>
34+
<Link href={info.href} as={info.as || info.href}>
35+
<a className={this.isSelected() ? 'selected' : ''}>{info.name}</a>
36+
</Link>
37+
<style jsx>{`
38+
a {
39+
text-decoration: none;
40+
font-size: 14px;
41+
color: #000;
42+
}
43+
44+
a.selected {
45+
font-weight: 600;
46+
color: #000;
47+
}
48+
`}</style>
49+
</div>
50+
)
51+
}
52+
}
53+
54+
export default class DocsNavbarDesktop extends React.Component {
55+
renderPost(info, level) {
56+
if (info.posts) {
57+
return this.renderCategory(info, level + 1)
58+
}
59+
60+
return (
61+
<div className="link" key={info.href}>
62+
<NavLink info={info} url={this.props.url} />
63+
<style jsx>{`
64+
.link {
65+
margin: 10px 0;
66+
}
67+
68+
@media screen and (max-width: 950px) {
69+
.link {
70+
padding: 20px 0;
71+
margin: 0;
72+
border-bottom: 1px solid #EEE;
73+
}
74+
}
75+
`}</style>
76+
</div>
77+
)
78+
}
79+
80+
renderCategory(info, level = 1) {
81+
const levelClass = `level-${level}`
82+
const postStyle = {
83+
marginLeft: 10 * (level - 1)
84+
}
85+
86+
return (
87+
<div className={`category ${levelClass}`} key={info.name}>
88+
<div className="label">
89+
{info.href ? <NavLink info={info} url={this.props.url} /> : info.name}
90+
</div>
91+
<div className="posts" style={postStyle}>
92+
{info.posts.map(postInfo => this.renderPost(postInfo, level))}
93+
</div>
94+
<style jsx>{`
95+
.label {
96+
margin: 0 0 15px 0;
97+
font-size: 13px;
98+
text-transform: uppercase;
99+
letter-spacing: 1.3px;
100+
font-weight: 400;
101+
color: #888;
102+
cursor: default;
103+
}
104+
105+
.level-2 .label {
106+
font-size: 14px;
107+
font-weight: 400;
108+
margin: 10px 0;
109+
text-transform: none;
110+
letter-spacing: 0;
111+
cursor: default;
112+
}
113+
114+
.category.level-1 {
115+
margin: 0 0 50px 0;
116+
}
117+
118+
@media screen and (max-width: 950px) {
119+
.label {
120+
margin: -10px 0;
121+
}
122+
123+
.level-2 .label {
124+
padding: 20px 0;
125+
margin: 0;
126+
border-bottom: 1px solid #EEE;
127+
}
128+
}
129+
`}</style>
130+
</div>
131+
)
132+
}
133+
134+
render() {
135+
return (
136+
<div>
137+
{data.map(categoryInfo => this.renderCategory(categoryInfo))}
138+
</div>
139+
)
140+
}
141+
}

components/docs/navbar/mobile.js

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import React from 'react'
2+
import DocsNavbarDesktop from './desktop'
3+
import Arrow from '../../arrow'
4+
5+
export default class DocsNavbarMobile extends React.Component {
6+
state = { show: false }
7+
8+
toggle() {
9+
this.setState({ show: !this.state.show })
10+
}
11+
12+
render() {
13+
const { show } = this.state
14+
15+
return (
16+
<div>
17+
<div
18+
className={show ? 'arrow show' : 'arrow'}
19+
onClick={() => this.toggle()}
20+
>
21+
<Arrow />
22+
</div>
23+
{show ? <DocsNavbarDesktop {...this.props} /> : null}
24+
<style jsx>{`
25+
.arrow {
26+
margin: 0 0 30px 0;
27+
width: 27px;
28+
}
29+
30+
.arrow.show {
31+
transform: rotate(180deg);
32+
}
33+
`}</style>
34+
</div>
35+
)
36+
}
37+
}

components/freeze-page-scroll.js

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import React from 'react'
2+
3+
export default class FreezePageScroll extends React.Component {
4+
// Make sure to unfreeze when unmounting the component
5+
componentWillUnmount() {
6+
this.freezeScrolling(false)
7+
}
8+
9+
// Make sure to freeze if unmounted and re-mounted again while mouse is
10+
// still over the component
11+
register(ref) {
12+
if (!ref) return
13+
14+
const onMove = () => {
15+
this.freezeScrolling(true)
16+
ref.removeEventListener('mousemove', onMove)
17+
}
18+
19+
ref.addEventListener('mousemove', onMove)
20+
}
21+
22+
freezeScrolling(enable) {
23+
const { body } = document
24+
if (enable) {
25+
// If already freezed we don't need to do anything
26+
if (/body\-freeze\-scroll/.test(body.className)) return
27+
body.className = `body-freeze-scroll ${body.className}`
28+
} else {
29+
body.className = body.className.replace('body-freeze-scroll', '').trim()
30+
}
31+
}
32+
33+
render() {
34+
return (
35+
<div
36+
ref={r => this.register(r)}
37+
onMouseEnter={() => this.freezeScrolling(true)}
38+
onMouseLeave={() => this.freezeScrolling(false)}
39+
>
40+
{this.props.children}
41+
<style jsx global>{`
42+
.body-freeze-scroll {
43+
overflow: hidden;
44+
}
45+
`}</style>
46+
</div>
47+
)
48+
}
49+
}

0 commit comments

Comments
 (0)