@nibgate/sdk 0.2.29 → 0.2.31
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/dist/nibgate.js +21 -13
- package/dist/nibgate.js.map +2 -2
- package/dist/nibgate.min.js +10 -10
- package/dist/nibgate.min.js.map +3 -3
- package/package.json +1 -1
- package/src/browser/default-ui.js +21 -10
package/package.json
CHANGED
|
@@ -81,7 +81,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
81
81
|
<div id="nibgate-lottie" style="width:165px;height:168px;margin-bottom:24px"></div>
|
|
82
82
|
<div style="font-size:50px;font-weight:700;letter-spacing:-.03em;color:${theme.fg};margin-bottom:12px">${esc(resource.price)} USDC</div>
|
|
83
83
|
<div style="font-size:21px;color:${theme.muted};margin-bottom:48px">Pay to unlock this content</div>
|
|
84
|
-
<div data-nibgate-wallet-label class="nui-mono" style="font-size:18px;color:${theme.muted};margin-bottom:40px;min-height:28px">Connect wallet
|
|
84
|
+
<div data-nibgate-wallet-label class="nui-mono" style="font-size:18px;color:${theme.muted};margin-bottom:40px;min-height:28px">Connect wallet <span data-nibgate-bal style="display:none"><span data-nibgate-bal-txt></span></span></div>
|
|
85
85
|
<div data-nibgate-unlock-wrap style="width:100%;position:relative;border-radius:10px;overflow:hidden;cursor:pointer">
|
|
86
86
|
<div data-nibgate-unlock-progress style="position:absolute;inset:0;width:0%;background:${theme.accent};opacity:0.15;border-radius:10px;transition:width .05s linear;z-index:2"></div>
|
|
87
87
|
<button type="button" data-nibgate-unlock disabled style="width:100%;padding:14px 0;font-size:17px;font-weight:600;line-height:1;border:0;border-radius:10px;outline:none;cursor:pointer;position:relative;z-index:4;color:#fff;background:${theme.accent};transition:box-shadow .3s,transform .3s;font-family:inherit;display:flex;align-items:center;justify-content:center">${unlockSVG}Hold to pay</button></div>
|
|
@@ -149,12 +149,19 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
149
149
|
|
|
150
150
|
function updateLabel() {
|
|
151
151
|
const addr = ctrl.getWalletAddress();
|
|
152
|
+
// Clear all children, keep text nodes
|
|
153
|
+
while (label.firstChild) label.removeChild(label.firstChild);
|
|
152
154
|
if (addr) {
|
|
153
|
-
label.
|
|
155
|
+
label.appendChild(document.createTextNode(shortAddress(addr) + ' '));
|
|
156
|
+
const dc = el('span', { 'data-nibgate-disconnect': '', style: 'cursor:pointer' }, '\u00b7 Disconnect');
|
|
157
|
+
dc.addEventListener('click', (e) => { if (e.target.dataset.nibgateDisconnect !== undefined) ctrl.disconnect().then(updateLabel); });
|
|
158
|
+
label.appendChild(dc);
|
|
159
|
+
// Re-add balance element if it exists
|
|
160
|
+
if (balEl?.isConnected) label.appendChild(balEl);
|
|
154
161
|
btn.disabled = false;
|
|
155
162
|
btn.style.cursor = 'pointer';
|
|
156
163
|
} else {
|
|
157
|
-
label.
|
|
164
|
+
label.appendChild(document.createTextNode('Connect wallet'));
|
|
158
165
|
btn.disabled = true;
|
|
159
166
|
btn.style.cursor = 'default';
|
|
160
167
|
btn.innerHTML = unlockSVG + 'Hold to pay';
|
|
@@ -206,9 +213,7 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
206
213
|
}
|
|
207
214
|
|
|
208
215
|
label.addEventListener('click', (e) => {
|
|
209
|
-
if (
|
|
210
|
-
ctrl.disconnect().then(updateLabel);
|
|
211
|
-
} else if (!ctrl.getWalletAddress()) {
|
|
216
|
+
if (!ctrl.getWalletAddress()) {
|
|
212
217
|
ctrl.connect().then(updateLabel).catch(() => updateLabel());
|
|
213
218
|
}
|
|
214
219
|
});
|
|
@@ -248,10 +253,16 @@ export function renderDefaultUnlockUI(container, resource, options = {}) {
|
|
|
248
253
|
|
|
249
254
|
function ensureBal() {
|
|
250
255
|
if (balEl && balEl.isConnected) return balEl;
|
|
251
|
-
balEl =
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
256
|
+
balEl = label.querySelector('[data-nibgate-bal]');
|
|
257
|
+
if (balEl) {
|
|
258
|
+
balEl.style.display = '';
|
|
259
|
+
balEl.style.marginLeft = '4px';
|
|
260
|
+
balEl.style.cursor = 'pointer';
|
|
261
|
+
balEl.style.whiteSpace = 'nowrap';
|
|
262
|
+
balEl.style.color = 'var(--accent,#7c9a6d)';
|
|
263
|
+
balEl.innerHTML = '\u00b7\u00a0<span data-nibgate-bal-txt></span>\u00a0|\u00a0' + depIcon();
|
|
264
|
+
balEl.addEventListener('click', showDeposit);
|
|
265
|
+
}
|
|
255
266
|
return balEl;
|
|
256
267
|
}
|
|
257
268
|
|