-
Notifications
You must be signed in to change notification settings - Fork 143
Expand file tree
/
Copy pathConsoleOutput.jsx
More file actions
57 lines (50 loc) · 1.2 KB
/
ConsoleOutput.jsx
File metadata and controls
57 lines (50 loc) · 1.2 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
import {faChevronLeft} from '@fortawesome/free-solid-svg-icons';
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
import isNil from 'lodash-es/isNil';
import React from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import {ConsoleEntry} from '../records';
import styles from './ConsoleOutput.module.css';
export default function ConsoleOutput({entry, isActive}) {
const {expression, value, error} = entry;
const chevron = expression ?
(<div className={styles.chevron}>
<FontAwesomeIcon icon={faChevronLeft} />
</div>) :
null;
if (!isNil(value)) {
return (
<div
className={
classnames(
styles.value,
{[styles.inactive]: !isActive},
)
}
>
{chevron}
{value}
</div>
);
}
if (!isNil(error)) {
return (
<div
className={
classnames(
styles.error,
{[styles.inactive]: !isActive},
)
}
>
{error.text}
</div>
);
}
return null;
}
ConsoleOutput.propTypes = {
entry: PropTypes.instanceOf(ConsoleEntry).isRequired,
isActive: PropTypes.bool.isRequired,
};