Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ef6087b

Browse files
committed
fix: check icon not showing when copy btn clicked
1 parent dd8127e commit ef6087b

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

‎src/popup/popup.css

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ body {
4040
background-color: var(--background-color);
4141
font-size: calc(var(--font-size-base) * var(--scale-factor));
4242
font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', Oxygen, Ubuntu, sans-serif;
43-
padding: 0 calc(20px * var(--scale-factor));
43+
padding: calc(25px*var(--scale-factor)) calc(20px * var(--scale-factor));
4444
width: calc(400px * var(--scale-factor));
4545
margin: 0;
4646
line-height: 1.5;
@@ -298,9 +298,10 @@ pre[class*="language-"] {
298298
}
299299

300300
#clear-code-btn {
301-
margin-left: calc(10px * var(--scale-factor));
301+
margin-left: calc(5px * var(--scale-factor));
302302
}
303303

304+
304305
/* Settings */
305306
#settings-icon {
306307
width: calc(24px * var(--scale-factor));
@@ -326,6 +327,7 @@ pre[class*="language-"] {
326327

327328
#settings-menu {
328329
text-align: center;
330+
padding: calc(15px * var(--scale-factor)) 0;
329331
}
330332

331333
.video-container {

‎src/popup/popup.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Add code to highlight response after it's displayed
2+
document.addEventListener('DOMContentLoaded', function() {
3+
// Function to make the response visible and highlighted
4+
function watchForResponseContent() {
5+
const responseElement = document.getElementById('analyze-code-response');
6+
if (responseElement) {
7+
// Create a MutationObserver to detect when content is added
8+
const observer = new MutationObserver(function(mutations) {
9+
mutations.forEach(function(mutation) {
10+
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
11+
// Make sure the element is visible by removing the 'hidden' class
12+
responseElement.classList.remove('hidden');
13+
}
14+
});
15+
});
16+
17+
// Start observing the response element
18+
observer.observe(responseElement, { childList: true, subtree: true });
19+
}
20+
}
21+
22+
watchForResponseContent();
23+
});

‎src/popup/popup.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,17 @@ function initCopyButton(): void {
307307
const copyButton = elements['copyCodeBtn'];
308308
if (!copyButton) return;
309309
copyButton.onclick = async () => {
310-
setInfoMessage('Copied Code', 3000);
311-
// change icon to check-icon.png
312-
copyButton
310+
setInfoMessage('Copied Code', 1000);
311+
// Change icon to check-icon.png
312+
const copyButtonImg = copyButton.querySelector('img');
313+
if (copyButtonImg) {
314+
copyButtonImg.src = '../assets/images/check-icon.png';
315+
// After 1 second, change the icon back to the copy icon
316+
setTimeout(() => {
317+
copyButtonImg.src = '../assets/images/copy-icon.png';
318+
}, 1000);
319+
}
320+
313321
if (fixCodeResponse && fixCodeResponse.textContent) {
314322
await navigator.clipboard.writeText(fixCodeResponse.textContent);
315323
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /