-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.jsx
More file actions
60 lines (50 loc) · 1.21 KB
/
Copy pathcli.jsx
File metadata and controls
60 lines (50 loc) · 1.21 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
53
54
55
56
57
58
59
60
import React, {Component} from 'react';
import blessed from 'blessed';
import {render} from 'react-blessed';
class App extends Component {
render() {
return (
<box label="react-blessed demo"
border={{type: 'line'}}
style={{border: {fg: 'cyan'}}}>
Random text here...
</box>
);
}
}
class InnerBox extends Component {
constructor(props) {
super(props);
this.state = {
hey: true
};
setInterval(() => {
this.setState({hey: !this.state.hey});
}, 1000);
}
render() {
const position = this.props.position;
const left = position === 'left' ? '2%' : '53%';
return (
<box label={this.state.hey ? 'First step' : 'Second step'}
ref="box"
left={left}
width='45%'
height="70%"
top="10%"
border={{type: 'line'}}
style={{border: {fg: 'green'}}}>
{this.state.hey ? 'Hey...' : 'Ho...'}
</box>
);
}
}
const screen = blessed.screen({
autoPadding: true,
smartCSR: true,
title: 'react-blessed demo app'
});
screen.key(['escape', 'q', 'C-c'], function(ch, key) {
return process.exit(0);
});
const component = render(<App />, screen);