Skip to content

Commit

Permalink
update GameSlide.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Oct 27, 2023
1 parent 1c50a2b commit 77939d0
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions kiosk/src/Components/GameSlide.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useContext } from "react";
import { useContext, useMemo } from "react";
import { playSoundEffect } from "../Services/SoundEffectService";
import { launchGame } from "../Transforms/launchGame";
import { GameData, HighScore } from "../Types";
import { GameData } from "../Types";
import { AppStateContext } from "../State/AppStateContext";
import HighScoresList from "./HighScoresList";
import { GameMenu } from "./GameMenu";
import { getHighScores } from "../State";
import { getEffectiveGameId } from "../Utils";

interface IProps {
game: GameData;
Expand All @@ -19,13 +20,20 @@ const GameSlide: React.FC<IProps> = ({ game }) => {
launchGame(game.id);
};

const thumbnailUrl = useMemo(() => {
if (game) {
const gameId = getEffectiveGameId(game);
return `url("https://makecode.com/api/${gameId}/thumb")`;
}
}, [game, game?.staticGameId]);

return (
<div className="gameTile" onClick={handleSlideClick}>
<div className="gameSelectionIndicator" />
<div
className="gameThumbnail"
style={{
backgroundImage: `url("https://makecode.com/api/${game.id}/thumb")`,
backgroundImage: thumbnailUrl,
}}
/>

Expand Down

0 comments on commit 77939d0

Please sign in to comment.