-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.py
More file actions
73 lines (64 loc) · 2.42 KB
/
Copy pathApp.py
File metadata and controls
73 lines (64 loc) · 2.42 KB
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
from Component_py.stubs import require, __pragma__ # __:skip
from Component_py.component import Component, destruct
from containers.LoginFormContainer import LoginFormContainer
from containers.FormPanelContainer import FormPanelContainer
from containers.ButtonPanelContainer import ButtonPanelContainer
from containers.TodoListContainer import TodoListContainer
from components.Spinner import Spinner
React = require("react")
PropTypes = require("prop-types")
Form, Row, Col, Jumbotron = destruct(
require("reactstrap"), "Form", "Row", "Col", "Jumbotron")
class App(Component):
propTypes = {
"logged_in": PropTypes.bool.isRequired,
"error": PropTypes.string
}
def render_login_panel(self):
return __pragma__("xtrans", None, "{}", """ (
<div>
<h5>Please Login:</h5>
<LoginFormContainer />
</div>
); """)
def on_submit(self, e):
e.preventDefault()
def render_todo_panel(self):
return __pragma__("xtrans", None, "{}", """ (
<div>
<TodoListContainer />
<Form
className="p-4"
onSubmit={self.on_submit}
>
<FormPanelContainer />
<ButtonPanelContainer />
</Form>
</div>
); """)
def render(self):
logged_in, loading, error = destruct(
self.props, "logged_in", "loading", "error")
visible_component = \
self.render_todo_panel() if logged_in else self.render_login_panel()
return __pragma__("xtrans", None, "{}", """ (
<Row>
<Col
lg={{size: 6, offset: 3}}
md={{size: 8, offset: 2}}
sm={{size: 10, offset: 1}}
xs="12"
>
<Jumbotron>
<div className="d-flex flex-column">
<div className="d-flex justify-content-center align-items-center p-4">
<h2>My Todos</h2>
</div>
{visible_component}
<Spinner loading={loading} />
<span className="text-danger">{error}</span>
</div>
</Jumbotron>
</Col>
</Row>
); """)