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" ;
88import React , { useState } from "react" ;
99
1010import { 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 ) }
0 commit comments