Compare commits

..

1 Commits

Author SHA1 Message Date
user
668d967a5c feat: add copy-flash visual feedback on click-to-copy
All checks were successful
check / check (push) Successful in 9s
When a user clicks to copy text (addresses, tx hashes, etc.), the copied
element now briefly flashes with inverted colors (bg/fg swap) and fades
back over ~300ms. This provides localized visual feedback in addition to
the existing flash message.

Applied to all click-to-copy elements across all views.

closes #100
2026-02-28 15:55:57 -08:00
9 changed files with 54 additions and 61 deletions

View File

@@ -15,22 +15,20 @@
--color-section: #dddddd;
}
@keyframes copy-flash {
0% {
background-color: var(--color-fg);
color: var(--color-bg);
}
100% {
background-color: transparent;
color: inherit;
}
}
.copy-flash {
animation: copy-flash 500ms ease-out;
}
body {
width: 396px;
overflow-x: hidden;
}
/* Copy-flash feedback: inverts colors then fades back */
.copy-flash-active {
background-color: var(--color-fg) !important;
color: var(--color-bg) !important;
transition: none;
}
.copy-flash-fade {
transition:
background-color 300ms ease-out,
color 300ms ease-out;
}

View File

@@ -2,7 +2,7 @@ const {
$,
showView,
showFlash,
flashCopyElement,
flashCopyFeedback,
balanceLinesForAddress,
addressDotHtml,
addressTitle,
@@ -238,12 +238,11 @@ function renderTransactions(txs) {
function init(_ctx) {
ctx = _ctx;
$("address-full").addEventListener("click", () => {
const el = $("address-full");
const addr = el.dataset.full;
const addr = $("address-full").dataset.full;
if (addr) {
navigator.clipboard.writeText(addr);
flashCopyElement(el);
showFlash("Copied!");
flashCopyFeedback($("address-full"));
}
});
@@ -357,22 +356,20 @@ function init(_ctx) {
});
$("export-privkey-value").addEventListener("click", () => {
const el = $("export-privkey-value");
const key = el.textContent;
const key = $("export-privkey-value").textContent;
if (key) {
navigator.clipboard.writeText(key);
flashCopyElement(el);
showFlash("Copied!");
flashCopyFeedback($("export-privkey-value"));
}
});
$("export-privkey-address").addEventListener("click", () => {
const el = $("export-privkey-address");
const full = el.dataset.full;
const full = $("export-privkey-address").dataset.full;
if (full) {
navigator.clipboard.writeText(full);
flashCopyElement(el);
showFlash("Copied!");
flashCopyFeedback($("export-privkey-address"));
}
});

View File

@@ -5,7 +5,7 @@ const {
$,
showView,
showFlash,
flashCopyElement,
flashCopyFeedback,
addressDotHtml,
addressTitle,
escapeHtml,
@@ -314,12 +314,11 @@ function renderTransactions(txs) {
function init(_ctx) {
ctx = _ctx;
$("address-token-full").addEventListener("click", () => {
const el = $("address-token-full");
const addr = el.dataset.full;
const addr = $("address-token-full").dataset.full;
if (addr) {
navigator.clipboard.writeText(addr);
flashCopyElement(el);
showFlash("Copied!");
flashCopyFeedback($("address-token-full"));
}
});
@@ -327,8 +326,8 @@ function init(_ctx) {
const copyEl = e.target.closest("[data-copy]");
if (copyEl) {
navigator.clipboard.writeText(copyEl.dataset.copy);
flashCopyElement(copyEl);
showFlash("Copied!");
flashCopyFeedback(copyEl);
}
});
@@ -376,8 +375,8 @@ function init(_ctx) {
if (copyEl) {
copyEl.addEventListener("click", () => {
navigator.clipboard.writeText(copyEl.dataset.copy);
flashCopyElement(copyEl);
showFlash("Copied!");
flashCopyFeedback(copyEl);
});
}
updateSendBalance();

View File

@@ -15,7 +15,7 @@ const {
hideError,
showView,
showFlash,
flashCopyElement,
flashCopyFeedback,
addressTitle,
addressDotHtml,
escapeHtml,
@@ -117,8 +117,8 @@ function show(txInfo) {
if (copyEl) {
copyEl.onclick = () => {
navigator.clipboard.writeText(copyEl.dataset.copy);
flashCopyElement(copyEl);
showFlash("Copied!");
flashCopyFeedback(copyEl);
};
}
} else {

View File

@@ -76,18 +76,6 @@ function clearFlash() {
$("flash-msg").textContent = "";
}
function flashCopyElement(el) {
el.classList.remove("copy-flash");
// Force reflow so re-adding the class restarts the animation.
void el.offsetWidth;
el.classList.add("copy-flash");
el.addEventListener(
"animationend",
() => el.classList.remove("copy-flash"),
{ once: true },
);
}
function showFlash(msg, duration = 2000) {
clearFlash();
$("flash-msg").textContent = msg;
@@ -271,13 +259,26 @@ function timeAgo(timestamp) {
return years + " year" + (years !== 1 ? "s" : "") + " ago";
}
function flashCopyFeedback(el) {
if (!el) return;
el.classList.remove("copy-flash-fade");
el.classList.add("copy-flash-active");
setTimeout(() => {
el.classList.remove("copy-flash-active");
el.classList.add("copy-flash-fade");
setTimeout(() => {
el.classList.remove("copy-flash-fade");
}, 350);
}, 100);
}
module.exports = {
$,
showError,
hideError,
showView,
showFlash,
flashCopyElement,
flashCopyFeedback,
balanceLine,
balanceLinesForAddress,
addressColor,

View File

@@ -2,7 +2,7 @@ const {
$,
showView,
showFlash,
flashCopyElement,
flashCopyFeedback,
balanceLinesForAddress,
isoDate,
timeAgo,
@@ -88,8 +88,8 @@ function renderActiveAddress() {
`<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
$("active-addr-copy").addEventListener("click", (e) => {
navigator.clipboard.writeText(addr);
flashCopyElement(e.currentTarget);
showFlash("Copied!");
flashCopyFeedback(e.currentTarget);
});
} else {
el.textContent = "";

View File

@@ -2,7 +2,7 @@ const {
$,
showView,
showFlash,
flashCopyElement,
flashCopyFeedback,
formatAddressHtml,
addressTitle,
} = require("./helpers");
@@ -61,23 +61,21 @@ function show() {
}
function init(ctx) {
$("receive-address-block").addEventListener("click", () => {
const el = $("receive-address-block");
const addr = el.dataset.full;
$("receive-address-block").addEventListener("click", (e) => {
const addr = $("receive-address-block").dataset.full;
if (addr) {
navigator.clipboard.writeText(addr);
flashCopyElement(el);
showFlash("Copied!");
flashCopyFeedback(e.currentTarget);
}
});
$("btn-receive-copy").addEventListener("click", () => {
const block = $("receive-address-block");
const addr = block.dataset.full;
const addr = $("receive-address-block").dataset.full;
if (addr) {
navigator.clipboard.writeText(addr);
flashCopyElement(block);
showFlash("Copied!");
flashCopyFeedback($("receive-address-block"));
}
});

View File

@@ -5,7 +5,7 @@ const {
$,
showView,
showFlash,
flashCopyElement,
flashCopyFeedback,
addressDotHtml,
addressTitle,
escapeHtml,
@@ -171,8 +171,8 @@ function render() {
.forEach((el) => {
el.onclick = () => {
navigator.clipboard.writeText(el.dataset.copy);
flashCopyElement(el);
showFlash("Copied!");
flashCopyFeedback(el);
};
});
}
@@ -249,8 +249,8 @@ async function loadCalldata(txHash, toAddress) {
container.querySelectorAll("[data-copy]").forEach((el) => {
el.onclick = () => {
navigator.clipboard.writeText(el.dataset.copy);
flashCopyElement(el);
showFlash("Copied!");
flashCopyFeedback(el);
};
});
}

View File

@@ -4,7 +4,7 @@ const {
$,
showView,
showFlash,
flashCopyElement,
flashCopyFeedback,
addressDotHtml,
addressTitle,
escapeHtml,
@@ -77,8 +77,8 @@ function attachCopyHandlers(viewId) {
.forEach((el) => {
el.onclick = () => {
navigator.clipboard.writeText(el.dataset.copy);
flashCopyElement(el);
showFlash("Copied!");
flashCopyFeedback(el);
};
});
}