Merge pull request 'feat: add copy-flash visual feedback — closes #100' (#113) from fix/issue-100-copy-flash-feedback into main
All checks were successful
check / check (push) Successful in 21s
All checks were successful
check / check (push) Successful in 21s
Reviewed-on: #113
This commit was merged in pull request #113.
This commit is contained in:
@@ -19,3 +19,16 @@ body {
|
|||||||
width: 396px;
|
width: 396px;
|
||||||
overflow-x: hidden;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyFeedback,
|
||||||
balanceLinesForAddress,
|
balanceLinesForAddress,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
@@ -241,6 +242,7 @@ function init(_ctx) {
|
|||||||
if (addr) {
|
if (addr) {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback($("address-full"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -358,6 +360,7 @@ function init(_ctx) {
|
|||||||
if (key) {
|
if (key) {
|
||||||
navigator.clipboard.writeText(key);
|
navigator.clipboard.writeText(key);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback($("export-privkey-value"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -366,6 +369,7 @@ function init(_ctx) {
|
|||||||
if (full) {
|
if (full) {
|
||||||
navigator.clipboard.writeText(full);
|
navigator.clipboard.writeText(full);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback($("export-privkey-address"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyFeedback,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
@@ -317,6 +318,7 @@ function init(_ctx) {
|
|||||||
if (addr) {
|
if (addr) {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback($("address-token-full"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -325,6 +327,7 @@ function init(_ctx) {
|
|||||||
if (copyEl) {
|
if (copyEl) {
|
||||||
navigator.clipboard.writeText(copyEl.dataset.copy);
|
navigator.clipboard.writeText(copyEl.dataset.copy);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback(copyEl);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -373,6 +376,7 @@ function init(_ctx) {
|
|||||||
copyEl.addEventListener("click", () => {
|
copyEl.addEventListener("click", () => {
|
||||||
navigator.clipboard.writeText(copyEl.dataset.copy);
|
navigator.clipboard.writeText(copyEl.dataset.copy);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback(copyEl);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
updateSendBalance();
|
updateSendBalance();
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const {
|
|||||||
hideError,
|
hideError,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyFeedback,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
@@ -117,6 +118,7 @@ function show(txInfo) {
|
|||||||
copyEl.onclick = () => {
|
copyEl.onclick = () => {
|
||||||
navigator.clipboard.writeText(copyEl.dataset.copy);
|
navigator.clipboard.writeText(copyEl.dataset.copy);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback(copyEl);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -258,12 +258,26 @@ function timeAgo(timestamp) {
|
|||||||
return years + " year" + (years !== 1 ? "s" : "") + " ago";
|
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 = {
|
module.exports = {
|
||||||
$,
|
$,
|
||||||
showError,
|
showError,
|
||||||
hideError,
|
hideError,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyFeedback,
|
||||||
balanceLine,
|
balanceLine,
|
||||||
balanceLinesForAddress,
|
balanceLinesForAddress,
|
||||||
addressColor,
|
addressColor,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyFeedback,
|
||||||
balanceLinesForAddress,
|
balanceLinesForAddress,
|
||||||
isoDate,
|
isoDate,
|
||||||
timeAgo,
|
timeAgo,
|
||||||
@@ -85,9 +86,10 @@ function renderActiveAddress() {
|
|||||||
el.innerHTML =
|
el.innerHTML =
|
||||||
`<span class="underline decoration-dashed cursor-pointer" id="active-addr-copy">${dot}${escapeHtml(addr)}</span>` +
|
`<span class="underline decoration-dashed cursor-pointer" id="active-addr-copy">${dot}${escapeHtml(addr)}</span>` +
|
||||||
`<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
`<a href="${link}" target="_blank" rel="noopener" class="inline-flex items-center">${EXT_ICON}</a>`;
|
||||||
$("active-addr-copy").addEventListener("click", () => {
|
$("active-addr-copy").addEventListener("click", (e) => {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback(e.currentTarget);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
el.textContent = "";
|
el.textContent = "";
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyFeedback,
|
||||||
formatAddressHtml,
|
formatAddressHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
} = require("./helpers");
|
} = require("./helpers");
|
||||||
@@ -60,11 +61,12 @@ function show() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init(ctx) {
|
function init(ctx) {
|
||||||
$("receive-address-block").addEventListener("click", () => {
|
$("receive-address-block").addEventListener("click", (e) => {
|
||||||
const addr = $("receive-address-block").dataset.full;
|
const addr = $("receive-address-block").dataset.full;
|
||||||
if (addr) {
|
if (addr) {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback(e.currentTarget);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -73,6 +75,7 @@ function init(ctx) {
|
|||||||
if (addr) {
|
if (addr) {
|
||||||
navigator.clipboard.writeText(addr);
|
navigator.clipboard.writeText(addr);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback($("receive-address-block"));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyFeedback,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
@@ -171,6 +172,7 @@ function render() {
|
|||||||
el.onclick = () => {
|
el.onclick = () => {
|
||||||
navigator.clipboard.writeText(el.dataset.copy);
|
navigator.clipboard.writeText(el.dataset.copy);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback(el);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -248,6 +250,7 @@ async function loadCalldata(txHash, toAddress) {
|
|||||||
el.onclick = () => {
|
el.onclick = () => {
|
||||||
navigator.clipboard.writeText(el.dataset.copy);
|
navigator.clipboard.writeText(el.dataset.copy);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback(el);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ const {
|
|||||||
$,
|
$,
|
||||||
showView,
|
showView,
|
||||||
showFlash,
|
showFlash,
|
||||||
|
flashCopyFeedback,
|
||||||
addressDotHtml,
|
addressDotHtml,
|
||||||
addressTitle,
|
addressTitle,
|
||||||
escapeHtml,
|
escapeHtml,
|
||||||
@@ -77,6 +78,7 @@ function attachCopyHandlers(viewId) {
|
|||||||
el.onclick = () => {
|
el.onclick = () => {
|
||||||
navigator.clipboard.writeText(el.dataset.copy);
|
navigator.clipboard.writeText(el.dataset.copy);
|
||||||
showFlash("Copied!");
|
showFlash("Copied!");
|
||||||
|
flashCopyFeedback(el);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user