File size: 1,461 Bytes
b08dbc1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
export default function GameControls({ turn, onReset, historyLength }) {
  return (
    <div className="comic-card space-y-4">
      <div className="flex items-center justify-between border-b-4 border-black pb-4 mb-4">
        <h2 className="font-['Bangers'] text-2xl">Game Status</h2>
        <div className={`px-3 py-1 border-2 border-black font-bold text-sm uppercase ${turn === 'white' ? 'bg-white' : 'bg-black text-white'}`}>
          {turn}'s Turn
        </div>
      </div>

      <div className="grid grid-cols-2 gap-4">
        <button 
          onClick={onReset}
          className="comic-btn bg-comic-red text-white w-full flex items-center justify-center gap-2"
        >
          <span></span> Reset
        </button>
        <button className="comic-btn bg-comic-blue text-white w-full opacity-50 cursor-not-allowed">
          Undo
        </button>
      </div>

      <div className="bg-gray-100 border-2 border-black p-3 rounded-sm">
        <div className="flex justify-between text-xs font-bold uppercase mb-1">
          <span>Moves</span>
          <span>{Math.ceil(historyLength / 2)}</span>
        </div>
        <div className="w-full bg-gray-300 h-2 border border-black">
          <div 
            className="bg-comic-yellow h-full border-r-2 border-black transition-all duration-500" 
            style={{ width: `${Math.min((historyLength / 80) * 100, 100)}%` }} 
          />
        </div>
      </div>
    </div>
  );
}