Files
radicle-explorer/src/Clipboard.svelte
T
Rūdolfs OšiņšandBrandon Oxendine b35d46752f Add theme switching button
Co-authored-by: Brandon Oxendine <brandon.oxendine@gmail.com>
Signed-off-by: Brandon Oxendine <brandon.oxendine@gmail.com>
Signed-off-by: Rūdolfs Ošiņš <rudolfs@osins.org>
2022-09-15 12:45:56 +02:00

48 lines
967 B
Svelte

<script lang="ts">
import Icon from "@app/Icon.svelte";
import { toClipboard } from "@app/utils";
import { createEventDispatcher } from "svelte";
const dispatch = createEventDispatcher();
const copy = () => {
toClipboard(text);
dispatch("copied");
};
export let text: string;
export let small = false;
</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>
<span class="clipboard" class:small on:click|stopPropagation={copy}>
{#if small}
<Icon name="clipboard-small" />
{:else}
<Icon name="clipboard" />
{/if}
</span>