-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.tsx
75 lines (69 loc) · 1.83 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* _____ __
* / ___// /_ _____
* \__ \/ / / / / _ \
* ___/ / / /_/ / __/
* /____/_/\__, /\___/
* /____/
* Copyright 2018 Parsa Ghadimi. All Rights Reserved.
* Licence: MIT License
*/
import React, { Component } from "react";
import { Img } from "./async";
import { db } from "./fs";
import * as types from "./types";
interface IndexState {
loading: boolean;
presentations: types.PresentationInfo[];
}
// tslint:disable-next-line:variable-name
const Preview = ({ info }: { info: types.PresentationInfo }) => (
<div className="preview">
<a href={`#/view/${info.id}`} >
<Img src={ db.getThumbnailLink(info) } />
</a>
<div className="owner-box">
<img src={ info.data.owner.photoURL } />
<p>
<span className="by">By </span>
<a href={ "#/profile/" + info.data.owner.uid }>
{ info.data.owner.displayName }
</a>
</p>
</div>
</div>
);
export class Index extends Component<{}, IndexState> {
state = {
loading: true,
presentations: null
};
async componentWillMount() {
const presentations = await db.queryLatest();
this.setState({ loading: false, presentations });
}
render() {
if (this.state.loading) {
return <div className="loader" />;
}
const { presentations } = this.state;
return (
<div id="index">
<div className="description">
<p>
Slye is an early stage
<a
href="https://github.com/slye3d/slye"
target="_blank"> open-source </a>
web application to create 3D presentations powered by WebGL.<br />
</p>
<hr />
</div>
<h2>Recent presentations</h2>
<div className="list">
{ presentations.map(x => <Preview info={ x } key={ x.id } />) }
</div>
</div>
);
}
}