summaryrefslogtreecommitdiff
path: root/frontend/src/components/game
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2019-02-26 18:27:57 +0100
committerjbion <joffrey.bion@amadeus.com>2019-02-26 18:27:57 +0100
commitfd2b0f4b223c4a92de0e10cbabd21955436c150d (patch)
tree16c5798338b3a992f537c6b777081add517e7127 /frontend/src/components/game
parentHide start button for non-game owners and disable while we can't start (diff)
downloadseven-wonders-fd2b0f4b223c4a92de0e10cbabd21955436c150d.tar.gz
seven-wonders-fd2b0f4b223c4a92de0e10cbabd21955436c150d.tar.bz2
seven-wonders-fd2b0f4b223c4a92de0e10cbabd21955436c150d.zip
Extract CardImage
Diffstat (limited to 'frontend/src/components/game')
-rw-r--r--frontend/src/components/game/CardImage.jsx15
-rw-r--r--frontend/src/components/game/Hand.jsx6
2 files changed, 17 insertions, 4 deletions
diff --git a/frontend/src/components/game/CardImage.jsx b/frontend/src/components/game/CardImage.jsx
new file mode 100644
index 00000000..110d9883
--- /dev/null
+++ b/frontend/src/components/game/CardImage.jsx
@@ -0,0 +1,15 @@
+import React from 'react';
+import type { ApiCard } from '../../api/model';
+import './Hand.css'
+
+type CardImageProps = {
+ card: ApiCard,
+ otherClasses: string
+}
+
+export const CardImage = ({card, otherClasses}: CardImageProps) => {
+ return <img src={`/images/cards/${card.image}`}
+ title={card.name}
+ alt={'Card ' + card.name}
+ className={`card-img ${otherClasses}`}/>
+};
diff --git a/frontend/src/components/game/Hand.jsx b/frontend/src/components/game/Hand.jsx
index 2b8ca196..9b29742e 100644
--- a/frontend/src/components/game/Hand.jsx
+++ b/frontend/src/components/game/Hand.jsx
@@ -2,6 +2,7 @@ import { Button, ButtonGroup, Classes, Intent } from '@blueprintjs/core';
import React from 'react';
import type { ApiHandCard, ApiPlayerMove } from '../../api/model';
import './Hand.css'
+import { CardImage } from './CardImage';
type HandProps = {
cards: ApiHandCard[],
@@ -24,10 +25,7 @@ type HandCardProps = {
const HandCard = ({card, wonderUpgradable, prepareMove}: HandCardProps) => {
let playableClass = card.playability.playable ? '' : 'unplayable';
return <div className={`hand-card ${playableClass}`}>
- <img src={`/images/cards/${card.image}`}
- title={card.name}
- alt={'Card ' + card.name}
- className="hand-card-img"/>
+ <CardImage card={card} otherClasses="hand-card-img"/>
<ActionButtons card={card} wonderUpgradable={wonderUpgradable} prepareMove={prepareMove} />
</div>
};
bgstack15