UNPKG

my-button-sdk

Version:

A simple Button SDK that works in all front-end stacks.

37 lines (31 loc) 1.03 kB
// ButtonSDK - A Simple Button Generator class ButtonSDK { constructor(apiKey, label, callback) { this.apiKey = apiKey; this.label = label || "Click Me"; this.callback = callback || function () {}; } render(targetElement) { var container = document.querySelector(targetElement); if (!container) { console.error("[ButtonSDK] Target element '" + targetElement + "' not found."); return; } var button = document.createElement("button"); button.innerText = this.label; button.style.padding = "10px 20px"; button.style.fontSize = "16px"; button.style.borderRadius = "5px"; button.style.cursor = "pointer"; button.style.backgroundColor = "#007BFF"; button.style.color = "#fff"; button.style.border = "none"; button.onclick = () => { console.log("[ButtonSDK] API Key:", this.apiKey); this.callback(); }; container.appendChild(button); } } // Export ButtonSDK as a module export default ButtonSDK;