Skip to content

Commit c22c20e

Browse files
authored
docs: avoid showing "Copied" if copying fails (denoland#3397)
I noticed that in denoland#3393 it looks like it's possible that the "Copied"/Check icon will be shown even if copying to clipboard fails. This PR changes it so that the Check icon only shows if copy succeeds.
1 parent 6fbe0dd commit c22c20e

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

www/assets/styles.css

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,7 @@ html[data-theme="dark"] ::selection {
9494
background-repeat: no-repeat;
9595
}
9696

97-
.group:not([data-copied]) .group-not-copied {
98-
display: block;
99-
}
100-
.group[data-copied] .group-not-copied {
101-
display: none;
102-
}
103-
104-
.group[data-copied] .group-copied {
105-
display: block;
106-
}
97+
.group[data-copied] .group-not-copied,
10798
.group:not([data-copied]) .group-copied {
10899
display: none;
109100
}

www/client.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ document.addEventListener("click", async (ev) => {
1111
const code = el.dataset.code;
1212
if (!code) return;
1313

14-
el.dataset.copied = "true";
15-
16-
setTimeout(() => {
17-
delete el.dataset.copied;
18-
}, 1000);
19-
2014
try {
2115
await navigator.clipboard.writeText(code);
16+
17+
el.dataset.copied = "true";
18+
19+
setTimeout(() => {
20+
delete el.dataset.copied;
21+
}, 1000);
2222
} catch (error) {
2323
const message = error instanceof Error ? error.message : String(error);
2424
// deno-lint-ignore no-console

0 commit comments

Comments
 (0)