1
1
import { Link } from '@reach/router'
2
2
import PropTypes from "prop-types"
3
- import React , { Component } from "react"
3
+ import React , { Component } from "react"
4
4
import promiseImageLoader from 'promise-image-loader'
5
5
import fetch from "isomorphic-fetch"
6
6
7
7
const NavItemFactory = ( linkImplementation ) => {
8
8
const LinkImplementation = ( linkImplementation ) ? linkImplementation : Link ;
9
- const NavItem = ( { url, rel, active, children} ) => {
9
+ const NavItem = ( { url, rel, active, children } ) => {
10
10
const classList = [ "alex-header__nav-item" ]
11
11
if ( active ) classList . push ( "alex-header__nav-item--active" )
12
12
return (
13
- < li className = { classList . join ( ' ' ) } >
14
- < LinkImplementation rel = { rel } to = { url } > { children } </ LinkImplementation >
15
- </ li >
13
+ < li className = { classList . join ( ' ' ) } >
14
+ < LinkImplementation rel = { rel } to = { url } > { children } </ LinkImplementation >
15
+ </ li >
16
16
) ;
17
17
}
18
18
@@ -23,7 +23,7 @@ const NavSpacer = () => (
23
23
< li className = "alex-header__nav-item alex-header__nav-item--spacer" > </ li >
24
24
)
25
25
26
- const Icon = ( { src, title} ) => (
26
+ const Icon = ( { src, title } ) => (
27
27
< img
28
28
src = { src }
29
29
// onerror={`"this.src='https://imagecdn.app/v2/image/${encodeURIComponent(icon)}?format=png&width=90'"`}
@@ -51,15 +51,15 @@ class HeaderImage extends Component {
51
51
. then ( ( ) => this . setState ( {
52
52
preloadedImage : actualSrc
53
53
} ) )
54
- . catch ( ( ) => { } )
54
+ . catch ( ( ) => { } )
55
55
}
56
56
57
57
imageService ( url , params = [ ] ) {
58
58
return `https://imagecdn.app/v2/image/${ encodeURIComponent ( url ) } ?${ params . join ( '&' ) } `
59
59
}
60
60
61
61
render ( ) {
62
- const { src} = this . props
62
+ const { src } = this . props
63
63
return < div className = { `alex-header-image` } >
64
64
< picture className = { `alex-header-image--container` } >
65
65
< img
@@ -71,14 +71,14 @@ class HeaderImage extends Component {
71
71
'height=60' ,
72
72
'quality=low' ,
73
73
'format=jpg'
74
- ] ) : null } />
74
+ ] ) : null } />
75
75
< img
76
76
alt = "Header"
77
77
className = { `alex-header-image__main` }
78
78
src = { this . state . preloadedImage }
79
79
style = { {
80
80
opacity : this . props . blur !== true && this . state . preloadedImage !== undefined ? 1 : 0
81
- } } />
81
+ } } />
82
82
</ picture >
83
83
</ div >
84
84
}
@@ -111,7 +111,7 @@ class Header extends Component {
111
111
try {
112
112
const response = await fetch ( 'https://source.unsplash.com/collection/33719360/0x0' )
113
113
if ( response . ok && response . url ) {
114
- const { origin, pathname} = new URL ( response . url )
114
+ const { origin, pathname } = new URL ( response . url )
115
115
this . setState ( {
116
116
backgroundImage : `${ origin } ${ pathname } `
117
117
} )
@@ -121,7 +121,7 @@ class Header extends Component {
121
121
}
122
122
123
123
render ( ) {
124
- const { pathname} = this . props . location
124
+ const { pathname } = this . props . location
125
125
const name = this . props . name ? this . props . name : "Alex Wilson"
126
126
const intro = this . props . intro ? this . props . intro : "On products, engineering & everything in-between."
127
127
@@ -133,53 +133,56 @@ class Header extends Component {
133
133
< div className = "alex-header--container" >
134
134
135
135
< div className = "alex-header__about" >
136
- < h1 className = "alex-header__name" > { name } </ h1 >
137
- { intro && < span className = "alex-header__intro" > { intro } </ span > }
136
+ < h1 className = "alex-header__name" > { name } </ h1 >
137
+ { intro && < span className = "alex-header__intro" > { intro } </ span > }
138
138
</ div >
139
139
140
140
141
141
< nav ref = { this . headerNav } class = "alex-header__nav--container" >
142
- < a
143
- className = "alex-header__menu-button" role = "button"
144
- aria-pressed = { this . state . navigationExpanded }
145
- onClick = { ( ) => { this . setState ( {
146
- navigationExpanded : ! this . state . navigationExpanded
147
- } )
148
- } }
149
- >
150
- < span > </ span >
151
- < span > </ span >
152
- < span > </ span >
153
- </ a >
154
- < ul className = "alex-header__nav" id = "menu" aria-expanded = { this . state . navigationExpanded } >
155
- < this . navItem url = "/" active = { pathname === "/" } > Home</ this . navItem >
156
- < this . navItem url = "/about-me/" active = { pathname . startsWith ( "/about-me/" ) } > About Me</ this . navItem >
157
- < this . navItem url = "/blog/" active = { pathname . startsWith ( "/blog/" ) || pathname . startsWith ( "/content/" ) } > Writing</ this . navItem >
158
- < this . navItem url = "/talks/" active = { pathname . startsWith ( "/talks/" ) } > Speaking</ this . navItem >
159
- < this . navItem url = "/consultancy/" active = { pathname . startsWith ( "/consultancy/" ) } > Hire Me</ this . navItem >
160
-
161
- < NavSpacer />
162
-
163
- < this . navItem url = "https://mastodon.social/@alexwilson" rel = 'me' > < Icon src = "/svg/mastodon.svg" title = "Mastodon" /> </ this . navItem >
164
- < this . navItem url = "https://twitter.com/alexwilsonv1" rel = 'me' > < Icon src = "/svg/twitter.svg" title = "Twitter" /> </ this . navItem >
165
- < this . navItem url = "https://www.linkedin.com/in/alex-/" rel = 'me' > < Icon src = "/svg/linkedin.svg" title = "LinkedIn" /> </ this . navItem >
166
- < this . navItem url = "https://github.com/alexwilson" rel = 'me' > < Icon src = "/svg/github.svg" title = "Github" /> </ this . navItem >
167
- </ ul >
142
+ < a
143
+ className = "alex-header__menu-button" role = "button"
144
+ aria-pressed = { this . state . navigationExpanded }
145
+ onClick = { ( ) => {
146
+ this . setState ( {
147
+ navigationExpanded : ! this . state . navigationExpanded
148
+ } )
149
+ } }
150
+ >
151
+ < span > </ span >
152
+ < span > </ span >
153
+ < span > </ span >
154
+ </ a >
155
+ < ul className = "alex-header__nav" id = "menu" aria-expanded = { this . state . navigationExpanded } >
156
+ < this . navItem url = "/" active = { pathname === "/" } > Home</ this . navItem >
157
+ < this . navItem url = "/about-me/" active = { pathname . startsWith ( "/about-me/" ) } > About Me</ this . navItem >
158
+ < this . navItem url = "/blog/" active = { pathname . startsWith ( "/blog/" ) || pathname . startsWith ( "/content/" ) } > Writing</ this . navItem >
159
+ < this . navItem url = "/talks/" active = { pathname . startsWith ( "/talks/" ) } > Speaking</ this . navItem >
160
+ < this . navItem url = "/consultancy/" active = { pathname . startsWith ( "/consultancy/" ) } > Hire Me</ this . navItem >
161
+
162
+ < NavSpacer />
163
+
164
+ < this . navItem url = "https://mastodon.social/@alexwilson" rel = 'me' > < Icon src = "/svg/mastodon.svg" title = "Mastodon" /> </ this . navItem >
165
+ < this . navItem url = "https://twitter.com/alexwilsonv1" rel = 'me' > < Icon src = "/svg/twitter.svg" title = "Twitter" /> </ this . navItem >
166
+ < this . navItem url = "https://www.linkedin.com/in/alex-/" rel = 'me' > < Icon src = "/svg/linkedin.svg" title = "LinkedIn" /> </ this . navItem >
167
+ < this . navItem url = "https://github.com/alexwilson" rel = 'me' > < Icon src = "/svg/github.svg" title = "Github" /> </ this . navItem >
168
+ </ ul >
168
169
</ nav >
169
170
170
- </ div >
171
- </ header > )
171
+ </ div >
172
+ </ header > )
172
173
}
173
174
}
174
175
175
176
Header . propTypes = {
176
177
siteTitle : PropTypes . string ,
177
178
image : PropTypes . string ,
179
+ location : PropTypes . object
178
180
}
179
181
180
182
Header . defaultProps = {
181
183
siteTitle : `Alex Wilson` ,
182
184
image : null ,
185
+ location : { pathname : "/" }
183
186
}
184
187
185
188
export default Header
0 commit comments