186 lines
3.9 KiB
Svelte
186 lines
3.9 KiB
Svelte
<script lang="ts">
|
|
import { components } from '$lib/mapRegistry';
|
|
import type { ElecType } from '$lib/railStyles';
|
|
import { IconArrowNarrowRight } from '@tabler/icons-svelte';
|
|
|
|
type featureType = "station" | "junction" | "crossovers" | "siteof" | "bridge" | "minorBridge" | "crossover" | "crossing" | "loop" | "loops" | "signallerChange" | "electrificationChange" | "default" | "tunnel";
|
|
export let feature: {name: string; type: featureType; goto?: string; entryPoint?: string; miles: number; chains: number; description?: string}; // Raw Object
|
|
export let activeElec: ElecType; // Active Electrification Type
|
|
export let reversed: boolean = false;
|
|
|
|
$: Icon = components[feature.type] || components.default;
|
|
|
|
// Linking Logic
|
|
$: isLinkable = !!(feature.goto && feature.entryPoint);
|
|
$: href = `/map/${feature.goto}#${feature.entryPoint}`;
|
|
|
|
const slugify = (str?: string) =>
|
|
str?.toLocaleLowerCase().trim().replace(/\s+/g, '-') ?? 'unknown';
|
|
</script>
|
|
|
|
<div class="row-container" id={slugify(feature.name)}>
|
|
<div class="mileage-col">
|
|
<span class="miles">{feature.miles + 'm' || ''}</span>
|
|
<span class="chains">{feature.chains + 'ch' || ''}</span>
|
|
</div>
|
|
|
|
<div class="icon-col">
|
|
<svelte:component this={Icon} feature={feature as any} {activeElec} {reversed} />
|
|
</div>
|
|
|
|
<svelte:element this={isLinkable ? 'a' : 'div'} {...(isLinkable ? { href } : {})} class="link-wrapper">
|
|
<div class="label-col">
|
|
{#if feature.name}
|
|
<div class="feature-name">{feature.name}</div>
|
|
{/if}
|
|
{#if feature.description}
|
|
<div class="feature-desc">{feature.description}</div>
|
|
{/if}
|
|
</div>
|
|
{#if isLinkable}
|
|
<div class="link-indicator">
|
|
<IconArrowNarrowRight />
|
|
</div>
|
|
{/if}
|
|
</svelte:element>
|
|
|
|
|
|
</div>
|
|
|
|
<style>
|
|
a {
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
}
|
|
.row-container {
|
|
display: grid;
|
|
grid-template-columns: 3.5rem 64px 1fr;
|
|
width: 100%;
|
|
height: 64px;
|
|
max-height: 64px;
|
|
align-items: center;
|
|
margin: 0;
|
|
padding: 0;
|
|
overflow: hidden;
|
|
}
|
|
|
|
.mileage-col {
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-end;
|
|
padding-right: 12px;
|
|
font-family: 'Courier New', Courier, monospace;
|
|
font-size: 0.85rem;
|
|
color: #64748b;
|
|
}
|
|
|
|
.miles {
|
|
font-weight: bold;
|
|
line-height: 1;
|
|
}
|
|
|
|
.chains {
|
|
font-size: 0.7rem;
|
|
}
|
|
|
|
|
|
.icon-col {
|
|
width: 64px;
|
|
height: 64px;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
overflow: visible;
|
|
}
|
|
|
|
|
|
.link-wrapper {
|
|
display: flex;
|
|
flex-direction: row;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
width: 100%;
|
|
height: 100%;
|
|
text-decoration: none;
|
|
color: inherit;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.link-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
margin-left: 5px;
|
|
margin-right: 8px;
|
|
flex-shrink: 0;
|
|
color: #e1ebeb;
|
|
background-color: #3c6f79;
|
|
padding: 2px 2px;
|
|
border-radius: 999px;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.link-wrapper:hover .link-indicator {
|
|
background-color: #404c55;
|
|
transform: rotate(-45deg);
|
|
}
|
|
|
|
.label-col {
|
|
padding-left: 16px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
justify-content: center;
|
|
overflow: hidden;
|
|
min-width: 0;
|
|
}
|
|
|
|
.feature-name {
|
|
font-weight: 700;
|
|
font-family: sans-serif;
|
|
color: #1e293b;
|
|
font-size: 0.8rem;
|
|
text-transform: capitalize;
|
|
white-space: normal;
|
|
line-height: 1.2;
|
|
margin-bottom: 2px;
|
|
}
|
|
|
|
.feature-desc {
|
|
display: -webkit-box;
|
|
-webkit-box-orient: vertical;
|
|
font-family: sans-serif;
|
|
-webkit-line-clamp: 2;
|
|
line-clamp: 2;
|
|
overflow: hidden;
|
|
white-space: normal;
|
|
line-height: 1.2rem;
|
|
max-height: 2.4rem;
|
|
font-size: 0.75rem;
|
|
color: #64748b;
|
|
word-break: break-word;
|
|
}
|
|
|
|
@media (max-width: 320px) {
|
|
.feature-desc {
|
|
display: none;
|
|
}
|
|
}
|
|
|
|
@media (min-width: 480px) {
|
|
.feature-name {
|
|
font-size: 1rem;
|
|
margin-bottom: 4px;
|
|
}
|
|
|
|
.feature-desc {
|
|
font-size: 0.85rem;
|
|
line-height: 1.3rem;
|
|
max-height: 2.6rem;
|
|
}
|
|
|
|
.label-col {
|
|
padding-left: 24px;
|
|
}
|
|
}
|
|
</style>
|