-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.jsx
90 lines (82 loc) · 2.37 KB
/
App.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* Copyright (C) 2022, BBC R&D
* This source code is licensed under the GPL license found in the LICENSE file in this repository.
*/
import React from 'react';
import PropTypes from 'prop-types';
// Import names used for identifying the current page
import {
PAGE_START,
PAGE_LOADING,
PAGE_ERROR,
PAGE_PLAYING,
PAGE_CONNECT_FORM,
PAGE_CONNECT_DIRECT,
PAGE_INSTRUCTIONS,
PAGE_CALIBRATION,
} from 'sagas';
// Import the page components: only one of these is used at a time.
import StartPage from 'pages/start-page/StartPage';
import LoadingPage from 'pages/loading-page/LoadingPage';
import InstructionsPage from 'pages/instructions-page/InstructionsPage';
import ErrorPage from 'pages/error-page/ErrorPage';
import PlayingPage from 'pages/playing-page/PlayingPage';
import ConnectFormPage from 'pages/connect-form-page/ConnectFormPage';
import ConnectDirectPage from 'pages/connect-direct-page/ConnectDirectPage';
import CalibrationPage from 'pages/calibration-page/CalibrationPage';
/**
* The App is the top level presentational component.
*
* It selects the currently active page to render, and forwards all its props to the page. Each
* page may contain further logic to show different screens depending on its props.
*
* The loading, error, and help (and any other screens you may want to add) are boolean properties
* in the state. They change as these pages should become visible, or hidden.
*
* Finally, there is a footer that is common to all pages. This is included directly here.
*/
const App = ({
page,
}) => {
let CurrentPage;
switch (page) {
case PAGE_START:
CurrentPage = StartPage;
break;
case PAGE_LOADING:
CurrentPage = LoadingPage;
break;
case PAGE_INSTRUCTIONS:
CurrentPage = InstructionsPage;
break;
case PAGE_ERROR:
CurrentPage = ErrorPage;
break;
case PAGE_PLAYING:
CurrentPage = PlayingPage;
break;
case PAGE_CONNECT_FORM:
CurrentPage = ConnectFormPage;
break;
case PAGE_CONNECT_DIRECT:
CurrentPage = ConnectDirectPage;
break;
case PAGE_CALIBRATION:
CurrentPage = CalibrationPage;
break;
default:
CurrentPage = ErrorPage;
}
return (
<div className="app">
<CurrentPage />
</div>
);
};
App.defaultProps = {
page: PAGE_LOADING,
};
App.propTypes = {
page: PropTypes.string,
};
export default App;