Skip to content

Commit 4f2344f

Browse files
committed
wip
1 parent 25e9150 commit 4f2344f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

components/APISourceToggle.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// Borrowed from: https://dev.to/murtuzaalisurti/dark-mode-toggle-animation-using-css-27il
2+
import React from "react";
3+
4+
const DarkModeToggle: React.FC<{ isDarkModeOn: boolean }> = ({
5+
isDarkModeOn,
6+
}) => {
7+
// React.useEffect(() => {
8+
// if (isDarkModeOn) {
9+
// document.querySelector(".sun-logo").classList.remove("animate-sun");
10+
// document.querySelector(".moon-logo").classList.remove("animate-moon");
11+
// } else {
12+
// document.querySelector(".sun-logo").classList.add("animate-sun");
13+
// document.querySelector(".moon-logo").classList.add("animate-moon");
14+
// }
15+
// }, [isDarkModeOn]);
16+
return (
17+
<div className="container p-1 rounded flex items-center justify-center">
18+
<div className="sun sun-logo flex items-center justify-center">
19+
<svg viewBox="0 0 512 512" width="16">
20+
<path
21+
d="M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z"
22+
fill="#FFF"
23+
/>
24+
</svg>
25+
</div>
26+
<div className="moon moon-logo flex items-center justify-center">
27+
<svg viewBox="0 0 512 512" width="16" className="z-1">
28+
<path
29+
d="M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z"
30+
stroke="#000"
31+
fill="#000"
32+
/>
33+
</svg>
34+
</div>
35+
</div>
36+
);
37+
};
38+
39+
export default DarkModeToggle;

0 commit comments

Comments
 (0)