bags-button 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -0
- package/package.json +10 -0
- package/src/index.js +25 -0
- package/src/modal.js +39 -0
- package/test.html +28 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# bags-button
|
|
2
|
+
|
|
3
|
+
Embed Bags token buy buttons into any website.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
npm install bags-button
|
|
8
|
+
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
<button data-bags-buy data-token="TOKEN_ADDRESS">
|
|
12
|
+
Buy Token
|
|
13
|
+
</button>
|
|
14
|
+
|
|
15
|
+
import { initBagsButtons } from "bags-button"
|
|
16
|
+
|
|
17
|
+
initBagsButtons()
|
package/package.json
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { openModal } from "./modal.js";
|
|
2
|
+
|
|
3
|
+
export function initBagsButtons() {
|
|
4
|
+
|
|
5
|
+
console.log("bags-button initialized");
|
|
6
|
+
|
|
7
|
+
const buttons = document.querySelectorAll("[data-bags-buy]");
|
|
8
|
+
|
|
9
|
+
console.log("Buttons found:", buttons.length);
|
|
10
|
+
|
|
11
|
+
buttons.forEach((btn) => {
|
|
12
|
+
|
|
13
|
+
btn.addEventListener("click", () => {
|
|
14
|
+
|
|
15
|
+
console.log("Button clicked");
|
|
16
|
+
|
|
17
|
+
const token = btn.getAttribute("data-token");
|
|
18
|
+
|
|
19
|
+
openModal(token);
|
|
20
|
+
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
}
|
package/src/modal.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export function openModal(token) {
|
|
2
|
+
|
|
3
|
+
console.log("Opening modal for:", token);
|
|
4
|
+
|
|
5
|
+
const modal = document.createElement("div");
|
|
6
|
+
|
|
7
|
+
modal.innerHTML = `
|
|
8
|
+
<div style="
|
|
9
|
+
position:fixed;
|
|
10
|
+
inset:0;
|
|
11
|
+
background:rgba(0,0,0,0.6);
|
|
12
|
+
display:flex;
|
|
13
|
+
align-items:center;
|
|
14
|
+
justify-content:center;
|
|
15
|
+
z-index:9999">
|
|
16
|
+
|
|
17
|
+
<div style="
|
|
18
|
+
background:white;
|
|
19
|
+
padding:20px;
|
|
20
|
+
border-radius:10px;
|
|
21
|
+
width:300px;
|
|
22
|
+
text-align:center">
|
|
23
|
+
|
|
24
|
+
<h2>Buy Token</h2>
|
|
25
|
+
<p>${token}</p>
|
|
26
|
+
|
|
27
|
+
<button id="bags-close">Close</button>
|
|
28
|
+
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
document.body.appendChild(modal);
|
|
34
|
+
|
|
35
|
+
document.getElementById("bags-close").onclick = () => {
|
|
36
|
+
modal.remove();
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
}
|
package/test.html
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
|
|
6
|
+
<script type="module">
|
|
7
|
+
|
|
8
|
+
import { initBagsButtons } from "./src/index.js";
|
|
9
|
+
|
|
10
|
+
window.onload = () => {
|
|
11
|
+
initBagsButtons();
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
</head>
|
|
17
|
+
|
|
18
|
+
<body>
|
|
19
|
+
|
|
20
|
+
<h2>Test Bags Button</h2>
|
|
21
|
+
|
|
22
|
+
<button data-bags-buy data-token="ABC123">
|
|
23
|
+
Buy Token
|
|
24
|
+
</button>
|
|
25
|
+
|
|
26
|
+
</body>
|
|
27
|
+
|
|
28
|
+
</html>
|