forked from popcodeorg/popcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPreview.jsx
More file actions
74 lines (67 loc) · 2.02 KB
/
Preview.jsx
File metadata and controls
74 lines (67 loc) · 2.02 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import get from 'lodash-es/get';
import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import React from 'react';
import PreviewFrame from './PreviewFrame';
export default function Preview({
compiledProjects,
consoleEntries,
focusedSelector,
showingErrors,
onConsoleError,
onConsoleLog,
onConsoleValue,
onPopOutProject,
onRefreshClick,
onRuntimeError,
}) {
if (showingErrors) {
return null;
}
const projectFrames = compiledProjects.map((compiledProject, key) => (
<PreviewFrame
compiledProject={compiledProject}
consoleEntries={consoleEntries}
focusedSelector={focusedSelector}
isActive={key === compiledProjects.keySeq().last()}
key={compiledProject.compiledProjectKey}
onConsoleError={onConsoleError}
onConsoleLog={onConsoleLog}
onConsoleValue={onConsoleValue}
onRuntimeError={onRuntimeError}
/>
));
const mostRecentCompiledProject = compiledProjects.last();
const title = get(mostRecentCompiledProject, 'title', '');
return (
<div className="preview output__item">
<div className="preview__title-bar">
<span
className="preview__button preview__button_pop-out u__icon"
onClick={onPopOutProject}
></span>
{title}
<span
className="preview__button preview__button_reset u__icon"
onClick={onRefreshClick}
></span>
</div>
{projectFrames}
</div>
);
}
Preview.propTypes = {
compiledProjects: ImmutablePropTypes.iterable.isRequired,
consoleEntries: ImmutablePropTypes.iterable.isRequired,
focusedSelector: PropTypes.string,
showingErrors: PropTypes.bool.isRequired,
onConsoleError: PropTypes.func.isRequired,
onConsoleLog: PropTypes.func.isRequired,
onConsoleValue: PropTypes.func.isRequired,
onPopOutProject: PropTypes.func.isRequired,
onRefreshClick: PropTypes.func.isRequired,
onRuntimeError: PropTypes.func.isRequired,
};
Preview.defaultProps = {
focusedSelector: null,
};