-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.jsx
115 lines (101 loc) · 2.95 KB
/
index.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
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
import React, { Component } from "react";
import github from "../../assets/github/GitHub-Mark-Light-32px.png";
import { Keyboard } from "@material-ui/icons";
class appFooterNav extends Component {
constructor(props) {
super(props);
this.state = {
shortcutPopupActive: false,
};
this.switchShortcutPopupActive = this.switchShortcutPopupActive.bind(this);
this.initEvents = this.initEvents.bind(this);
}
componentDidMount() {
this.initEvents();
}
componentWillUnmount() {
document.removeEventListener("closePopupShortcut");
}
initEvents() {
document.addEventListener("closePopupShortcut", () => {
this.switchShortcutPopupActive();
});
document.querySelector("body").onclick = (event) => {
if (this.state.shortcutPopupActive) {
const path = event.path;
const isClickInPopup =
path.filter((element) => {
let result = false;
if (
!!element.className &&
element.tagName !== "svg" &&
element.tagName !== "path"
) {
const elementClass = element.className.split(" ");
result =
elementClass.filter(
(item) =>
item === "footer-popup-icon" ||
item === "footer-popup-content"
).length > 0;
}
return result;
}).length > 0;
if (!isClickInPopup) {
document.dispatchEvent(new CustomEvent("closePopupShortcut"));
}
}
};
}
switchShortcutPopupActive() {
this.setState({ shortcutPopupActive: !this.state.shortcutPopupActive });
}
/**
* React Render
*/
render() {
const shortcutPopup = this.state.shortcutPopupActive ? (
<div className="popup-shortcut card card-3">
<ul className="footer-popup-content">
<li>
<span>SpaceBar</span> Pause or resume song
</li>
<li>
<span>N</span> Go to the next song
</li>
<li>
<span>B</span> Back to the previous song
</li>
</ul>
</div>
) : null;
return (
<div className="footer-nav">
<ul>
<li
className={
this.state.shortcutPopupActive ? "footer-popup-icon active" : null
}
>
<Keyboard
style={{ fontSize: "32px" }}
onClick={this.switchShortcutPopupActive}
/>
{shortcutPopup}
</li>
<li style={{ borderRadius: "12%" }}>
<div key="github-logo" data-for="githubTooltip" data-tip>
<a
href="https://github.com/danielbarion/react-player"
target="_alt"
>
<img src={github} alt="GitHub" width="32" height="32"></img>
</a>
</div>
</li>
</ul>
</div>
);
}
}
export default appFooterNav;