Close clone popover when Clipboard icon clicked

Signed-off-by: Sebastian Martinez <me@sebastinez.dev>
This commit is contained in:
Sebastian Martinez
2022-08-24 09:13:55 +02:00
committed by Alexis Sellier
parent 8bc659aff2
commit 8021f6396d
2 changed files with 14 additions and 4 deletions
+11 -3
View File
@@ -1,6 +1,14 @@
<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;
@@ -8,8 +16,8 @@
<style>
.clipboard {
width: 32px;
height: 32px;
width: 30px;
height: 30px;
cursor: pointer;
display: inline-flex;
justify-content: center;
@@ -30,7 +38,7 @@
}
</style>
<span class="clipboard" class:small on:click|stopPropagation={() => toClipboard(text)}>
<span class="clipboard" class:small on:click|stopPropagation={copy}>
{#if small}
<Icon name="clipboard-small" width={12} height={12} />
{:else}
+3 -1
View File
@@ -1,5 +1,6 @@
<script lang="ts">
import Clipboard from '@app/Clipboard.svelte';
import { closeFocused } from '@app/Floating.svelte';
export let name: string;
export let value: string;
@@ -10,6 +11,7 @@
<style>
main {
display: flex;
align-items: center;
}
.clipboard {
visibility: hidden;
@@ -39,7 +41,7 @@
<input class={$$props.class} readonly={clipboard} {name} {value} />
{#if clipboard}
<span class="clipboard {$$props.class}">
<Clipboard text={value} {small} />
<Clipboard text={value} {small} on:copied={closeFocused} />
</span>
{/if}
</main>