trying to get sub label showed properly
This commit is contained in:
@@ -158,8 +158,16 @@
|
||||
class="text-xs font-medium px-2 py-0.5 rounded-full"
|
||||
style="background:{color}22;color:{color}"
|
||||
>
|
||||
{sportIcon(activity.sport)} {sportLabel(activity.sport, activity.sub_sport)}
|
||||
{sportIcon(activity.sport)} {sportLabel(activity.sport)}
|
||||
</span>
|
||||
{#if activity.sub_sport && activity.sub_sport !== 'generic'}
|
||||
<span
|
||||
class="text-xs font-medium px-2 py-0.5 rounded-full"
|
||||
style="background:{color}11;color:{color}cc"
|
||||
>
|
||||
{sportLabel(activity.sport, activity.sub_sport).split(' ')[0]}
|
||||
</span>
|
||||
{/if}
|
||||
<span class="text-xs text-zinc-500">
|
||||
{formatDate(activity.started_at)} · {formatTime(activity.started_at)}
|
||||
</span>
|
||||
|
||||
+15
-1
@@ -75,10 +75,24 @@ export function sportColor(sport: Sport): string {
|
||||
return SPORT_COLORS[sport] ?? '#a78bfa';
|
||||
}
|
||||
|
||||
const SUB_SPORT_LABELS: Record<string, string> = {
|
||||
road: 'Road',
|
||||
mountain: 'MTB',
|
||||
gravel: 'Gravel',
|
||||
indoor: 'Indoor',
|
||||
trail: 'Trail',
|
||||
track: 'Track',
|
||||
nordic: 'Nordic',
|
||||
alpine: 'Alpine',
|
||||
open_water: 'Open Water',
|
||||
pool: 'Pool',
|
||||
};
|
||||
|
||||
export function sportLabel(sport: Sport, subSport?: string | null): string {
|
||||
const base = sport.charAt(0).toUpperCase() + sport.slice(1);
|
||||
if (subSport && subSport !== 'generic') {
|
||||
return `${subSport.charAt(0).toUpperCase() + subSport.slice(1)} ${base}`;
|
||||
const sub = SUB_SPORT_LABELS[subSport] ?? (subSport.charAt(0).toUpperCase() + subSport.slice(1));
|
||||
return `${sub} ${base}`;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/** TypeScript types mirroring BAS v1.0 schema. */
|
||||
|
||||
export type Sport = "cycling" | "running" | "hiking" | "walking" | "swimming" | "skiing" | "other";
|
||||
export type SubSport = "road" | "mountain" | "gravel" | "indoor" | "trail" | "track" | "nordic" | null;
|
||||
export type SubSport = "road" | "mountain" | "gravel" | "indoor" | "trail" | "track" | "nordic" | "alpine" | "open_water" | "pool" | null;
|
||||
export type Privacy = "public" | "blur_start" | "no_gps" | "private";
|
||||
|
||||
/** [duration_s, avg_watts] pairs, sorted by duration ascending. */
|
||||
|
||||
Reference in New Issue
Block a user