import * as React from 'react';
import * as blessed from 'blessed';
import { render } from 'react-blessed';
// Testing example from demos page
// https://github.com/Yomguithereal/react-blessed/blob/master/examples/dashboard.jsx
const { Component } = React;
/**
* Stylesheet
*/
const stylesheet = {
bordered: {
border: {
type: 'line'
},
style: {
border: {
fg: 'blue'
}
}
}
};
/**
* Top level component.
*/
class Dashboard extends Component {
render() {
return (
<>
>
);
}
}
/**
* Log component.
*/
class Log extends Component {
render() {
return (
{'Hello'}, {0}, {'World'}
);
}
}
/**
* Request component.
*/
class Request extends Component {
render() {
return (
{0}
);
}
}
/**
* Response component.
*/
class Response extends Component {
render() {
return (
);
}
}
/**
* Jobs component.
*/
class Jobs extends Component {
render() {
return (
);
}
}
/**
* Progress component.
*/
class Progress extends Component {
state: {
progress: number,
color: string,
} = {
progress: 0,
color: 'blue'
};
constructor(props: any) {
super(props);
const interval: NodeJS.Timer = setInterval(() => {
const { progress } = this.state;
if (this.state.progress >= 100) {
clearInterval(interval);
return;
}
this.setState({
progress: progress + 1,
});
}, 50);
}
render() {
const { progress, color } = this.state;
const label = `Progress - ${progress}%`;
return (
this.setState({
color: 'green'
})}
class={stylesheet.bordered}
filled={progress}
top='60%'
left='60%'
width='40%'
height='10%'
style={{
bar: {
bg: color
}
}}
/>
);
}
}
/**
* Stats component.
*/
class Stats extends Component {
render() {
return (
Some stats
);
}
}
/**
* Rendering the screen.
*/
const screen = blessed.screen({
autoPadding: true,
smartCSR: true,
title: 'react-blessed dashboard'
});
screen.key(['escape', 'q', 'C-c'], () => {
return process.exit(0);
});
render(, screen);