Skip to content

Commit cd7560d

Browse files
committed
add copy btn ui feedback
1 parent 2cc8311 commit cd7560d

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

gcp/website/frontend3/src/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ import { MdFilledTextField } from '@material/web/textfield/filled-text-field.js'
99
import { LitElement, html } from 'lit';
1010
import { ExpandableSearch, SearchSuggestionsManager } from './search.js';
1111

12+
const COPY_ICON_RESET_MS = 1500;
13+
14+
document.addEventListener('clipboard-copy', ({target}) => {
15+
const icon = target.querySelector('md-icon');
16+
if (!icon) return;
17+
clearTimeout(target._copyResetTimer);
18+
icon.textContent = 'check';
19+
target._copyResetTimer = setTimeout(() => { icon.textContent = 'content_copy'; }, COPY_ICON_RESET_MS);
20+
});
21+
1222
// Submits a form in a way such that Turbo can intercept the event.
1323
// Triggering submit on the form directly would still give a correct resulting
1424
// page, but we want to let Turbo speed up renders as intended.

0 commit comments

Comments
 (0)