-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
160 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
import type { PageLoad } from './$types'; | ||
import type { LineMap } from '../../../../static/schemas/line-maps/line-maps'; | ||
|
||
type LineMapRow = | ||
| { | ||
isStop: false; | ||
drawing: string[]; | ||
} | ||
| { | ||
isStop: true; | ||
drawing: string[]; | ||
href: string; | ||
isTerminus: boolean; | ||
slugName: string; | ||
displayName: string; | ||
lineConnections: string[]; | ||
}; | ||
|
||
export const load: PageLoad = async ({ fetch, params }) => { | ||
const { line } = params; | ||
const lineMap: LineMap = await (await fetch(`/schemas/line-maps/${line}.json`)).json(); | ||
|
||
return { | ||
lineMap, | ||
lineMap: lineMap.map((row): LineMapRow => { | ||
const isStop = !!row.slugName; | ||
if (isStop) { | ||
return { | ||
isStop, | ||
drawing: row.drawing, | ||
displayName: row.displayName ?? '', | ||
slugName: row.slugName ?? '', | ||
href: `/timetables/${params.line}/${row.slugName}`, | ||
isTerminus: row.isTerminus ?? false, | ||
lineConnections: row.lineConnections?.map(({ line }) => line) ?? [], | ||
}; | ||
} else { | ||
return { | ||
isStop, | ||
drawing: row.drawing, | ||
}; | ||
} | ||
}), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<script lang="ts"> | ||
export let content: string; | ||
export let isTerminus: boolean; | ||
</script> | ||
|
||
{#if content === '*'} | ||
<svg class="drawing-stop" viewBox="0 0 16 16"> | ||
<circle cx="8" cy="8" r={isTerminus ? 6 : 4} /> | ||
</svg> | ||
{:else if content === '^'} | ||
<svg class="drawing-path" viewBox="0 0 16 16"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,0 Z" /> | ||
<path d="M0,8 a8,-8 0 0,1 8,-8 L0,0 Z" /> | ||
</svg> | ||
{:else if content === 'v'} | ||
<svg class="drawing-path" viewBox="0 0 16 16"> | ||
<path d="M0,8 a8,8 0 0,0 8,8 L0,16 Z" /> | ||
<path d="M8,16 a8,-8 0 0,0 8,-8 L16,16 Z" /> | ||
</svg> | ||
{:else if content === 'o\\'} | ||
<svg class="drawing-path" viewBox="0 0 16 16"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,0 Z" /> | ||
</svg> | ||
{:else if content === 'o/'} | ||
<svg class="drawing-path" viewBox="0 0 16 16" transform="rotate(90)"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,0 Z" /> | ||
</svg> | ||
{:else if content === '\\o'} | ||
<svg class="drawing-path" viewBox="0 0 16 16" transform="rotate(180)"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,0 Z" /> | ||
</svg> | ||
{:else if content === '/o'} | ||
<svg class="drawing-path" viewBox="0 0 16 16" transform="rotate(270)"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,0 Z" /> | ||
</svg> | ||
{:else if content === '\\.'} | ||
<svg class="drawing-path" viewBox="0 0 16 16"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,16 L0,16 L0 0 Z" /> | ||
</svg> | ||
{:else if content === '/.'} | ||
<svg class="drawing-path" viewBox="0 0 16 16" transform="rotate(90)"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,16 L0,16 L0 0 Z" /> | ||
</svg> | ||
{:else if content === '.\\'} | ||
<svg class="drawing-path" viewBox="0 0 16 16" transform="rotate(180)"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,16 L0,16 L0 0 Z" /> | ||
</svg> | ||
{:else if content === './'} | ||
<svg class="drawing-path" viewBox="0 0 16 16" transform="rotate(270)"> | ||
<path d="M8,0 a8,8 0 0,1 8,8 L16,16 L0,16 L0 0 Z" /> | ||
</svg> | ||
{/if} | ||
|
||
{#if ['↑', '↓'].includes(content)} | ||
<span>{content}</span> | ||
{/if} | ||
|
||
<style> | ||
.drawing-stop { | ||
display: block; | ||
z-index: 0; | ||
position: absolute; | ||
transform: translate(-0.25rem, 0.5rem); | ||
width: 1.5rem; | ||
fill: #fff; | ||
stroke: #2f2f2f; | ||
stroke-width: 2.5px; | ||
} | ||
.drawing-path { | ||
display: block; | ||
fill: #fff; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script lang="ts"> | ||
export let isTerminus: boolean; | ||
export let href: string; | ||
export let displayName: string; | ||
export let lineConnections: string[]; | ||
</script> | ||
|
||
<a class="label-text" class:label-terminus={isTerminus} {href}> | ||
{displayName} | ||
{#if lineConnections} | ||
<div class="line-connections"> | ||
{#each lineConnections as line} | ||
<img src="/img/lines-icons/colors/{line}.svg" alt={line} /> | ||
{/each} | ||
</div> | ||
{/if} | ||
</a> | ||
|
||
<style> | ||
.label-terminus { | ||
font-weight: 700; | ||
color: #000; | ||
} | ||
.label-text { | ||
display: inline-block; | ||
padding: 0.4rem 0 0.4rem 1rem; | ||
min-width: 70%; | ||
margin-right: 0.75rem; | ||
text-decoration: inherit; | ||
color: inherit; | ||
} | ||
.line-connections > img { | ||
margin-top: 0.2rem; | ||
margin-right: 0.2rem; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters