--- /dev/null
+export interface ProgressBarOptions {
+ startingColor: string;
+ endingColor: string;
+}
+
+export function ProgressBar(current: number, max: number, id: string, opts: ProgressBarOptions) {
+ let percent = 0;
+ if(max > 0) {
+ percent = Math.floor((current / max) * 100);
+ }
+
+ return `<div class="progress-bar" id="${id}" style="background: linear-gradient(to right, ${opts.startingColor}, ${opts.endingColor} ${percent}%, transparent ${percent}%, transparent)"
+title="${percent}% - ${current}/${max}">${current}/${max} - ${percent}%</div>`;
+}
import { TravelDTO } from "../../shared/map";
+import { ProgressBar } from './components/progress-bar';
export function travelButton(blockTime: number): string {
return `<button id="keep-walking" hx-post="/travel/step" class="${blockTime ? 'disabled': ''}" data-block="${blockTime}" ${blockTime ? 'disabled': ''}>Keep Walking</button>`;
let html = `<section id="explore" class="tab active" hx-swap-oob="true" style="background-image: url('/assets/img/map/${data.closestTown}.jpeg')">
-<div id="travelling" class="city-details">`;
+<div id="travelling" class="city-details">
+ <div class="travel-distance">
+ <p>Travelling from ${data.travelPlan.source_city_name} to ${data.travelPlan.destination_city_name}</p>
+ ${ProgressBar(data.travelPlan.current_position, data.travelPlan.total_distance, 'travel-plan', {
+ startingColor: '#d9975a',
+ endingColor: '#bb724c'
+ })}
+ </div>
+`;
html += '<div id="travelling-actions">';
html += travelButton(blockTime);
if(data.things.length) {