-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
23 lines (23 loc) · 1.52 KB
/
script.js
File metadata and controls
23 lines (23 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function copyCommand() {
const command = document.querySelector('.cmd').dataset.cmd;
navigator.clipboard.writeText('npm ' + command)
.then(() => {
const copyBtn = document.querySelector('.copy_toggle');
copyBtn.innerHTML = `
<svg width="16px" height="16px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 5H7C5.89543 5 5 5.89543 5 7V19C5 20.1046 5.89543 21 7 21H17C18.1046 21 19 20.1046 19 19V7C19 5.89543 18.1046 5 17 5H15" stroke="#bbfdfe" stroke-width="2"/>
<path d="M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z" stroke="#bbfdfe" stroke-width="2"/>
<path d="M9 12L11 14L15 10" stroke="#bbfdfe" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`;
setTimeout(() => {
copyBtn.innerHTML = `
<svg width="16px" height="16px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9 5H7C5.89543 5 5 5.89543 5 7V19C5 20.1046 5.89543 21 7 21H17C18.1046 21 19 20.1046 19 19V7C19 5.89543 18.1046 5 17 5H15" stroke="currentColor" stroke-width="2"/>
<path d="M9 3m0 2a2 2 0 0 1 2 -2h2a2 2 0 0 1 2 2v0a2 2 0 0 1 -2 2h-2a2 2 0 0 1 -2 -2z" stroke="currentColor" stroke-width="2"/>
</svg>
`;
}, 2000);
})
.catch(err => console.error('Failed to copy!', err));
}