Skip to content

Commit

Permalink
Prevent repeated clicking the Copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
Amphiluke committed Mar 4, 2024
1 parent 5a3d982 commit 5520e19
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "lindsvg-pwa",
"private": true,
"version": "2.4.2",
"version": "2.4.3",
"type": "module",
"scripts": {
"lint": "eslint \"src/**/*.{mjs,vue}\"",
Expand Down
17 changes: 12 additions & 5 deletions src/components/PanelCollections.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup>
import {ref, computed} from "vue";
import {ref, computed, useCssModule} from "vue";
import {refDebounced} from "@vueuse/core";
import {useCollectionsStore, isUserDefined, USER_DEFINED_COLLECTION_ID} from "../stores/collections.mjs";
import {useLSystemStore} from "../stores/lSystem.mjs";
Expand Down Expand Up @@ -52,16 +52,15 @@ function deleteLSystem(lid) {
collectionsStore.deleteLSystem(lid);
}
let copiedClassName = useCssModule().copied;
async function copyPermalink(target, cid, lid) {
let url = new URL(location.origin + location.pathname);
url.searchParams.set("cid", cid);
url.searchParams.set("lid", lid);
await navigator.clipboard.writeText(url.toString());
target.classList.remove(interfaceStyles.iconButtonLink);
target.classList.add(interfaceStyles.iconButtonCheck);
target.classList.add(copiedClassName);
setTimeout(() => {
target.classList.remove(interfaceStyles.iconButtonCheck);
target.classList.add(interfaceStyles.iconButtonLink);
target.classList.remove(copiedClassName);
}, 2000);
}
</script>
Expand Down Expand Up @@ -235,4 +234,12 @@ async function copyPermalink(target, cid, lid) {
.collectionItems li:not(:hover, .active) :where(.permalinkButton, .exploreButton, .deleteLSystemButton):not(:focus) {
opacity: 0.01;
}
.copied {
pointer-events: none;
&::before {
--mask-pos: -200px 0;
}
}
</style>
8 changes: 6 additions & 2 deletions src/components/PanelSharing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,12 @@ async function copyLSVG({target}) {
width: 100%;
}
&.copied::before {
--mask-pos: -204px -4px;
&.copied {
pointer-events: none;
&::before {
--mask-pos: -204px -4px;
}
}
}
Expand Down

0 comments on commit 5520e19

Please sign in to comment.