guandan.dev

guandan.dev

https://git.tonybtw.com/guandan.dev.git git://git.tonybtw.com/guandan.dev.git
2,345 bytes raw
1
import { Card as Card_Type, Rank } from '../game/types'
2
import { Card } from './Card'
3
4
interface Table_Props {
5
  cards: Card_Type[]
6
  level: Rank
7
  combo_type: string
8
  last_play_seat?: number | null
9
}
10
11
export function Table({ cards, level, combo_type, last_play_seat }: Table_Props) {
12
  const card_width = 70
13
  const overlap = 40
14
  const show_highlight = last_play_seat !== null && last_play_seat !== undefined && cards.length > 0
15
16
  return (
17
    <div
18
      style={{
19
        display: 'flex',
20
        flexDirection: 'column',
21
        alignItems: 'center',
22
        justifyContent: 'center',
23
        minHeight: 180,
24
        padding: 20,
25
        borderRadius: 12,
26
        transition: 'background-color 0.2s ease, box-shadow 0.2s ease',
27
        backgroundColor: show_highlight ? 'rgba(76, 175, 80, 0.15)' : 'transparent',
28
        boxShadow: show_highlight ? '0 0 20px rgba(76, 175, 80, 0.4)' : 'none',
29
      }}
30
    >
31
      <div
32
        style={{
33
          display: 'flex',
34
          position: 'relative',
35
          width: cards.length > 0 ? card_width + (cards.length - 1) * overlap : 100,
36
          height: 100,
37
          justifyContent: 'center',
38
        }}
39
      >
40
        {cards.length > 0 ? (
41
          cards.map((card, index) => (
42
            <div
43
              key={`table-${card.Id}`}
44
              style={{
45
                position: 'absolute',
46
                left: index * overlap,
47
                zIndex: index,
48
              }}
49
            >
50
              <Card
51
                card={card}
52
                level={level}
53
                selected={false}
54
                on_click={() => {}}
55
              />
56
            </div>
57
          ))
58
        ) : (
59
          <div
60
            style={{
61
              display: 'flex',
62
              alignItems: 'center',
63
              justifyContent: 'center',
64
              color: '#666',
65
              fontSize: 14,
66
              opacity: 0.5,
67
            }}
68
          >
69
            No cards played
70
          </div>
71
        )}
72
      </div>
73
      {combo_type && (
74
        <div
75
          style={{
76
            marginTop: 12,
77
            padding: '4px 12px',
78
            backgroundColor: '#333',
79
            color: '#fff',
80
            borderRadius: 4,
81
            fontSize: 12,
82
            textTransform: 'uppercase',
83
          }}
84
        >
85
          {combo_type}
86
        </div>
87
      )}
88
    </div>
89
  )
90
}