File size: 7,877 Bytes
267266e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
import React from 'react';
import type { DriverPrediction, Driver, RacePhase } from '../types';

interface TrackMapPanelProps {
  prediction: DriverPrediction | null;
  driver: Driver | null;
  racePhase: RacePhase;
}

export const TrackMapPanel: React.FC<TrackMapPanelProps> = ({ prediction, driver, racePhase }) => {
  const progress = prediction ? (prediction.lapsCompleted / prediction.totalLaps) : 0;
  
  const monzaPath = "M 500 350 L 200 350 l -15 -10 l -15 10 Q 100 250, 250 150 l 15 10 l 15 -10 L 400 150 Q 430 150, 430 180 L 430 190 Q 430 220, 460 220 Q 550 220, 600 250 l 15 -15 l 20 20 l 15 -15 L 700 290 C 780 290, 780 350, 700 350 Z";

  const renderBadge = () => {
    if (racePhase === 'finished') {
      return (
        <div className="flex items-center gap-1.5 bg-zinc-950 dark:bg-zinc-800 border border-zinc-950 dark:border-zinc-700 px-3 py-1.5 rounded-full shadow-sm">

          <svg width="12" height="12" viewBox="0 0 12 12" className="opacity-90">

            <rect x="0" y="0" width="4" height="4" fill="#fff" />

            <rect x="4" y="0" width="4" height="4" fill="#52525b" />

            <rect x="8" y="0" width="4" height="4" fill="#fff" />

            <rect x="0" y="4" width="4" height="4" fill="#52525b" />

            <rect x="4" y="4" width="4" height="4" fill="#fff" />

            <rect x="8" y="4" width="4" height="4" fill="#52525b" />

            <rect x="0" y="8" width="4" height="4" fill="#fff" />

            <rect x="4" y="8" width="4" height="4" fill="#52525b" />

            <rect x="8" y="8" width="4" height="4" fill="#fff" />

          </svg>

          <span className="text-[10px] font-sans font-bold text-white tracking-widest uppercase">Race Complete</span>

        </div>
      );
    }
    return (
      <div className="flex items-center gap-2 bg-white dark:bg-zinc-800 border border-zinc-200 dark:border-zinc-700 px-3 py-1.5 rounded-full shadow-sm">

        <div className="w-2 h-2 rounded-full bg-racing-red animate-pulse" />

        <span className="text-[10px] font-sans font-bold text-zinc-950 dark:text-zinc-100 tracking-widest uppercase">Live</span>

      </div>
    );
  };

  return (
    <div className="bg-white dark:bg-zinc-900 rounded-2xl shadow-[0_8px_30px_rgb(0,0,0,0.04)] border border-zinc-200 dark:border-zinc-800 p-6 flex flex-col relative overflow-hidden h-full transition-colors duration-200">

      <div className="absolute inset-0 pointer-events-none opacity-[0.03] dark:opacity-[0.02]" 

        style={{

          backgroundImage: `url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 5 L10 20 L15 20 L5 35 L35 35 L25 20 L30 20 Z' fill='%23000' /%3E%3C/svg%3E")`,

          backgroundSize: '80px 80px',

        }} 

      />



      <div className="flex justify-between items-start mb-6 z-10 shrink-0">

        <div className="flex flex-col">

          <div className="flex items-center gap-3">

            <h2 className="font-sans font-bold text-lg text-zinc-950 dark:text-zinc-50 tracking-wide uppercase">MONZA CIRCUIT</h2>

          </div>

          <div className="mt-1 flex flex-col">

            <div className="h-[3px] w-12 flex mb-1.5 rounded-sm overflow-hidden">

              <div className="flex-1 bg-[#009246]" />

              <div className="flex-1 bg-white dark:bg-zinc-700 border-y border-zinc-200 dark:border-zinc-700" />

              <div className="flex-1 bg-[#CE2B37]" />

            </div>

            <span className="text-[10px] font-sans font-bold text-zinc-400 dark:text-zinc-500 uppercase tracking-widest">

              Autodromo Nazionale Monza

            </span>

          </div>

        </div>

        

        {renderBadge()}

      </div>



      <div className="flex-1 relative w-full flex items-center justify-center z-10 min-h-0">

        <div className="w-full aspect-[2.5/1] max-h-full">

          <svg viewBox="50 100 750 300" className="w-full h-full drop-shadow-sm overflow-visible">

            {/* Outer track line */}

            <path 

              d={monzaPath} 

              fill="none" 

              stroke="currentColor" 

              className="text-zinc-200 dark:text-zinc-800"

              strokeWidth="12"

              strokeLinejoin="round"

              strokeLinecap="round"

            />

            {/* Inner track centerline */}

            <path 

              d={monzaPath} 

              fill="none" 

              stroke="currentColor" 

              className="text-zinc-900 dark:text-zinc-500"

              strokeWidth="3"

              strokeLinejoin="round"

              strokeLinecap="round"

            />

            

            {racePhase !== 'pre-race' && driver && (

              <path 

                d={monzaPath} 

                fill="none" 

                stroke="#E10600" 

                strokeWidth="10"

                strokeLinejoin="round"

                strokeLinecap="round"

                pathLength="1"

                strokeDasharray="0.001 1"

                strokeDashoffset={-progress}

                className="drop-shadow-[0_0_8px_rgba(225,6,0,0.8)]"

              />

            )}



            {racePhase !== 'pre-race' && (

              <>

                {/* Lesmo 1 Callout */}

                <g transform="translate(415, 145)">

                  <rect x="-35" y="-45" width="70" height="30" rx="4" className="fill-white dark:fill-zinc-800 stroke-zinc-900 dark:stroke-zinc-600" strokeWidth="1.5" />

                  <text x="0" y="-31" textAnchor="middle" className="font-sans text-[9px] font-black tracking-wider uppercase fill-zinc-900 dark:fill-zinc-100">Lesmo 1</text>

                  <text x="0" y="-18" textAnchor="middle" className="font-display text-[11px] font-bold tabular-nums" fill="#E10600">+0.12s</text>

                  <path d="M -5 -15 L 5 -15 L 0 -8 Z" className="fill-zinc-900 dark:fill-zinc-600" />

                  <circle cx="0" cy="0" r="3" className="fill-zinc-900 dark:fill-zinc-600" />

                </g>



                {/* Ascari Callout */}

                <g transform="translate(635, 235)">

                  <rect x="-35" y="-45" width="70" height="30" rx="4" className="fill-white dark:fill-zinc-800 stroke-zinc-900 dark:stroke-zinc-600" strokeWidth="1.5" />

                  <text x="0" y="-31" textAnchor="middle" className="font-sans text-[9px] font-black tracking-wider uppercase fill-zinc-900 dark:fill-zinc-100">Ascari</text>

                  <text x="0" y="-18" textAnchor="middle" className="font-display text-[11px] font-bold tabular-nums fill-zinc-900 dark:fill-zinc-100">-0.05s</text>

                  <path d="M -5 -15 L 5 -15 L 0 -8 Z" className="fill-zinc-900 dark:fill-zinc-600" />

                  <circle cx="0" cy="0" r="3" className="fill-zinc-900 dark:fill-zinc-600" />

                </g>



                {/* Parabolica Callout */}

                <g transform="translate(740, 320)">

                  <rect x="-35" y="-45" width="70" height="30" rx="4" className="fill-white dark:fill-zinc-800 stroke-zinc-900 dark:stroke-zinc-600" strokeWidth="1.5" />

                  <text x="0" y="-31" textAnchor="middle" className="font-sans text-[9px] font-black tracking-wider uppercase fill-zinc-900 dark:fill-zinc-100">Parabolica</text>

                  <text x="0" y="-18" textAnchor="middle" className="font-display text-[11px] font-bold tabular-nums" fill="#E10600">+0.23s</text>

                  <path d="M -5 -15 L 5 -15 L 0 -8 Z" className="fill-zinc-900 dark:fill-zinc-600" />

                  <circle cx="0" cy="0" r="3" className="fill-zinc-900 dark:fill-zinc-600" />

                </g>

              </>

            )}

          </svg>

        </div>

      </div>
    </div>
  );
};