2021-09-24 06:51:17 -04:00
|
|
|
import React from 'react'
|
|
|
|
|
|
|
|
import type {Card} from './types.ts'
|
|
|
|
import CardToken from './cards/Card.tsx'
|
|
|
|
|
|
|
|
const EMPTY_SPACE = '-'
|
|
|
|
|
|
|
|
interface CardTokenProps {
|
|
|
|
card: Card | null
|
|
|
|
onSelect: () => void
|
2021-09-24 22:51:26 -04:00
|
|
|
isSelected: boolean
|
|
|
|
disabled: boolean
|
2021-09-24 06:51:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
export default function BoardSlot(props: CardTokenProps): JSX.Element {
|
2021-09-24 22:51:26 -04:00
|
|
|
const {onSelect, card, isSelected, disabled} = props
|
2021-09-24 06:51:17 -04:00
|
|
|
|
2021-09-24 22:51:26 -04:00
|
|
|
if (card === null || card.type === -1) {
|
2021-09-24 06:51:17 -04:00
|
|
|
return (
|
2021-09-24 22:51:26 -04:00
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className={`board-slot${isSelected ? ' selected' : ''}`}
|
|
|
|
onClick={onSelect}
|
|
|
|
disabled={disabled}
|
|
|
|
>
|
2021-09-24 06:51:17 -04:00
|
|
|
<span>{EMPTY_SPACE}</span>
|
|
|
|
</button>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return (
|
2021-09-24 22:51:26 -04:00
|
|
|
<CardToken
|
|
|
|
onSelect={onSelect}
|
|
|
|
cardKey={card.type}
|
|
|
|
isSelected={isSelected}
|
|
|
|
disabled={disabled}
|
|
|
|
/>
|
2021-09-24 06:51:17 -04:00
|
|
|
)
|
|
|
|
}
|