frontend/components/notes/copyable-text.vue

33 lines
934 B
Vue
Raw Normal View History

2024-11-30 02:19:32 +01:00
<template>
<span :class="cn('text-primary group', $props.class)">
<span class="group-hover:hidden">
<slot />
</span>
<span class="hidden group-hover:inline">
<span @click="copyText"
2024-11-30 02:19:32 +01:00
class="select-none cursor-pointer space-x-1">
<Clipboard class="size-4 -translate-y-0.5 inline" />
{{ m.clean_yummy_owl_reside() }}
2024-11-30 02:19:32 +01:00
</span>
</span>
</span>
</template>
<script lang="tsx" setup>
2024-11-30 02:19:32 +01:00
import { cn } from "@/lib/utils";
import { Check, Clipboard } from "lucide-vue-next";
import type { HTMLAttributes } from "vue";
import { toast } from "vue-sonner";
import * as m from "~/paraglide/messages.js";
2024-11-30 02:19:32 +01:00
const { text } = defineProps<{
text: string;
class?: HTMLAttributes["class"];
}>();
const { copy } = useClipboard();
const copyText = () => {
copy(text);
toast.success("Copied to clipboard");
2024-11-30 02:19:32 +01:00
};
</script>