-
Notifications
You must be signed in to change notification settings - Fork 44
/
home-app.tsx
51 lines (45 loc) · 1.31 KB
/
home-app.tsx
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
import {
Actions,
Button,
Home,
PheliaHomeProps,
Section,
Text,
} from "../../core";
import React from "react";
import { MyModal } from "./modal-example";
export function HomeApp({ useState, useModal, user }: PheliaHomeProps) {
const [counter, setCounter] = useState("counter", 0);
const [loaded, setLoaded] = useState("loaded", 0);
const [form, setForm] = useState("form");
const [updated, setUpdated] = useState("updated", false);
const openModal = useModal("modal", MyModal, (event) =>
setForm(JSON.stringify(event.form, null, 2))
);
return (
<Home
onLoad={() => setLoaded(loaded + 1)}
onUpdate={() => setUpdated(true)}
>
<Section>
<Text emoji>Hey there {user.username} :wave:</Text>
<Text type="mrkdwn">*Updated:* {String(updated)}</Text>
<Text type="mrkdwn">*Counter:* {counter}</Text>
<Text type="mrkdwn">*Loaded:* {loaded}</Text>
</Section>
<Actions>
<Button action="counter" onClick={() => setCounter(counter + 1)}>
Click me
</Button>
<Button action="modal" onClick={() => openModal()}>
Open a Modal
</Button>
</Actions>
{form && (
<Section>
<Text type="mrkdwn">{"```\n" + form + "\n```"}</Text>
</Section>
)}
</Home>
);
}