1
0
mirror of https://github.com/garraflavatra/rolens.git synced 2025-01-18 13:07:58 +00:00

Copy collection stats as JSON

This commit is contained in:
Romein van Buren 2023-05-29 21:36:44 +02:00
parent 1a8cc2fe98
commit b22734d6d1
Signed by: romein
GPG Key ID: 0EFF8478ADDF6C49

View File

@ -1,7 +1,17 @@
<script>
import Icon from '$components/icon.svelte';
import ObjectGrid from '$components/objectgrid.svelte';
export let collection;
let copySucceeded = false;
async function copy() {
const json = JSON.stringify(collection.stats, undefined, '\t');
await navigator.clipboard.writeText(json);
copySucceeded = true;
setTimeout(() => copySucceeded = false, 1500);
}
</script>
<div class="stats">
@ -10,13 +20,20 @@
<div class="grid">
<ObjectGrid data={collection.stats} />
</div>
<div class="buttons">
<button class="btn secondary" on:click={copy}>
<Icon name={copySucceeded ? 'check' : 'clipboard'} />
Copy JSON
</button>
</div>
</div>
<style>
.stats {
display: grid;
gap: 0.5rem;
grid-template: auto / 1fr;
grid-template: 1fr auto / 1fr;
}
.stats .grid {