-
Notifications
You must be signed in to change notification settings - Fork 37
/
happybrowser.jsx
81 lines (75 loc) · 2.3 KB
/
happybrowser.jsx
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
// dependencies ------------------------------------------------------------------
import React from 'react'
import PropTypes from 'prop-types'
import bowser from 'bowser'
import chrome from './assets/chrome.jpg'
import warning from './assets/warning.jpg'
export default class Happybrowser extends React.Component {
// life cycle methods ------------------------------------------------------------
constructor(props) {
super(props)
this.state = {
hbVisible: this._incompatibleBrowser(props.ua),
}
}
render() {
if (this.state.hbVisible) {
return (
<div className="happybrowser-markup">
<div className="hb-wrap clearfix">
<div className="hb-text clearfix">
<img src={warning} alt="warning" />
<p>
We have detected that you are using an incompatible browser.
This site may not work as expected.{' '}
<strong>
<a href="http://www.google.com/chrome/">
Please consider using a minimum of Chrome V49.0 or Firefox
V50.0 as your browser
</a>.
</strong>
</p>
</div>
<div className="hb-upgrade clearfix">
<div
className="hb-img-wrap hb-dismiss"
id="dismiss"
onClick={this._dismiss.bind(this)}>
X
</div>
<div className="hb-img-wrap hb-chrome">
<a href="http://www.google.com/chrome/">
<img src={chrome} alt="upgrade chrome" />
</a>
</div>
</div>
</div>
</div>
)
} else {
return null
}
}
_incompatibleBrowser(ua) {
const check = bowser.check(
{ chrome: '49', chromium: '49', googlebot: '0', firefox: '50' },
true,
ua || window.navigator.userAgent,
)
if (
bowser.check({ chrome: '41' }, true, ua || window.navigator.userAgent)
) {
// Also allow Chrome 41 even though uploading does not work
// This is for Googlebot to index correctly
return false
}
return !check
}
_dismiss() {
let self = this
self.setState({ hbVisible: false })
}
}
Happybrowser.propTypes = {
ua: PropTypes.string,
}