Files
gpx.studio/website/src/lib/components/GPXData.svelte

70 lines
2.3 KiB
Svelte
Raw Normal View History

2024-04-19 16:13:08 +02:00
<script lang="ts">
import * as Card from '$lib/components/ui/card';
import Tooltip from '$lib/components/Tooltip.svelte';
2024-04-24 16:12:50 +02:00
import WithUnits from '$lib/components/WithUnits.svelte';
2024-04-19 16:13:08 +02:00
2024-04-25 13:48:31 +02:00
import { GPXFiles, GPXStatistics } from 'gpx';
2024-04-19 16:13:08 +02:00
2024-04-25 13:48:31 +02:00
import { selectedFiles, settings } from '$lib/stores';
2024-04-24 20:13:42 +02:00
import { get } from 'svelte/store';
2024-04-19 16:13:08 +02:00
import { MoveDownRight, MoveUpRight, Ruler, Timer, Zap } from 'lucide-svelte';
2024-04-24 18:02:35 +02:00
import { _ } from 'svelte-i18n';
2024-04-19 16:13:08 +02:00
let gpxData: GPXStatistics = new GPXStatistics();
2024-04-24 22:35:53 +02:00
function updateGPXData() {
2024-04-25 13:48:31 +02:00
gpxData = new GPXFiles(Array.from(get(selectedFiles))).getStatistics();
2024-04-19 16:13:08 +02:00
}
2024-04-24 22:35:53 +02:00
$: if ($selectedFiles) {
updateGPXData();
}
2024-04-19 16:13:08 +02:00
</script>
2024-04-24 11:24:26 +02:00
<Card.Root class="h-full overflow-hidden border-none min-w-48 pl-4">
<Card.Content class="h-full flex flex-col flex-wrap gap-4 justify-center p-0">
<Tooltip>
2024-04-19 16:13:08 +02:00
<span slot="data" class="flex flex-row items-center">
<Ruler size="18" class="mr-1" />
2024-04-24 16:12:50 +02:00
<WithUnits value={gpxData.distance.total} type="distance" />
2024-04-19 16:13:08 +02:00
</span>
2024-04-24 18:02:35 +02:00
<span slot="tooltip">{$_('quantities.distance')}</span>
</Tooltip>
<Tooltip>
2024-04-19 16:13:08 +02:00
<span slot="data" class="flex flex-row items-center">
<MoveUpRight size="18" class="mr-1" />
2024-04-24 16:12:50 +02:00
<WithUnits value={gpxData.elevation.gain} type="elevation" />
2024-04-19 16:13:08 +02:00
<MoveDownRight size="18" class="mx-1" />
2024-04-24 16:12:50 +02:00
<WithUnits value={gpxData.elevation.loss} type="elevation" />
2024-04-19 16:13:08 +02:00
</span>
2024-04-24 18:02:35 +02:00
<span slot="tooltip">{$_('quantities.elevation')}</span>
</Tooltip>
<Tooltip>
2024-04-19 16:13:08 +02:00
<span slot="data" class="flex flex-row items-center">
<Zap size="18" class="mr-1" />
2024-04-25 13:48:31 +02:00
<WithUnits value={gpxData.speed.total} type="speed" showUnits={false} />
<span class="mx-1">/</span>
<WithUnits value={gpxData.speed.moving} type="speed" />
2024-04-19 16:13:08 +02:00
</span>
2024-04-24 18:02:35 +02:00
<span slot="tooltip"
>{$settings.velocityUnits === 'speed' ? $_('quantities.speed') : $_('quantities.pace')} ({$_(
2024-04-25 13:48:31 +02:00
'quantities.total'
)} / {$_('quantities.moving')})</span
2024-04-24 18:02:35 +02:00
>
</Tooltip>
<Tooltip>
2024-04-19 16:13:08 +02:00
<span slot="data" class="flex flex-row items-center">
<Timer size="18" class="mr-1" />
2024-04-24 16:12:50 +02:00
<WithUnits value={gpxData.time.total} type="time" />
2024-04-25 13:48:31 +02:00
<span class="mx-1">/</span>
<WithUnits value={gpxData.time.moving} type="time" />
2024-04-19 16:13:08 +02:00
</span>
2024-04-24 18:02:35 +02:00
<span slot="tooltip"
2024-04-25 13:48:31 +02:00
>{$_('quantities.time')} ({$_('quantities.total')} / {$_('quantities.moving')})</span
2024-04-24 18:02:35 +02:00
>
</Tooltip>
2024-04-19 16:13:08 +02:00
</Card.Content>
</Card.Root>