added bootstrap styles to TimeLine.svelte
This commit is contained in:
parent
eb7066ac6b
commit
8e9f28a6ac
1 changed files with 122 additions and 205 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { createEventDispatcher } from "svelte";
|
import { createEventDispatcher } from "svelte";
|
||||||
import type { Prediction } from "$lib/types";
|
import type { Prediction } from "$lib/types";
|
||||||
|
import "bootstrap-icons/font/bootstrap-icons.css";
|
||||||
|
|
||||||
let { prediction }: { prediction: Prediction | null } = $props();
|
let { prediction }: { prediction: Prediction | null } = $props();
|
||||||
|
|
||||||
|
|
@ -11,6 +12,7 @@
|
||||||
let isPlaying = $state(false);
|
let isPlaying = $state(false);
|
||||||
let currentIndex = $state(0);
|
let currentIndex = $state(0);
|
||||||
let playbackSpeed = $state(1);
|
let playbackSpeed = $state(1);
|
||||||
|
let isCollapsed = $state(false);
|
||||||
let animationFrame: number | null = null;
|
let animationFrame: number | null = null;
|
||||||
let lastUpdateTime = 0;
|
let lastUpdateTime = 0;
|
||||||
|
|
||||||
|
|
@ -119,11 +121,15 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeSpeed() {
|
function changeSpeed() {
|
||||||
const speeds = [1, 2, 5, 10];
|
const speeds = [1, 2, 5, 0.5];
|
||||||
const currentSpeedIndex = speeds.indexOf(playbackSpeed);
|
const currentSpeedIndex = speeds.indexOf(playbackSpeed);
|
||||||
playbackSpeed = speeds[(currentSpeedIndex + 1) % speeds.length];
|
playbackSpeed = speeds[(currentSpeedIndex + 1) % speeds.length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleToggleCollapse() {
|
||||||
|
isCollapsed = !isCollapsed;
|
||||||
|
}
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
return () => {
|
return () => {
|
||||||
if (animationFrame !== null) {
|
if (animationFrame !== null) {
|
||||||
|
|
@ -133,20 +139,40 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="timeline-container">
|
<div class="timeline-container card shadow-sm">
|
||||||
<div class="timeline-info">
|
<div
|
||||||
|
class="card-header bg-primary text-white d-flex justify-content-between align-items-center p-1 px-3"
|
||||||
|
style="cursor:pointer;"
|
||||||
|
onclick={handleToggleCollapse}
|
||||||
|
role="button"
|
||||||
|
tabindex="0"
|
||||||
|
onkeydown={(e) => e.key === 'Enter' && handleToggleCollapse()}
|
||||||
|
>
|
||||||
|
<span class="fw-bold mb-0">Flight Timeline</span>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-sm btn-primary p-0"
|
||||||
|
aria-label="Toggle timeline visibility"
|
||||||
|
>
|
||||||
|
<i class="bi {isCollapsed ? 'bi-caret-left-fill' : 'bi-caret-down-fill'}"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{#if !isCollapsed}
|
||||||
|
<div class="card-body p-3">
|
||||||
|
<div class="timeline-info mb-2">
|
||||||
<div class="info-section">
|
<div class="info-section">
|
||||||
<span class="label">Time:</span>
|
<span class="form-label mb-1">Time:</span>
|
||||||
<span class="value">{timeElapsed}</span>
|
<span class="fw-bold font-monospace">{timeElapsed}</span>
|
||||||
</div>
|
</div>
|
||||||
{#if currentPosition}
|
{#if currentPosition}
|
||||||
<div class="info-section">
|
<div class="info-section">
|
||||||
<span class="label">Altitude:</span>
|
<span class="form-label mb-1">Altitude:</span>
|
||||||
<span class="value">{Math.round(currentPosition.alt)} m</span>
|
<span class="fw-bold font-monospace">{Math.round(currentPosition.alt)} m</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="info-section">
|
<div class="info-section">
|
||||||
<span class="label">Position:</span>
|
<span class="form-label mb-1">Position:</span>
|
||||||
<span class="value"
|
<span class="fw-bold font-monospace"
|
||||||
>{currentPosition.lat.toFixed(4)}, {currentPosition.lng.toFixed(4)}</span
|
>{currentPosition.lat.toFixed(4)}, {currentPosition.lng.toFixed(4)}</span
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -154,49 +180,67 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="timeline-controls">
|
<div class="timeline-controls">
|
||||||
<div class="control-buttons">
|
<div class="btn-group me-2" role="group">
|
||||||
<button
|
<button
|
||||||
class="control-btn"
|
type="button"
|
||||||
on:click={stop}
|
class="btn btn-sm btn-outline-primary"
|
||||||
|
onclick={stop}
|
||||||
disabled={!prediction || currentIndex === 0}
|
disabled={!prediction || currentIndex === 0}
|
||||||
title="Start"
|
title="Reset to start"
|
||||||
|
aria-label="Reset to start"
|
||||||
>
|
>
|
||||||
<i class="bi bi-skip-start-fill"></i>
|
<i class="bi bi-skip-start-fill"></i>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{#if !isPlaying}
|
{#if !isPlaying}
|
||||||
<button class="control-btn play-btn" on:click={play} disabled={!prediction} title="Play">
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-sm btn-success"
|
||||||
|
onclick={play}
|
||||||
|
disabled={!prediction}
|
||||||
|
title="Play animation"
|
||||||
|
aria-label="Play animation"
|
||||||
|
>
|
||||||
<i class="bi bi-play-fill"></i>
|
<i class="bi bi-play-fill"></i>
|
||||||
</button>
|
</button>
|
||||||
{:else}
|
{:else}
|
||||||
<button class="control-btn" on:click={pause} title="Pause">
|
<button
|
||||||
|
type="button"
|
||||||
|
class="btn btn-sm btn-warning"
|
||||||
|
onclick={pause}
|
||||||
|
title="Pause animation"
|
||||||
|
aria-label="Pause animation"
|
||||||
|
>
|
||||||
<i class="bi bi-pause-fill"></i>
|
<i class="bi bi-pause-fill"></i>
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<button
|
<button
|
||||||
class="control-btn speed-btn"
|
type="button"
|
||||||
on:click={changeSpeed}
|
class="btn btn-sm btn-outline-secondary"
|
||||||
|
onclick={changeSpeed}
|
||||||
disabled={!prediction}
|
disabled={!prediction}
|
||||||
title="Speed"
|
title="Change playback speed"
|
||||||
|
aria-label="Change playback speed"
|
||||||
>
|
>
|
||||||
{playbackSpeed}x
|
{playbackSpeed}x
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="progress-container">
|
<div class="flex-grow-1 position-relative">
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="range"
|
||||||
min="0"
|
min="0"
|
||||||
max={flightPathLength - 1}
|
max={flightPathLength - 1}
|
||||||
value={currentIndex}
|
value={currentIndex}
|
||||||
on:input={handleSliderChange}
|
oninput={handleSliderChange}
|
||||||
disabled={!prediction}
|
disabled={!prediction}
|
||||||
class="timeline-slider"
|
class="form-range timeline-slider"
|
||||||
/>
|
/>
|
||||||
<div class="progress-bar" style="width: {progress}%"></div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -205,172 +249,53 @@
|
||||||
bottom: 20px;
|
bottom: 20px;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
background: rgba(255, 255, 255, 0.95);
|
min-width: 500px;
|
||||||
border-radius: 12px;
|
max-width: 700px;
|
||||||
padding: 16px 20px;
|
|
||||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
||||||
min-width: 600px;
|
|
||||||
max-width: 800px;
|
|
||||||
z-index: 1000;
|
z-index: 1000;
|
||||||
|
background: var(--bs-body-bg, #fff);
|
||||||
backdrop-filter: blur(10px);
|
backdrop-filter: blur(10px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-info {
|
.timeline-info {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-around;
|
justify-content: space-around;
|
||||||
margin-bottom: 12px;
|
gap: 0.5rem;
|
||||||
gap: 16px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-section {
|
.info-section {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 4px;
|
gap: 0.001rem;
|
||||||
}
|
flex: 1;
|
||||||
|
|
||||||
.label {
|
|
||||||
font-size: 11px;
|
|
||||||
color: #666;
|
|
||||||
text-transform: uppercase;
|
|
||||||
font-weight: 600;
|
|
||||||
letter-spacing: 0.5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.value {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #000;
|
|
||||||
font-weight: 600;
|
|
||||||
font-family: monospace;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-controls {
|
.timeline-controls {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 0.5rem;
|
||||||
}
|
|
||||||
|
|
||||||
.control-buttons {
|
|
||||||
display: flex;
|
|
||||||
gap: 8px;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.control-btn {
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
border: none;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: #007bff;
|
|
||||||
color: white;
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-size: 18px;
|
|
||||||
transition: all 0.2s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.control-btn:hover:not(:disabled) {
|
|
||||||
background: #0056b3;
|
|
||||||
transform: scale(1.1);
|
|
||||||
}
|
|
||||||
|
|
||||||
.control-btn:disabled {
|
|
||||||
background: #ccc;
|
|
||||||
cursor: not-allowed;
|
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.play-btn {
|
|
||||||
width: 48px;
|
|
||||||
height: 48px;
|
|
||||||
font-size: 22px;
|
|
||||||
background: #28a745;
|
|
||||||
}
|
|
||||||
|
|
||||||
.play-btn:hover:not(:disabled) {
|
|
||||||
background: #218838;
|
|
||||||
}
|
|
||||||
|
|
||||||
.speed-btn {
|
|
||||||
border-radius: 8px;
|
|
||||||
width: 50px;
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 700;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-container {
|
|
||||||
flex: 1;
|
|
||||||
position: relative;
|
|
||||||
height: 40px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timeline-slider {
|
|
||||||
width: 100%;
|
|
||||||
height: 6px;
|
|
||||||
border-radius: 3px;
|
|
||||||
outline: none;
|
|
||||||
background: #e0e0e0;
|
|
||||||
-webkit-appearance: none;
|
|
||||||
appearance: none;
|
|
||||||
cursor: pointer;
|
|
||||||
position: relative;
|
|
||||||
z-index: 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Custom range slider styling to match Bootstrap theme */
|
||||||
.timeline-slider::-webkit-slider-thumb {
|
.timeline-slider::-webkit-slider-thumb {
|
||||||
-webkit-appearance: none;
|
background: var(--bs-primary, #007bff);
|
||||||
appearance: none;
|
|
||||||
width: 18px;
|
|
||||||
height: 18px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: #007bff;
|
|
||||||
cursor: pointer;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-slider::-moz-range-thumb {
|
.timeline-slider::-moz-range-thumb {
|
||||||
width: 18px;
|
background: var(--bs-primary, #007bff);
|
||||||
height: 18px;
|
|
||||||
border-radius: 50%;
|
|
||||||
background: #007bff;
|
|
||||||
cursor: pointer;
|
|
||||||
border: none;
|
|
||||||
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-slider:disabled {
|
/* Responsive design */
|
||||||
cursor: not-allowed;
|
@media (max-width: 767.98px) {
|
||||||
opacity: 0.5;
|
|
||||||
}
|
|
||||||
|
|
||||||
.progress-bar {
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
height: 6px;
|
|
||||||
background: linear-gradient(90deg, #007bff 0%, #0056b3 100%);
|
|
||||||
border-radius: 3px;
|
|
||||||
transition: width 0.05s linear;
|
|
||||||
pointer-events: none;
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.timeline-container {
|
.timeline-container {
|
||||||
min-width: 90%;
|
min-width: calc(100vw - 40px);
|
||||||
max-width: 90%;
|
max-width: calc(100vw - 40px);
|
||||||
padding: 12px 16px;
|
bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.timeline-info {
|
.timeline-info {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
gap: 8px;
|
gap: 0.5rem;
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.info-section {
|
.info-section {
|
||||||
|
|
@ -378,16 +303,8 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
.control-btn {
|
.btn-group {
|
||||||
width: 36px;
|
flex-wrap: nowrap;
|
||||||
height: 36px;
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.play-btn {
|
|
||||||
width: 42px;
|
|
||||||
height: 42px;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue