Skip to content

Commit

Permalink
Merge pull request #272 from Steinbeck-Lab/fix-copy-button-timeout
Browse files Browse the repository at this point in the history
fix: copy buttons now have a time out of 4 seconds to reset
  • Loading branch information
Kohulan authored Oct 14, 2024
2 parents be91376 + 335fdc2 commit cc62abf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion resources/views/livewire/copy-button.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<span x-data="{ copied: false }">
<span x-ref="copyText" class="hidden">{{ $textToCopy }}</span>
<button @click="navigator.clipboard.writeText($refs.copyText.textContent).then(() => copied = true)"
<button @click="navigator.clipboard.writeText($refs.copyText.textContent).then(() => {
copied = true;
setTimeout(() => copied = false, 4000);
})"
class="relative text-center align-middle font-sans text-xs font-medium uppercase transition-all" type="button">
<span class="absolute transform -translate-x-1/2 -translate-y-1/2 top-1/2 left-1/2">
<svg x-show="!copied" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
Expand Down

0 comments on commit cc62abf

Please sign in to comment.