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

72 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
import { GPXStatistics } from 'gpx';
2024-04-24 22:35:53 +02:00
import { getFileStore, 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-19 16:13:08 +02:00
gpxData = new GPXStatistics();
2024-04-24 20:13:42 +02:00
$selectedFiles.forEach((file) => {
2024-04-24 22:35:53 +02:00
gpxData.mergeWith(file.statistics);
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-24 18:02:35 +02:00
<WithUnits value={gpxData.speed.moving} type="speed" showUnits={false} /> /
<WithUnits value={gpxData.speed.total} 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')} ({$_(
'quantities.moving'
)} / {$_('quantities.total')})</span
>
</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.moving} type="time" />
<span class="mx-1">/</span>
<WithUnits value={gpxData.time.total} type="time" />
2024-04-19 16:13:08 +02:00
</span>
2024-04-24 18:02:35 +02:00
<span slot="tooltip"
>{$_('quantities.time')} ({$_('quantities.moving')} / {$_('quantities.total')})</span
>
</Tooltip>
2024-04-19 16:13:08 +02:00
</Card.Content>
</Card.Root>