/
index.tsx
61 lines (53 loc) Β· 1.29 KB
/
index.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
52
53
54
55
56
57
58
59
60
61
import type { FC } from "react";
import { useState } from "react";
import GitHubCorner from "../GitHubCorner";
import Slider from "../Slider";
import Card from "../Card";
import styles from "./styles.module.scss";
interface State {
str: string;
dir: string;
}
const emojis = [
"π",
"π",
"βοΈ",
"π",
"π",
"πΊ",
"πͺ",
"π",
"π₯",
"π§",
"π",
"π΅",
];
const App: FC = () => {
const [state, setState] = useState<State>({ str: emojis[0], dir: "" });
const renderCards = (): JSX.Element[] =>
emojis.map((emoji) => (
<Card
key={emoji}
string={emoji}
onEnter={(str: string, dir: string) => {
setState({ str, dir });
}}
/>
));
const { str, dir } = state;
return (
<div className={styles.container}>
<GitHubCorner url="https://github.com/wellyshen/react-cool-inview" />
<h1 className={styles.title}>REACT COOL INVIEW</h1>
<p className={styles.subtitle}>
React hook to monitor an element enters or leaves the viewport (or
another element).
</p>
<div className={styles.log}>
Hello! <Slider string={str} direction={dir} /> comes in.
</div>
<div className={styles.frame}>{renderCards()}</div>
</div>
);
};
export default App;