zenno/race: common component for calculator outputs

This commit is contained in:
2026-07-18 16:38:07 -04:00
parent cb54bbe414
commit b22c8307fd
4 changed files with 49 additions and 30 deletions
+10 -10
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import { HORSE_LENGTH, speedGain } from '$lib/race';
import type { Snippet } from 'svelte';
import CalcInfo from '../CalcInfo.svelte';
interface Props {
children: Snippet;
@@ -21,13 +22,12 @@
const text = $derived(gain.map(fmtp).join(' '));
</script>
<div
class="m-2 flex h-full w-full max-w-80 flex-1 flex-col rounded-md border p-2 text-center shadow-sm transition-shadow hover:shadow-md"
>
<div class="block">{@render children()}</div>
<span class="block text-xl">{text} L</span>
<div class="flex flex-row">
<span class="flex-1 text-xs">{fmtp(speed)} m/s</span>
<span class="flex-1 text-xs">{dur.toFixed(3)} s</span>
</div>
</div>
<CalcInfo title={children} class="max-w-80 flex-1">
{text} L
{#snippet additional()}
<div class="flex flex-row">
<span class="flex-1 text-xs">{fmtp(speed)} m/s</span>
<span class="flex-1 text-xs">{dur.toFixed(3)} s</span>
</div>
{/snippet}
</CalcInfo>