/
wrapper.tsx
95 lines (90 loc) · 2.61 KB
/
wrapper.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
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
91
92
93
94
95
import * as React from "react";
import * as style from "@styles/index/wrapper.module.css";
import { AppState } from "@stores/index";
import { AppActions } from "@containers/index";
import { Facebook } from "@components/common/buttons/facebook";
import { Twitter } from "@components/common/buttons/twitter";
import { Blogs } from "@components/index/blogs";
import { Events } from "@components/index/events";
import headerSvg from "@images/header.svg";
import footerImg from "@images/index/background.png";
type Props = AppActions & AppState;
type State = {
tabs: "blogs" | "events";
footer: {
imageLoading: boolean;
};
};
export class Wrapper extends React.Component<Props, State> {
footerImage: HTMLImageElement;
constructor(props: Props) {
super(props);
this.state = {
tabs: "blogs",
footer: {
imageLoading: true
}
};
}
componentDidMount() {
if (this.state.footer.imageLoading) {
this.footerImage = new Image();
this.footerImage.onload = () => {
this.setState({
footer: {
imageLoading: false
}
});
};
this.footerImage.src = footerImg;
}
}
render() {
return (
<div className={style.wrapper}>
<div className={style.siteContent}>
<header className={style.header}>
<object
className={style.headerSvg}
type="image/svg+xml"
data={headerSvg}
/>
</header>
<main className={style.main}>
<nav className={style.tabs}>
<div
className={
this.state.tabs === "blogs" ? style.tappedTab : style.tab
}
onClick={() => this.setState({ tabs: "blogs" })}
>
Blogs
</div>
<div
className={
this.state.tabs === "events" ? style.tappedTab : style.tab
}
onClick={() => this.setState({ tabs: "events" })}
>
Events
</div>
</nav>
<Blogs {...this.props} display={this.state.tabs === "blogs"} />
<Events {...this.props} display={this.state.tabs === "events"} />
</main>
<footer
className={
this.state.footer.imageLoading ? style.disable : style.footer
}
>
<nav className={style.nav}>
<Facebook />
<span className={style.margin} />
<Twitter />
</nav>
</footer>
</div>
</div>
);
}
}