mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-11-21 22:30:41 +08:00
55 lines
1.1 KiB
Svelte
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>
|