Skip to content

feat: add copy button for variable export #5

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 20 additions & 2 deletions src/components/ExportOptions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
let exportPermalink = '';

let permalinkInputEl: HTMLInputElement;
let variableExportInputEl: HTMLTextAreaElement;

let exportColorsOnly = false;

Expand All @@ -32,6 +33,16 @@
toast.push('Copied!', { target: 'modalToast', duration: 2000 });
}

function onCopyVariableExport() {
if (!exportEnvString) return;

variableExportInputEl.select();
navigator.clipboard.writeText(variableExportInputEl.value);

toast.pop();
toast.push('Copied!', { target: 'modalToast', duration: 2000 });
}

function onToggleColorsOnly(e: Event) {
exportColorsOnly = (e.currentTarget as HTMLInputElement)?.checked;
}
Expand Down Expand Up @@ -82,8 +93,15 @@
</button>
</div>

<h3>Variable Export</h3>
<textarea readonly>{exportEnvString}</textarea>
<div style="display: flex; flex-direction: column; gap: 15px; height: 100%;">
<div style="display: flex; align-items: center; gap: 15px;">
<h3>Variable Export</h3>
<button type="button" class="copy-url btn btn-secondary" on:click={onCopyVariableExport}>
<ClipboardOutline size="16" />
</button>
</div>
<textarea bind:this={variableExportInputEl} readonly style="flex: 1;">{exportEnvString}</textarea>
</div>
</div>

<SvelteToast
Expand Down