Skip to content

Commit

Permalink
Update ComponentStructure and Router components
Browse files Browse the repository at this point in the history
  • Loading branch information
valiantlynx committed Dec 29, 2023
1 parent f976055 commit 1b12bbc
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/lib/site-components/ComponentStructure.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@

<h1 class="text-4xl font-bold text-center">{title}</h1>

<div class="m-10">
<div class="m-10 h-96">
<slot />
</div>

Expand Down
44 changes: 41 additions & 3 deletions src/routes/components/router/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,51 @@


<script>
import ComponentStructure from '$lib/site-components/ComponentStructure.svelte';
import Route from '$lib/site-components/Route.svelte';
import { routeCoordinates, instructions, summary } from '$lib/components/stores';
import jsonData from './data.json';
console.log($summary);
</script>

<ComponentStructure title="Router" url="router" {jsonData}>
<Route />
</ComponentStructure>
<div slot="more">
<div>
<h1 class="text-4xl font-bold text-center">routeCoordinates</h1>
<div class="m-10">
<p>start: {$routeCoordinates[0]}</p>
<p>end: {$routeCoordinates[$routeCoordinates.length - 1]}</p>
<div>
<h1 class="text-4xl font-bold text-center">summary</h1>
<div class="m-10">
<p>distance: {(parseFloat($summary.totalDistance) / 1000).toFixed(2)} km</p>
<p>duration: {parseFloat(($summary.totalTime) / 60).toFixed(2)} min</p>
</div>
</div>
<div>
<h1 class="text-4xl font-bold text-center">route (first 10)</h1>
<div class="m-10 truncate">
{#each $routeCoordinates.filter((i, index) => index < 7) as coordinate}
<p>{coordinate}</p>
{/each}
</div>
<h1 class="text-4xl font-bold text-center">instructions (first 10)</h1>
<div class="m-10">
{#each $instructions.filter((i, index) => index < 7) as instruction}
<div class="flex flex-row justify-between">
<div class="flex flex-col">
<p>{instruction.text}</p>
<p>{instruction.distance / 1000} km</p>
</div>
<div class="flex flex-col">
<p>{instruction.duration / 60} min</p>
<p>{instruction.type}</p>
</div>
</div>
{/each}
</div>
</div>
</div>
</div>
</div></ComponentStructure
>

0 comments on commit 1b12bbc

Please sign in to comment.