blob: a0b6e646c305741e2313f8c55a70cea766b79460 (
plain)
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
|
import React, { Component } from 'react'
import './landscape.warning.css'
import { isMobile } from 'app/utils'
import { LastMuseumLogoNoBlur } from '../icons'
const PhoneIcon = (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" className="phone-icon">
<path d="M15.5 1h-8C6.12 1 5 2.12 5 3.5v17C5 21.88 6.12 23 7.5 23h8c1.38 0 2.5-1.12 2.5-2.5v-17C18 2.12 16.88 1 15.5 1zm-4 21c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm4.5-4H7V4h9v14z"/>
</svg>
)
const RotateIcon = (
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" className="rotate-icon">
<path d="M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7l-3.6 3.6z"/>
</svg>
)
export default class LandscapeWarning extends Component {
state = {
landscape: !isMobile || window.innerWidth > window.innerHeight,
}
constructor(props) {
super(props)
this.handleResize = this.handleResize.bind(this)
if (isMobile) {
window.addEventListener("resize", this.handleResize)
setTimeout(this.handleResize, 100)
}
}
handleResize() {
const landscape = !isMobile || window.innerWidth > window.innerHeight
if (landscape !== this.state.landscape) {
this.setState({ landscape })
}
}
render() {
const { landscape } = this.state
if (landscape) return null
return (
<div className="landscape-warning">
{RotateIcon}
{PhoneIcon}
{LastMuseumLogoNoBlur}
<div className="landscape-message">{'Please rotate your device'}</div>
</div>
)
}
}
|