tome-web/client/game/cards/Card.tsx

29 lines
537 B
TypeScript
Raw Normal View History

2021-09-23 23:34:33 -04:00
import React from 'react'
import {CardKey, getCardSrc} from './cards.ts'
const EMPTY_SPACE = '-'
interface CardTokenProps {
cardKey: CardKey | null
onClick?: () => void
}
export default function CardToken(props: CardTokenProps): JSX.Element {
const {onClick, cardKey} = props
if (cardKey == null) {
return (
<button>
<span>{EMPTY_SPACE}</span>
</button>
)
}
const card = getCardSrc(cardKey)
return (
<button onClick={onClick}>
<img src={card} alt={cardKey} />
</button>
)
}