@papanasi/solid
Advanced tools
Comparing version 1.0.0-rc.102 to 1.0.0-rc.103
@@ -10,6 +10,8 @@ import { Show, onMount, createSignal } from "solid-js"; | ||
const [gameInfo, setGameInfo] = createSignal(null); | ||
let actionRef; | ||
function onClickAction(user, game, width, height) { | ||
itchioService.onClickAction(user, game, width, height); | ||
} | ||
onMount(() => { | ||
setClasses(itchioService.getClasses(props.className)); | ||
itchioService.processInfo(actionRef, props.user, props.game, props.width, props.height, props.secret, (data) => { | ||
itchioService.processInfo(props.user, props.game, props.secret, (data) => { | ||
setGameInfo(data); | ||
@@ -32,3 +34,3 @@ setLoaded(true); | ||
</Show> | ||
<span class="pa-itchio__children" ref={actionRef}> | ||
<span class="pa-itchio__children" onClick={(event) => onClickAction(props.user, props.game, props.width, props.height)}> | ||
<Show when={loaded()}> | ||
@@ -35,0 +37,0 @@ <span>{props.children}</span> |
@@ -21,2 +21,3 @@ import type { BaseProps, BaseState, Children } from '../../../models'; | ||
gameInfo: ItchioGameInfo; | ||
onClickAction: (user: string, game: string, width: number, height: number) => void; | ||
} & BaseState; |
@@ -6,8 +6,8 @@ import type { ItchioGameInfo } from './itchio.model'; | ||
}; | ||
attachButton(actionRef: any, user: string, game: string, width: number, height: number): void; | ||
getGameData(actionRef: any, user: string, game: string, width: number, height: number, secret: string): Promise<ItchioGameInfo>; | ||
getGameData(user: string, game: string, secret: string): Promise<ItchioGameInfo>; | ||
loadScript(): Promise<void>; | ||
processInfo(actionRef: any, user: string, game: string, width: number, height: number, secret: string, callback: (data: ItchioGameInfo) => void): Promise<void>; | ||
processInfo(user: string, game: string, secret: string, callback: (data: ItchioGameInfo) => void): Promise<void>; | ||
onClickAction(user: string, game: string, width?: number, height?: number): void; | ||
} | ||
export declare const itchioService: ItchioService; | ||
export {}; |
@@ -8,13 +8,4 @@ import { getWindow } from 'ssr-window'; | ||
} | ||
attachButton(actionRef, user, game, width, height) { | ||
async getGameData(user, game, secret) { | ||
const window = getWindow(); | ||
window['Itch'].attachBuyButton(actionRef, { | ||
user: user, | ||
game: game, | ||
width: width || 800, | ||
height: height || 600 | ||
}); | ||
} | ||
async getGameData(actionRef, user, game, width, height, secret) { | ||
const window = getWindow(); | ||
return new Promise((resolve) => { | ||
@@ -26,3 +17,2 @@ window['Itch'].getGameData({ | ||
onComplete: (data) => { | ||
this.attachButton(actionRef, user, game, width, height); | ||
resolve(data); | ||
@@ -38,8 +28,18 @@ } | ||
} | ||
async processInfo(actionRef, user, game, width, height, secret, callback) { | ||
async processInfo(user, game, secret, callback) { | ||
await this.loadScript(); | ||
const data = await this.getGameData(actionRef, user, game, width, height, secret); | ||
const data = await this.getGameData(user, game, secret); | ||
callback && callback(data); | ||
} | ||
onClickAction(user, game, width = 800, height = 600) { | ||
const window = getWindow(); | ||
const domain = 'itch.io'; | ||
const top = (screen.height - height) / 2; | ||
const left = (screen.width - width) / 2; | ||
const openedWindow = window.open('https://' + user + '.' + domain + '/' + game + '/purchase?popup=1', 'purchase', 'scrollbars=1, resizable=no, width=' + width + ', height=' + height + ', top=' + top + ', left=' + left); | ||
if (typeof openedWindow.focus === 'function') { | ||
openedWindow.focus(); | ||
} | ||
} | ||
} | ||
export const itchioService = new ItchioService(); |
{ | ||
"name": "@papanasi/solid", | ||
"version": "1.0.0-rc.102", | ||
"version": "1.0.0-rc.103", | ||
"license": "MIT", | ||
@@ -34,3 +34,3 @@ "author": "ckgrafico/papanasi", | ||
}, | ||
"gitHead": "3f6dbe3781c4545393ec1a2b59629b0b17d867f3" | ||
"gitHead": "9fbcaf338a28cf607fe26ff3ab8a1db1e6711f57" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1356873
26566