Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/lib/components/copyInput.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
<script lang="ts">
import { tooltip } from '$lib/actions/tooltip';
import { copy } from '$lib/helpers/copy';

import { addNotification } from '$lib/stores/notifications';

export let value: string;
export let label: string = null;
export let showLabel = false;

let content = 'Click to copy';

let content = 'Copy';
const handleCopy = async () => {
const success = await copy(value);

Expand All @@ -23,24 +21,28 @@
}
};
</script>

<style>
span.icon-duplicate {
cursor: pointer;
}
</style>
<div>
<label class:u-hide={!showLabel} class="label" for={label}>{label}</label>
<div class="input-text-wrapper" style="--amount-of-buttons:1">
<input {value} id={label} type="text" class="input-text" readonly />
<div class="options-list">
<button
type="button"
class="options-list-button"
aria-label="Click to copy."

<span
class="icon-duplicate" aria-label="Copy"
on:click={handleCopy}
on:mouseenter={() => setTimeout(() => (content = 'Click to copy'))}
on:mouseenter={() => setTimeout(() => (content = 'Copy'))}
use:tooltip={{
content,
hideOnClick: false
}}>
<span class="icon-duplicate" aria-hidden="true" />
</button>
hideOnClick: false,
appendTo: 'parent',
}}
/>

</div>
</div>
</div>