Skip to content

Commit f03c36f

Browse files
committed
uses game image as background for game embed
1 parent b0bb208 commit f03c36f

2 files changed

Lines changed: 28 additions & 14 deletions

File tree

client/src/components/ui/GameEmbed.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// - would need to save embed link, width and height to db
55
// - this method is reliant on itch.io staying up and not changing anything
66
// - would want a play button so it doesn't autoload (especially for bigger more intense games)
7-
7+
import Image from "next/image";
88
import React, { useState } from "react";
99

1010
import { Button } from "./button";
@@ -13,33 +13,46 @@ type GameEmbedProps = {
1313
embedID: string;
1414
gameWidth: number;
1515
gameHeight: number;
16+
gameImage: string;
1617
};
1718

18-
export function GameEmbed({ embedID, gameWidth, gameHeight }: GameEmbedProps) {
19+
export function GameEmbed({
20+
embedID,
21+
gameWidth,
22+
gameHeight,
23+
gameImage,
24+
}: GameEmbedProps) {
1925
const [isPlaying, setIsPlaying] = useState(false);
2026

2127
return (
2228
<div
23-
className={
24-
"flex items-center justify-center border-[26px] border-accent bg-background p-2 [clip-path:polygon(20px_20px,calc(100%-20px)_20px,100%_32px,100%_30%,calc(100%-20px)_45%,calc(100%-20px)_calc(100%-8px),80%_calc(100%-8px),75%_calc(100%-20px),20px_calc(100%-20px),0%_60%,0%_30%,20px_25%)]"
25-
}
26-
style={{ width: gameWidth, height: gameHeight }}
29+
className={`flex items-center justify-center border-[26px] border-accent bg-background [clip-path:polygon(20px_20px,calc(100%-20px)_20px,100%_32px,100%_30%,calc(100%-20px)_45%,calc(100%-20px)_calc(100%-8px),80%_calc(100%-8px),75%_calc(100%-20px),20px_calc(100%-20px),0%_60%,0%_30%,20px_25%)]`}
30+
style={{ width: gameWidth + 26 * 2, height: gameHeight + 26 * 2 }}
2731
>
2832
{!isPlaying ? (
29-
<Button
30-
onClick={() => setIsPlaying(!isPlaying)}
31-
size={"lg"}
32-
className="text-3xl"
33-
>
34-
Play
35-
</Button>
33+
<div>
34+
<Image
35+
src={gameImage}
36+
alt="Game Cover"
37+
width={gameWidth}
38+
height={gameHeight}
39+
className="absolute left-[50%] top-[50%] translate-x-[-50%] translate-y-[calc(-50%-52px)] blur-sm"
40+
style={{ width: "auto", height: gameHeight }}
41+
/>
42+
<Button
43+
onClick={() => setIsPlaying(!isPlaying)}
44+
size={"lg"}
45+
className="absolute left-[50%] top-[50%] translate-x-[-50%] translate-y-[calc(-50%-52px)] text-3xl"
46+
>
47+
Play
48+
</Button>
49+
</div>
3650
) : (
3751
<div>
3852
<iframe
3953
src={`https://itch.io/embed-upload/${embedID}?color=110e1a`}
4054
width={gameWidth}
4155
height={gameHeight}
42-
className="min-w-80 border-[26px] border-accent [clip-path:polygon(20px_20px,calc(100%-20px)_20px,100%_32px,100%_30%,calc(100%-20px)_45%,calc(100%-20px)_calc(100%-8px),80%_calc(100%-8px),75%_calc(100%-20px),20px_calc(100%-20px),0%_60%,0%_30%,20px_25%)]"
4356
></iframe>
4457
</div>
4558
)}

client/src/pages/games/[id].tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export default function IndividualGamePage() {
9494
embedID={gameEmbedID}
9595
gameWidth={gameWidth}
9696
gameHeight={gameHeight}
97+
gameImage={gameCover}
9798
/>
9899
</div>
99100
) : (

0 commit comments

Comments
 (0)