-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
57 lines (57 loc) · 2.08 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Prototype</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.3.1/css/foundation-flex.css">
<script src="https://unpkg.com/react@15.5.0/dist/react.js"></script>
<script src="https://unpkg.com/react-dom@15.5.0/dist/react-dom.js"></script>
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
<script src="https://cdn.rawgit.com/chriszarate/sheetrock/master/dist/sheetrock.min.js"></script>
</head>
<body>
<script type="text/babel">
let HelloTable = (props) => {
let mappable = (component) => {
return (x, i) => {
return component({key: i}, x);
}
};
let td = mappable(React.DOM.td);
let tr = mappable(React.DOM.tr);
let th = mappable(React.DOM.th);
let renderTableBody = (tableData) => {
return tableData.map((row, i, arr) => {
if(i > 0) return tr(row.cellsArray.map(td), i, arr);
});
};
return (
<div>
<table className="stack hover">
<thead>
<tr>{props.sheetsData.rows[0].cellsArray.map(th)}</tr>
</thead>
<tbody>{renderTableBody(props.sheetsData.rows)}</tbody>
</table>
</div>
);
};
function handleSpreadsheetData(error, options, response) {
console.log('Sheetrock', 'error', error, 'options', options, 'response', response);
ReactDOM.render(
<HelloTable sheetsData={response} />,
document.getElementById('proto')
);
}
window.loadSpreadsheetData = () => {
sheetrock({
url: 'https://docs.google.com/spreadsheets/d/1Gn50ovdLMMv_uoMevojl46BZbliaLolgZDtHD1FIpOs/edit#gid=0',
callback: handleSpreadsheetData
});
}
</script>
<h1>Prototyping awesomeness</h1>
<button class="button" type="button" onclick="loadSpreadsheetData();">Load spreadsheet data</button>
<div id="proto"></div>
</body>
</html>