Files
radicle-explorer/src/components/Clipboard.svelte
T
Rūdolfs Ošiņš 9704318248 Refactor seed view
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
2023-04-20 14:41:19 +02:00

55 lines
1.1 KiB
Svelte

<script lang="ts" strictEvents>
import { createEventDispatcher } from "svelte";
import Icon from "@app/components/Icon.svelte";
import { toClipboard } from "@app/lib/utils";
const dispatch = createEventDispatcher<{ copied: never }>();
const copy = () => {
toClipboard(text);
dispatch("copied");
};
export let text: string;
export let small = false;
export let tooltip: string | undefined = undefined;
</script>
<style>
.clipboard {
width: 2rem;
height: 2rem;
cursor: pointer;
display: inline-flex;
justify-content: center;
align-items: center;
}
.clipboard.small {
width: 1.5rem;
height: 1.5rem;
}
.clipboard:hover :global(svg) {
fill: var(--color-foreground);
}
.clipboard:active :global(svg) {
fill: var(--color-foreground-6);
}
.clipboard:hover {
border-radius: var(--border-radius);
}
</style>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<span
title={tooltip}
class="clipboard"
class:small
on:click|stopPropagation={copy}>
{#if small}
<Icon name="clipboard-small" />
{:else}
<Icon name="clipboard" />
{/if}
</span>