-
Notifications
You must be signed in to change notification settings - Fork 200
Expand file tree
/
Copy pathFooter.jsx
More file actions
77 lines (71 loc) · 1.84 KB
/
Footer.jsx
File metadata and controls
77 lines (71 loc) · 1.84 KB
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
import React, { useState, useEffect } from "react";
import heartBeat from "./heart-beat.wav";
import typingSound from "./typing-sound.wav";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faCode } from "@fortawesome/free-solid-svg-icons";
import styles from "./Footer.module.css";
const Footer = () => {
const [isMobile, setIsMobile] = useState(window.innerWidth < 640);
const heartAudio = new Audio(heartBeat);
const typingAudio = new Audio(typingSound);
useEffect(() => {
function handleSize() {
setIsMobile(window.innerWidth < 640);
}
window.addEventListener("resize", handleSize);
return () => {
window.removeEventListener("resize", handleSize);
};
}, []);
const playHeartbeat = () => {
heartAudio.play();
};
const stopHeartbeat = () => {
if (heartAudio) {
heartAudio.pause();
}
};
const playTypingSound = () => {
typingAudio.play();
};
const stopTypingSound = () => {
if (typingAudio) {
typingAudio.pause();
}
};
return (
<footer className={styles["footer"]}>
<p className={styles["footer-message"]}>
<span
onMouseEnter={playTypingSound}
onMouseLeave={stopTypingSound}
>
<FontAwesomeIcon
icon={faCode}
style={{ color: "#feea3a" }}
title="Click me!"
/>
</span>{" "}
with{" "}
<span
className={styles["emoji"]}
role="img"
aria-label="heart"
onMouseEnter={playHeartbeat}
onMouseLeave={stopHeartbeat}
>
💙
</span>{" "}
{isMobile && <br />}
by the{" "}
<a
className={styles["footer-message-link"]}
href="https://github.com/BeforeIDieCode"
>
Before I Die Community
</a>
</p>
</footer>
);
};
export default Footer;