aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/app.js33
-rw-r--r--src/features/gifts.js2
-rw-r--r--src/i18n.js2
-rw-r--r--src/style.css1
-rw-r--r--tools/signup-quick-test.js21
5 files changed, 51 insertions, 8 deletions
diff --git a/src/app.js b/src/app.js
index e1df4e2..61e2342 100644
--- a/src/app.js
+++ b/src/app.js
@@ -5186,6 +5186,15 @@ function separateBalances() {
function setSeparateBalances(on) {
try { on ? localStorage.setItem(SEPARATE_KEY, '1') : localStorage.removeItem(SEPARATE_KEY); } catch {}
}
+// The one balance's breakdown (Ark / On-chain / Gifts) folds away under its
+// total by default (Adam, 2026-11-16); opening it is remembered per device.
+const BREAKDOWN_KEY = 'btc-wallet-balance-breakdown';
+function breakdownOpen() {
+ try { return localStorage.getItem(BREAKDOWN_KEY) === '1'; } catch { return false; }
+}
+function setBreakdownOpen(on) {
+ try { on ? localStorage.setItem(BREAKDOWN_KEY, '1') : localStorage.removeItem(BREAKDOWN_KEY); } catch {}
+}
function unifiedOn(a = activeAccount()) {
return !!a && !a.kind && a.type === 'full' && !separateBalances() && spendingActive();
}
@@ -5332,8 +5341,8 @@ function walletSide() {
h('button', { type: 'button', class: 'wallet-side-total', onClick: () => toWallet('history') },
h('span', { class: 'small muted' }, t('balance')),
h('span', { class: 'wallet-side-amount' }, wallet.loaded ? fmtAmount(spending + saving) + ' ' + unitLabel() : '…')),
- spendingActive() && (!unified || (spending > 0 && saving > 0)) ? line(unified ? t('balInstant') : t('spendingLabel'), spending) : null,
- spendingActive() && (!unified || (spending > 0 && saving > 0)) ? line(unified ? t('balOnchain') : t('savingLabel'), saving) : null,
+ spendingActive() && (!unified || (spending > 0 && saving > 0 && breakdownOpen())) ? line(unified ? t('balInstant') : t('spendingLabel'), spending) : null,
+ spendingActive() && (!unified || (spending > 0 && saving > 0 && breakdownOpen())) ? line(unified ? t('balOnchain') : t('savingLabel'), saving) : null,
h('div', { class: 'row gap6' },
h('button', { type: 'button', class: 'btn-primary grow', onClick: () => toWallet('receive') }, t('tabReceive')),
h('button', { type: 'button', class: 'btn-primary grow', onClick: () => toWallet('send') }, t('tabSend')))),
@@ -5473,11 +5482,20 @@ function balanceCard() {
// when it's in both places (instant Ark coins, on-chain coins) — and every
// line under the figure (pending, moving, locked in gifts) belongs to it.
if (unifiedOn()) {
- const split = spending > 0 && saving > 0
- ? [{ label: t('balInstant'), sat: spending }, { label: t('balOnchain'), sat: saving }] : [];
- const lines = split
+ // the breakdown (where it sits, what gifts hold) folds away behind a
+ // toggle; what's on its way (pending, moving) always shows
+ const split = (spending > 0 && saving > 0
+ ? [{ label: t('balInstant'), sat: spending }, { label: t('balOnchain'), sat: saving }] : [])
+ .concat(featLines.filter((l) => l.part));
+ const open = breakdownOpen();
+ const lines = (open ? split : [])
.concat(pending > 0 ? [{ label: t('pending'), sat: pending, cls: 'v pending' }] : [])
- .concat(featLines);
+ .concat(featLines.filter((l) => !l.part));
+ const toggle = split.length
+ ? h('button', { type: 'button', class: 'linklike small breakdown-toggle', 'aria-expanded': open ? 'true' : 'false',
+ onClick: () => { setBreakdownOpen(!open); render(); } },
+ open ? t('hideBreakdown') + ' ▴' : t('showBreakdown') + ' ▾')
+ : null;
_accDir = null;
return h('div', { class: 'card balance balance-one' },
h('div', { class: 'balance-face' },
@@ -5492,7 +5510,8 @@ function balanceCard() {
lines.length
? h('div', { class: 'split' },
...lines.map((l) => h('div', {}, h('div', { class: 'k' }, l.label), h('div', { class: l.cls || 'v' }, fmtAmount(l.sat), ' ', unitTag()))))
- : null),
+ : null,
+ toggle),
...cardExtras('spending'));
}
const carouselMode = hasSpending && !kindLocked;
diff --git a/src/features/gifts.js b/src/features/gifts.js
index 7b81fa9..30b8d5e 100644
--- a/src/features/gifts.js
+++ b/src/features/gifts.js
@@ -1096,7 +1096,7 @@ export function giftsFeature(ctx) {
balanceLines() {
const locked = wallet.giftLockedValue();
// on-chain reservations: money still in Savings, spoken for
- return locked > 0 ? [{ label: t('balGifts'), sat: locked, side: 'savings' }] : [];
+ return locked > 0 ? [{ label: t('balGifts'), sat: locked, side: 'savings', part: true }] : [];
},
historyEntries(txs, sel) {
// These are ON-CHAIN gift reservations — Savings timeline. Ark gifts show
diff --git a/src/i18n.js b/src/i18n.js
index 04119c9..db7d267 100644
--- a/src/i18n.js
+++ b/src/i18n.js
@@ -1686,6 +1686,8 @@ const STR = {
balInstant: 'Ark',
balOnchain: 'On-chain',
balGifts: 'Gifts',
+ showBreakdown: 'Breakdown',
+ hideBreakdown: 'Hide breakdown',
topUpInstant: 'Make on-chain bitcoin instant',
allSettingsDesc: 'Coins, renewals, lock, recovery phrase, public key',
separateBalances: 'Show Spending and Savings separately',
diff --git a/src/style.css b/src/style.css
index 2bbf8fc..9f2cd35 100644
--- a/src/style.css
+++ b/src/style.css
@@ -231,6 +231,7 @@ input { scroll-margin-top: 12px; }
.balance .split .k { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .04em; }
.balance .split .v { font-family: var(--mono); font-size: 14px; }
.balance .split .v.pending { color: var(--accent-ink); }
+.balance .breakdown-toggle { margin-top: 10px; color: var(--faint); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
/* ---- tabs ---- */
.page-pick { width: auto; padding: 6px 28px 6px 10px; font-size: 13px; border-radius: 9px; background-color: var(--paper); }
diff --git a/tools/signup-quick-test.js b/tools/signup-quick-test.js
index 3e38c5f..5005d6a 100644
--- a/tools/signup-quick-test.js
+++ b/tools/signup-quick-test.js
@@ -108,6 +108,27 @@ try {
await page.reload({ waitUntil: 'domcontentloaded' }); await page.waitForSelector('.balance-face', { timeout: 20000 }); await sleep(1500);
await giveBalance();
check('...and never again, not after a reload', !(await page.$('.ways-back-prompt')));
+ // the breakdown (Ark / On-chain / Gifts) folds away under the total; a
+ // gift line stands in for it here (the ark feature made to report one)
+ {
+ const protoH = await page.evaluateHandle(() => Object.prototype);
+ const all = await page.queryObjects(protoH);
+ await page.evaluate((objs) => {
+ const f = objs.find((o) => { try { return o && o.id === 'ark' && typeof o.balanceLines === 'function'; } catch { return false; } });
+ f.balanceLines = () => [{ label: 'Gifts', sat: 700, side: 'savings', part: true }];
+ document.querySelector('.tabs button')?.click(); document.querySelector('.tabs button')?.click();
+ }, all);
+ await all.dispose(); await protoH.dispose(); await sleep(600);
+ const face = () => page.evaluate(() => ({ t: document.querySelector('.balance-one')?.innerText || '', btn: document.querySelector('.balance-one .breakdown-toggle')?.textContent || '' }));
+ let f = await face();
+ check('breakdown folded by default, with a way to open it', !/GIFTS/i.test(f.t.replace(f.btn, '')) && /breakdown/i.test(f.btn), JSON.stringify(f));
+ await page.click('.balance-one .breakdown-toggle'); await sleep(400);
+ f = await face();
+ check('opened, it shows the Gifts line', /Gifts/i.test(f.t.replace(f.btn, '')) && /hide/i.test(f.btn), JSON.stringify(f));
+ if (process.env.SHOT3) await page.screenshot({ path: process.env.SHOT3 });
+ check('remembered on this device', await page.evaluate(() => localStorage.getItem('btc-wallet-balance-breakdown') === '1'));
+ await page.evaluate(() => localStorage.removeItem('btc-wallet-balance-breakdown'));
+ }
for (let i = 0; i < 60 && !(await page.$('#recv-amount')); i++) await sleep(250);
check('Receive has an Amount button', !!(await page.$('#recv-amount')));
check('no History heading on an empty wallet', !/\bHISTORY\b/.test(await page.evaluate(() => document.body.innerText)));