Allow copying of different formats
This commit is contained in:
parent
0471e66edc
commit
d14b7b2b1f
42
web-frontend/src/lib/CopyButton.svelte
Normal file
42
web-frontend/src/lib/CopyButton.svelte
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<script>
|
||||||
|
export let data;
|
||||||
|
|
||||||
|
const copyData = (format) => {
|
||||||
|
navigator.clipboard.writeText(data);
|
||||||
|
state = new Promise(() =>
|
||||||
|
setTimeout(() => {
|
||||||
|
state = undefined;
|
||||||
|
}, 1500)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
let state;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={copyData}
|
||||||
|
>{#if state}<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="w-6 h-6"
|
||||||
|
><path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M11.35 3.836c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m8.9-4.414c.376.023.75.05 1.124.08 1.131.094 1.976 1.057 1.976 2.192V16.5A2.25 2.25 0 0118 18.75h-2.25m-7.5-10.5H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V18.75m-7.5-10.5h6.375c.621 0 1.125.504 1.125 1.125v9.375m-8.25-3l1.5 1.5 3-3.75"
|
||||||
|
/></svg
|
||||||
|
>{:else}<svg
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
stroke-width="1.5"
|
||||||
|
stroke="currentColor"
|
||||||
|
class="w-6 h-6"
|
||||||
|
><path
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
d="M9 12h3.75M9 15h3.75M9 18h3.75m3 .75H18a2.25 2.25 0 002.25-2.25V6.108c0-1.135-.845-2.098-1.976-2.192a48.424 48.424 0 00-1.123-.08m-5.801 0c-.065.21-.1.433-.1.664 0 .414.336.75.75.75h4.5a.75.75 0 00.75-.75 2.25 2.25 0 00-.1-.664m-5.8 0A2.251 2.251 0 0113.5 2.25H15c1.012 0 1.867.668 2.15 1.586m-5.8 0c-.376.023-.75.05-1.124.08C9.095 4.01 8.25 4.973 8.25 6.108V8.25m0 0H4.875c-.621 0-1.125.504-1.125 1.125v11.25c0 .621.504 1.125 1.125 1.125h9.75c.621 0 1.125-.504 1.125-1.125V9.375c0-.621-.504-1.125-1.125-1.125H8.25zM6.75 12h.008v.008H6.75V12zm0 3h.008v.008H6.75V15zm0 3h.008v.008H6.75V18z"
|
||||||
|
/></svg
|
||||||
|
>{/if}</button
|
||||||
|
>
|
@ -1,24 +1,28 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import CopyButton from '$lib/CopyButton.svelte';
|
||||||
import { onMount, onDestroy } from 'svelte';
|
import { onMount, onDestroy } from 'svelte';
|
||||||
|
|
||||||
export let xpin;
|
export let xpin;
|
||||||
|
let formats = ['dd', 'dms', 'dmm', 'utm', 'plus'];
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
|
// TODO: Indicate that the data is copied
|
||||||
console.log('Got xpin: ', xpin);
|
console.log('Got xpin: ', xpin);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<p>DD</p>
|
<table class="table-auto">
|
||||||
<p>{xpin.allCoordinates.dd}</p>
|
<tr>
|
||||||
|
<th>Format</th>
|
||||||
|
<th>Value</th>
|
||||||
|
<th />
|
||||||
|
</tr>
|
||||||
|
|
||||||
<p>DMS</p>
|
{#each formats as format}
|
||||||
<p>{xpin.allCoordinates.dms}</p>
|
<tr>
|
||||||
|
<th>{format.toUpperCase()}</th>
|
||||||
<p>DMM</p>
|
<td>{xpin.allCoordinates[format]}</td>
|
||||||
<p>{xpin.allCoordinates.dmm}</p>
|
<td><CopyButton data={xpin.allCoordinates[format]} /></td>
|
||||||
|
</tr>
|
||||||
<p>UTM</p>
|
{/each}
|
||||||
<p>{xpin.allCoordinates.utm}</p>
|
</table>
|
||||||
|
|
||||||
<p>PLUS</p>
|
|
||||||
<p>{xpin.allCoordinates.plus}</p>
|
|
||||||
|
Loading…
Reference in New Issue
Block a user