-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbottom.jsx
More file actions
executable file
·101 lines (92 loc) · 2.71 KB
/
Copy pathbottom.jsx
File metadata and controls
executable file
·101 lines (92 loc) · 2.71 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"use client";
import React, { useEffect, useState } from "react";
import { FaChevronUp, FaChevronDown } from "react-icons/fa";
const BottomAd = () => {
const [isClient, setIsClient] = useState(false);
const [minimized, setMinimized] = useState(false);
useEffect(() => {
setIsClient(true);
if (typeof window !== "undefined") {
// Load AdSense script once
const scriptId = "adsbygoogle-js";
if (!document.getElementById(scriptId)) {
const script = document.createElement("script");
script.id = scriptId;
script.async = true;
script.src =
"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-4311738896428559";
script.crossOrigin = "anonymous";
document.head.appendChild(script);
}
}
}, []);
useEffect(() => {
if (isClient) {
try {
(window.adsbygoogle = window.adsbygoogle || []).push({});
} catch (e) {
console.warn("AdSense error:", e);
}
}
}, [isClient]);
if (!isClient) return null;
// Detect environment for test ads
const isDev =
window.location.hostname === "localhost" ||
window.location.hostname === "127.0.0.1";
return (
<div
style={{
position: "fixed",
bottom: 0,
left: 0,
width: "100%",
background: "#fff",
boxShadow: "0 -2px 8px rgba(0,0,0,0.1)",
zIndex: 9999,
transition: "height 0.3s ease",
height: minimized ? "36px" : "100px",
overflow: "hidden",
textAlign: "center",
padding: minimized ? "0" : "4px 0",
}}
>
<button
onClick={() => setMinimized(!minimized)}
style={{
position: "absolute",
right: "8px",
top: "4px",
background: "transparent",
border: "none",
fontSize: "16px",
cursor: "pointer",
color: "#444",
display: "flex",
alignItems: "center",
justifyContent: "center",
}}
aria-label={minimized ? "Expand Ad" : "Minimize Ad"}
>
{minimized ? <FaChevronUp /> : <FaChevronDown />}
</button>
{minimized ? (
<div style={{ fontSize: "13px", padding: "6px", color: "#555" }}>
Ad minimized — click ▲ to reopen
</div>
) : (
<ins
className="adsbygoogle"
style={{ display: "block", height: "100px" }}
data-ad-client={
isDev ? "ca-pub-3940256099942544" : "ca-pub-4311738896428559"
}
data-ad-slot={isDev ? "6300978111" : "2048540881"}
data-ad-format="auto"
data-full-width-responsive="true"
></ins>
)}
</div>
);
};
export default BottomAd;