Skip to content

Commit 5083bbc

Browse files
committed
feat: use real toaster
1 parent c4de1de commit 5083bbc

4 files changed

Lines changed: 4092 additions & 126 deletions

File tree

app.vue

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<script lang="ts" setup>
22
import { useAuth0 } from "@auth0/auth0-vue";
3+
import { Toaster } from "vue-sonner";
4+
import "vue-sonner/style.css";
35
4-
const { $appInsights } = useNuxtApp();
6+
const { $appInsights, $colorMode } = useNuxtApp();
57
68
const { isLoading, loginWithRedirect, isAuthenticated, error, logout } =
79
useAuth0();
@@ -108,6 +110,17 @@ useHead({
108110

109111
<template>
110112
<div class="h-full">
113+
<Toaster
114+
:theme="$colorMode.preference"
115+
expand
116+
position="bottom-center"
117+
:toast-options="{
118+
style: {
119+
background: 'var(--bmm-background-3)',
120+
color: 'var(--bmm-label-1)',
121+
},
122+
}"
123+
/>
111124
<NuxtLayout v-if="isAuthenticated && !error">
112125
<div class="container mx-auto min-w-80 px-2 pb-20 lg:px-9">
113126
<NuxtPage />

components/CopyToClipboard.vue

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup lang="ts">
22
import type { NuxtRoute, RoutesNamesList } from "@typed-router";
3+
import { toast } from "vue-sonner";
34
45
const props = defineProps<{
56
link: NuxtRoute<RoutesNamesList, string, boolean>;
@@ -10,22 +11,22 @@ const runtimeConfig = useRuntimeConfig();
1011
const isElectron = runtimeConfig.public.systemName === "Electron";
1112
1213
const router = useRouter();
13-
const showToast = ref(false);
1414
1515
const copyToClipboard = () => {
16-
showToast.value = true;
17-
1816
const domain = isElectron
1917
? `https://${config.websiteDomain}`
2018
: window.location.origin;
2119
22-
navigator.clipboard.writeText(
23-
`${domain}${router.resolve(props.link).href.replace("/./", "/")}`, // not sure why Electron adds /. at the beginning
24-
);
25-
26-
setTimeout(() => {
27-
showToast.value = false;
28-
}, 2000);
20+
navigator.clipboard
21+
.writeText(
22+
`${domain}${router.resolve(props.link).href.replace("/./", "/")}`, // not sure why Electron adds /. at the beginning
23+
)
24+
.then(() => {
25+
toast.success(t("share.link-copied-message"));
26+
})
27+
.catch(() => {
28+
toast.error("Could not copy link");
29+
});
2930
};
3031
3132
defineExpose({
@@ -34,14 +35,6 @@ defineExpose({
3435
</script>
3536

3637
<template>
37-
<div
38-
v-if="showToast"
39-
class="fixed inset-0 z-20 flex items-center justify-center bg-white-2 p-4 backdrop-blur-md dark:bg-black-4"
40-
>
41-
<p class="rounded-xl bg-tint px-10 py-6 text-label-1 dark:text-black-1">
42-
{{ t("share.link-copied-message") }}
43-
</p>
44-
</div>
4538
<div class="cursor-pointer" @click.stop="copyToClipboard">
4639
<slot />
4740
</div>

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@
4747
"string-strip-html": "^13.4.8",
4848
"tailwindcss": "^3.4.3",
4949
"ua-parser-js": "^1.0.37",
50-
"vue-draggable-plus": "^0.3.5"
50+
"vue-draggable-plus": "^0.3.5",
51+
"vue-sonner": "^2.0.8"
5152
},
5253
"devDependencies": {
5354
"@intlify/eslint-plugin-vue-i18n": "^2.0.0",

0 commit comments

Comments
 (0)