Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 6248 copy button issue #561

Closed
wants to merge 2 commits into from
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>