Skip to content

Commit 4352954

Browse files
committed
refactor(icon): improve mta bus text style
1 parent 1d9e350 commit 4352954

1 file changed

Lines changed: 44 additions & 2 deletions

File tree

frontend/src/lib/Icon.svelte

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
66
import { type Route } from '@trainstatus/client';
77
8-
// TODO: combine w and h into size
98
const {
109
route,
1110
link,
@@ -29,6 +28,33 @@
2928
// TODO: maybe differentiate between planned alerts, station notices, etc
3029
return alerts.value?.alerts_by_route.has(route.id) ?? false;
3130
});
31+
32+
// TODO: apply this bus prefix thing to map
33+
// Make mta bus prefix smaller than rest of short name
34+
const route_short_name_parts = $derived.by(() => {
35+
const short_name = route.short_name ?? '';
36+
37+
if (route.data.source !== 'mta_bus') {
38+
return {
39+
prefix: '',
40+
rest: short_name
41+
};
42+
}
43+
44+
const match = short_name.match(/^([A-Za-z]+)(.*)$/);
45+
46+
if (!match || match[2].length === 0) {
47+
return {
48+
prefix: '',
49+
rest: short_name
50+
};
51+
}
52+
53+
return {
54+
prefix: match[1],
55+
rest: match[2]
56+
};
57+
});
3258
</script>
3359

3460
<!-- {#snippet alert_icon()}
@@ -49,7 +75,12 @@
4975
if (link) open_modal({ type: 'route', ...route });
5076
}}
5177
>
52-
{route.short_name}
78+
<span class="bus-short-name">
79+
{#if route_short_name_parts.prefix}
80+
<span class="bus-short-name-prefix">{route_short_name_parts.prefix}</span>
81+
{/if}
82+
<span>{route_short_name_parts.rest}</span>
83+
</span>
5384

5485
<!-- {@render alert_icon()} -->
5586
</div>
@@ -77,4 +108,15 @@
77108
svg {
78109
transform: translateZ(0);
79110
}
111+
112+
.bus-short-name {
113+
display: inline-flex;
114+
align-items: baseline;
115+
}
116+
117+
.bus-short-name-prefix {
118+
font-size: 0.8em;
119+
line-height: 1;
120+
margin-right: 1px;
121+
}
80122
</style>

0 commit comments

Comments
 (0)