From d81f17d9487ad67353b7fa30b3ef5b7d81f404d6 Mon Sep 17 00:00:00 2001 From: Joffrey BION Date: Mon, 30 Apr 2018 01:33:32 +0200 Subject: Add flow prop types in scene components --- frontend/src/scenes/GameBrowser/index.js | 13 ++++++++++--- frontend/src/scenes/Lobby/index.js | 9 ++++++++- frontend/src/scenes/SplashScreen/components/HomeLayout.js | 8 ++++++-- frontend/src/scenes/SplashScreen/index.js | 6 +++++- 4 files changed, 29 insertions(+), 7 deletions(-) (limited to 'frontend/src/scenes') diff --git a/frontend/src/scenes/GameBrowser/index.js b/frontend/src/scenes/GameBrowser/index.js index 20a835d1..7bb8b59d 100644 --- a/frontend/src/scenes/GameBrowser/index.js +++ b/frontend/src/scenes/GameBrowser/index.js @@ -10,7 +10,14 @@ import type { Player } from '../../models/players'; import { actions, getAllGames } from '../../redux/games'; import { getCurrentPlayer } from '../../redux/players'; -class GameBrowserPresenter extends Component { +export type GameBrowserProps = { + currentPlayer: Player, + games: List, + createGame: (gameName: string) => void, + joinGame: (gameId: string) => void +} + +class GameBrowserPresenter extends Component { props: { currentPlayer: Player, games: List, @@ -20,7 +27,7 @@ class GameBrowserPresenter extends Component { _gameName: string | void = undefined; - createGame = (e: SyntheticEvent): void => { + createGame = (e: SyntheticEvent<*>): void => { e.preventDefault(); if (this._gameName !== undefined) { this.props.createGame(this._gameName); @@ -35,7 +42,7 @@ class GameBrowserPresenter extends Component { buttonLabel="Create Game" label="Game name" name="game_name" - onChange={(e: SyntheticInputEvent) => (this._gameName = e.target.value)} + onChange={(e: SyntheticInputEvent<*>) => (this._gameName = e.target.value)} onClick={this.createGame} /> diff --git a/frontend/src/scenes/Lobby/index.js b/frontend/src/scenes/Lobby/index.js index 57ad5c7f..88021fbe 100644 --- a/frontend/src/scenes/Lobby/index.js +++ b/frontend/src/scenes/Lobby/index.js @@ -3,10 +3,17 @@ import React, { Component } from 'react'; import { connect } from 'react-redux'; import { Button } from 'rebass'; import { PlayerList } from '../../components/playerList'; +import type { Game } from '../../models/games'; +import type { Player } from '../../models/players'; import { actions, getCurrentGame } from '../../redux/games'; import { getPlayers } from '../../redux/players'; -class LobbyPresenter extends Component { +export type LobbyProps = { + currentGame: Game, + players: List, +} + +class LobbyPresenter extends Component { getTitle() { if (this.props.currentGame) { return this.props.currentGame.name + ' — Lobby'; diff --git a/frontend/src/scenes/SplashScreen/components/HomeLayout.js b/frontend/src/scenes/SplashScreen/components/HomeLayout.js index 2a3fd856..08029d45 100644 --- a/frontend/src/scenes/SplashScreen/components/HomeLayout.js +++ b/frontend/src/scenes/SplashScreen/components/HomeLayout.js @@ -1,12 +1,16 @@ // @flow -import type { Children } from 'react'; +import type { Node } from 'react'; import React from 'react'; import { Banner } from 'rebass'; import { ErrorToastContainer } from '../../../components/errors/errorToastContainer'; import background from './background-zeus-temple.jpg'; import logo from './logo-7-wonders.png'; -export const HomeLayout = ({ children }: { children: Children }) => ( +export type HomeLayoutProps = { + children?: Node, +} + +export const HomeLayout = ({ children }: HomeLayoutProps) => (
Seven Wonders diff --git a/frontend/src/scenes/SplashScreen/index.js b/frontend/src/scenes/SplashScreen/index.js index 022caf45..745d8ee7 100644 --- a/frontend/src/scenes/SplashScreen/index.js +++ b/frontend/src/scenes/SplashScreen/index.js @@ -6,7 +6,11 @@ import { Container } from 'rebass'; import { actions } from '../../redux/players'; import { HomeLayout } from './components/HomeLayout'; -class SplashScreenPresenter extends Component { +export type SplashScreenProps = { + chooseUsername: (username: string) => void, +} + +class SplashScreenPresenter extends Component { _username = ''; play = e => { -- cgit