Show sidebar labels on tablet, improve theme-safe UI, and keep Jalali dates on tracking. Co-authored-by: Cursor <cursoragent@cursor.com>
169 lines
4.2 KiB
Vue
169 lines
4.2 KiB
Vue
<script setup lang="ts">
|
|
import { computed } from 'vue'
|
|
import type { Order, OrderStatus } from '@/types'
|
|
import { ORDER_TRACKING_STEPS } from '@/utils/constants'
|
|
import { getStepTimestamp, getTrackingStepIndex } from '@/utils/orderTracking'
|
|
import { formatDateTime } from '@/utils/format'
|
|
|
|
const props = defineProps<{
|
|
order: Order
|
|
}>()
|
|
|
|
const currentIndex = computed(() => getTrackingStepIndex(props.order.status))
|
|
|
|
function stepState(index: number): 'done' | 'current' | 'pending' {
|
|
if (index < currentIndex.value) return 'done'
|
|
if (index === currentIndex.value) return 'current'
|
|
return 'pending'
|
|
}
|
|
|
|
function timestampFor(step: OrderStatus) {
|
|
const raw = getStepTimestamp(props.order, step)
|
|
return raw ? formatDateTime(raw) : null
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div class="tracking-timeline">
|
|
<div
|
|
v-for="(step, index) in ORDER_TRACKING_STEPS"
|
|
:key="step.status"
|
|
class="tracking-timeline__item"
|
|
:class="`tracking-timeline__item--${stepState(index)}`"
|
|
>
|
|
<div class="tracking-timeline__marker-wrap">
|
|
<div class="tracking-timeline__line" aria-hidden="true" />
|
|
<div class="tracking-timeline__marker">
|
|
<span v-if="stepState(index) === 'done'" class="tracking-timeline__check">✓</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div
|
|
class="tracking-timeline__content"
|
|
:class="{ 'tracking-timeline__content--current': stepState(index) === 'current' }"
|
|
>
|
|
<strong class="tracking-timeline__label">{{ step.label }}</strong>
|
|
<span v-if="timestampFor(step.status)" class="tracking-timeline__time">
|
|
{{ timestampFor(step.status) }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.tracking-timeline {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.tracking-timeline__item {
|
|
display: grid;
|
|
grid-template-columns: 28px minmax(0, 1fr);
|
|
column-gap: 12px;
|
|
align-items: start;
|
|
/* Same vertical rhythm for every step so the connector stays continuous */
|
|
min-height: 44px;
|
|
}
|
|
|
|
.tracking-timeline__marker-wrap {
|
|
position: relative;
|
|
display: flex;
|
|
justify-content: center;
|
|
align-self: stretch;
|
|
width: 28px;
|
|
}
|
|
|
|
.tracking-timeline__line {
|
|
position: absolute;
|
|
top: 22px;
|
|
bottom: 0;
|
|
left: 50%;
|
|
width: 2px;
|
|
transform: translateX(-50%);
|
|
background: var(--color-border);
|
|
z-index: 0;
|
|
}
|
|
|
|
.tracking-timeline__item:last-child .tracking-timeline__line {
|
|
display: none;
|
|
}
|
|
|
|
.tracking-timeline__item--done .tracking-timeline__line {
|
|
background: var(--color-success);
|
|
}
|
|
|
|
.tracking-timeline__item--current .tracking-timeline__line {
|
|
background: color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
|
|
}
|
|
|
|
.tracking-timeline__marker {
|
|
position: relative;
|
|
z-index: 1;
|
|
width: 22px;
|
|
height: 22px;
|
|
margin-top: 2px;
|
|
border-radius: 50%;
|
|
background: var(--color-border);
|
|
border: 2px solid var(--color-border);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
flex-shrink: 0;
|
|
}
|
|
|
|
.tracking-timeline__item--done .tracking-timeline__marker {
|
|
background: var(--color-success);
|
|
border-color: var(--color-success);
|
|
}
|
|
|
|
.tracking-timeline__item--current .tracking-timeline__marker {
|
|
background: var(--color-primary);
|
|
border-color: var(--color-primary);
|
|
box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 28%, transparent);
|
|
}
|
|
|
|
.tracking-timeline__item--pending .tracking-timeline__marker {
|
|
background: var(--color-elevated);
|
|
border-color: var(--color-border);
|
|
}
|
|
|
|
.tracking-timeline__check {
|
|
color: var(--color-surface);
|
|
font-size: 0.75rem;
|
|
font-weight: 700;
|
|
line-height: 1;
|
|
}
|
|
|
|
.tracking-timeline__content {
|
|
min-width: 0;
|
|
padding: 2px 0 14px;
|
|
}
|
|
|
|
.tracking-timeline__content--current {
|
|
padding: 8px 12px 10px;
|
|
border-radius: 12px;
|
|
background: var(--color-primary-soft);
|
|
border: 1px solid color-mix(in srgb, var(--color-primary) 28%, var(--color-border));
|
|
}
|
|
|
|
.tracking-timeline__label {
|
|
display: block;
|
|
font-size: 0.875rem;
|
|
font-weight: 600;
|
|
color: var(--color-text-muted);
|
|
margin-bottom: 2px;
|
|
}
|
|
|
|
.tracking-timeline__item--done .tracking-timeline__label,
|
|
.tracking-timeline__item--current .tracking-timeline__label {
|
|
color: var(--color-text);
|
|
}
|
|
|
|
.tracking-timeline__time {
|
|
display: block;
|
|
font-size: 0.75rem;
|
|
color: var(--color-text-muted);
|
|
}
|
|
</style>
|