-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathApp.js
More file actions
52 lines (43 loc) · 1.34 KB
/
App.js
File metadata and controls
52 lines (43 loc) · 1.34 KB
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
import React from 'react';
import ReactTV from 'react-tv';
import Sidebar from './Sidebar.js'
import List from './List.js'
import Search from './Search.js'
import Navigation, { VerticalList, HorizontalList } from 'react-key-navigation'
class ReactTVApp extends React.Component {
constructor() {
super();
this.state = {
active: null,
}
this.lists = ["Title 1", "Title 2", "Title 3", "Title 4"]
}
changeFocusTo(index) {
this.setState({active: index});
}
onBlurLists() {
this.setState({active: null});
}
render() {
return (
<Navigation supportedKeys={[{code:32, stringValue:"space"}, {code:27, stringValue:"esc"}]}>
<div id="container">
<HorizontalList>
<Sidebar/>
<div class="mainbox">
<VerticalList navDefault>
<Search/>
<VerticalList id="content" onBlur={() => this.onBlurLists()}>
{this.lists.map((list, i) =>
<List title={list} onFocus={() => this.changeFocusTo(i)} visible={this.state.active !== null ? i >= this.state.active : true}/>
)}
</VerticalList>
</VerticalList>
</div>
</HorizontalList>
</div>
</Navigation>
);
}
}
ReactTV.render(<ReactTVApp />, document.querySelector('#root'));