2021-10-12 18:32:15 +02:00
|
|
|
<script>
|
|
|
|
import Icon from "../Icon/Icon.svelte"
|
2022-02-24 22:48:23 +01:00
|
|
|
import { copyToClipboard } from "../helpers"
|
2021-10-12 18:32:15 +02:00
|
|
|
import { notifications } from "../Stores/notifications"
|
2022-02-24 22:48:23 +01:00
|
|
|
|
2021-10-12 18:32:15 +02:00
|
|
|
export let value
|
|
|
|
|
2022-02-24 22:48:23 +01:00
|
|
|
const onClick = async e => {
|
2021-10-12 18:32:15 +02:00
|
|
|
e.stopPropagation()
|
2022-02-24 22:48:23 +01:00
|
|
|
try {
|
|
|
|
await copyToClipboard(value)
|
|
|
|
notifications.success("Copied to clipboard")
|
|
|
|
} catch (error) {
|
|
|
|
notifications.error(
|
|
|
|
"Failed to copy to clipboard. Check the dev console for the value."
|
|
|
|
)
|
|
|
|
console.warn("Failed to copy the value", value)
|
|
|
|
}
|
2021-10-12 18:32:15 +02:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div on:click|stopPropagation={onClick}>
|
|
|
|
<Icon size="S" name="Copy" />
|
|
|
|
</div>
|