2024-04-19 16:13:08 +02:00
|
|
|
<script lang="ts">
|
|
|
|
import * as Card from '$lib/components/ui/card';
|
2024-04-21 16:40:28 +02:00
|
|
|
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 { MoveDownRight, MoveUpRight, Ruler, Timer, Zap } from 'lucide-svelte';
|
|
|
|
|
2024-04-24 18:02:35 +02:00
|
|
|
import { _ } from 'svelte-i18n';
|
2024-06-10 20:03:57 +02:00
|
|
|
import type { GPXStatistics } from 'gpx';
|
2024-07-05 16:08:16 +02:00
|
|
|
import type { Writable } from 'svelte/store';
|
2024-05-04 15:10:30 +02:00
|
|
|
|
2024-07-05 16:08:16 +02:00
|
|
|
export let gpxStatistics: Writable<GPXStatistics>;
|
|
|
|
export let slicedGPXStatistics: Writable<[GPXStatistics, number, number] | undefined>;
|
|
|
|
export let velocityUnits: 'speed' | 'pace';
|
|
|
|
export let orientation: 'horizontal' | 'vertical';
|
|
|
|
export let panelSize: number;
|
2024-06-10 20:03:57 +02:00
|
|
|
|
|
|
|
let statistics: GPXStatistics;
|
|
|
|
|
2024-06-12 12:13:30 +02:00
|
|
|
$: if ($slicedGPXStatistics !== undefined) {
|
2024-06-12 12:46:59 +02:00
|
|
|
statistics = $slicedGPXStatistics[0];
|
2024-06-10 20:03:57 +02:00
|
|
|
} else {
|
|
|
|
statistics = $gpxStatistics;
|
|
|
|
}
|
2024-04-19 16:13:08 +02:00
|
|
|
</script>
|
|
|
|
|
2024-06-09 17:22:41 +02:00
|
|
|
<Card.Root
|
2024-07-05 16:08:16 +02:00
|
|
|
class="h-full {orientation === 'vertical'
|
|
|
|
? 'min-w-52'
|
|
|
|
: 'w-full pr-4'} border-none shadow-none pl-4"
|
2024-06-09 17:22:41 +02:00
|
|
|
>
|
|
|
|
<Card.Content
|
2024-07-05 16:08:16 +02:00
|
|
|
class="h-full flex {orientation === 'vertical'
|
2024-06-09 17:22:41 +02:00
|
|
|
? 'flex-col justify-center'
|
2024-07-05 16:08:16 +02:00
|
|
|
: 'flex-row w-full justify-between'} gap-4 p-0"
|
2024-06-09 17:22:41 +02:00
|
|
|
>
|
2024-04-21 16:40:28 +02:00
|
|
|
<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-06-10 20:03:57 +02:00
|
|
|
<WithUnits value={statistics.global.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>
|
2024-04-21 16:40:28 +02:00
|
|
|
</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-06-10 20:03:57 +02:00
|
|
|
<WithUnits value={statistics.global.elevation.gain} type="elevation" />
|
2024-04-19 16:13:08 +02:00
|
|
|
<MoveDownRight size="18" class="mx-1" />
|
2024-06-10 20:03:57 +02:00
|
|
|
<WithUnits value={statistics.global.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>
|
2024-04-21 16:40:28 +02:00
|
|
|
</Tooltip>
|
2024-07-05 16:08:16 +02:00
|
|
|
{#if panelSize > 120 || orientation === 'horizontal'}
|
|
|
|
<Tooltip class={orientation === 'horizontal' ? 'hidden xs:block' : ''}>
|
2024-06-25 16:06:11 +02:00
|
|
|
<span slot="data" class="flex flex-row items-center">
|
|
|
|
<Zap size="18" class="mr-1" />
|
|
|
|
<WithUnits value={statistics.global.speed.moving} type="speed" showUnits={false} />
|
|
|
|
<span class="mx-1">/</span>
|
|
|
|
<WithUnits value={statistics.global.speed.total} type="speed" />
|
|
|
|
</span>
|
|
|
|
<span slot="tooltip"
|
2024-07-05 16:08:16 +02:00
|
|
|
>{velocityUnits === 'speed' ? $_('quantities.speed') : $_('quantities.pace')} ({$_(
|
2024-06-25 16:06:11 +02:00
|
|
|
'quantities.moving'
|
|
|
|
)} / {$_('quantities.total')})</span
|
|
|
|
>
|
|
|
|
</Tooltip>
|
|
|
|
{/if}
|
2024-07-05 16:08:16 +02:00
|
|
|
{#if panelSize > 160 || orientation === 'horizontal'}
|
|
|
|
<Tooltip class={orientation === 'horizontal' ? 'hidden md:block' : ''}>
|
2024-06-25 16:06:11 +02:00
|
|
|
<span slot="data" class="flex flex-row items-center">
|
|
|
|
<Timer size="18" class="mr-1" />
|
|
|
|
<WithUnits value={statistics.global.time.moving} type="time" />
|
|
|
|
<span class="mx-1">/</span>
|
|
|
|
<WithUnits value={statistics.global.time.total} type="time" />
|
|
|
|
</span>
|
|
|
|
<span slot="tooltip"
|
|
|
|
>{$_('quantities.time')} ({$_('quantities.moving')} / {$_('quantities.total')})</span
|
|
|
|
>
|
|
|
|
</Tooltip>
|
|
|
|
{/if}
|
2024-04-19 16:13:08 +02:00
|
|
|
</Card.Content>
|
|
|
|
</Card.Root>
|