From 150b7749ae56e3ff19441878006760f118499c19 Mon Sep 17 00:00:00 2001 From: Spythere Date: Mon, 9 Feb 2026 00:52:11 +0100 Subject: [PATCH] chore(profile): added level badges for player summary --- src/composables/badge.ts | 8 +++ src/views/PlayerProfileView.vue | 118 ++++++++++++++++++++++++-------- 2 files changed, 99 insertions(+), 27 deletions(-) create mode 100644 src/composables/badge.ts diff --git a/src/composables/badge.ts b/src/composables/badge.ts new file mode 100644 index 0000000..43a7e27 --- /dev/null +++ b/src/composables/badge.ts @@ -0,0 +1,8 @@ +export function calculateExpStyles(exp: number, isSupporter = false) { + const bgColor = exp > -1 ? (exp < 2 ? '#26B0D9' : `hsl(${-exp * 5 + 100}, 85%, 50%)`) : '#666'; + + const fontColor = exp > 14 || exp == -1 ? 'white' : 'black'; + const boxShadow = isSupporter ? `0 0 6px 2px ${bgColor};` : ''; + + return { 'background-color': bgColor, color: fontColor, 'box-shadow': boxShadow }; +} diff --git a/src/views/PlayerProfileView.vue b/src/views/PlayerProfileView.vue index 6691b8d..40aa69b 100644 --- a/src/views/PlayerProfileView.vue +++ b/src/views/PlayerProfileView.vue @@ -3,37 +3,73 @@
- player image +
+ player image -

{{ playerName }}

+ -

{{ playerTD2Info.levels.driver }} poziom maszynisty

-

{{ playerTD2Info.levels.dispatcher }} poziom dyżurnego

+
+

{{ playerName }}

-
-
- ONLINE JAKO DR: - {{ - playerInfo.currentActivity.dispatcher - .map((d) => `${d.stationName} (${d.stationHash})`) - .join(', ') - }} +
+
+ + {{ + playerInfo.driverStats.driverLevel > 1 + ? playerInfo.driverStats.driverLevel + : 'L' + }} + + MASZYNISTA +
+ +
+ + {{ + playerInfo.dispatcherStats.dispatcherLevel > 1 + ? playerInfo.dispatcherStats.dispatcherLevel + : 'L' + }} + + DYŻURNY RUCHU +
+
+
-
- ONLINE JAKO MASZYNISTA: - {{ playerInfo.currentActivity.driver }} -
+
+ ONLINE JAKO DR: + {{ + playerInfo.currentActivity.dispatcher + .map((d) => `${d.stationName} (${d.stationHash})`) + .join(', ') + }} +
+ +
+ ONLINE JAKO MASZYNISTA: + {{ playerInfo.currentActivity.driver.trainNo }}
@@ -168,7 +204,7 @@
spawn icon

- {{ playerInfo.driverStatsLastMonth.currentDistanceTotal || 0 }} + {{ playerInfo.driverStatsLastMonth.currentDistanceTotal?.toFixed(2) || 0 }}

@@ -295,6 +331,7 @@ import axios from 'axios'; import { getCountPercentage } from '../utils/calcUtils'; import { Status } from '../typings/common'; import Loading from '../components/Global/Loading.vue'; +import { calculateExpStyles } from '../composables/badge'; type JournalEntryType = 'Timetable' | 'Dispatcher' | 'IssuedTimetable'; @@ -375,6 +412,7 @@ const combinedJournal = computed(() => { async function fetchAllData() { const playerId = route.query.playerId?.toString(); + playerTD2Info.value = null; playerDataStatus.value = Status.Data.Loading; if (!playerId) { @@ -484,6 +522,7 @@ function toggleFilter(filterType: JournalEntryType) {