-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Console #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Console #13
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
14ede13
console: hijack iframe console messages
therewasaguy fae5ea0
Merge branch 'development' of https://github.com/catarak/p5.js-web-ed…
therewasaguy 7f0b7af
add Console component, gets postMessage from previewFrame
therewasaguy 5561d49
merge upstream changes
therewasaguy e7ea35f
add comments
therewasaguy 8b69ab7
really clear sketch when sketch is stopped
therewasaguy 227b562
console: color-coded error messages
therewasaguy 40704b4
console: shouldComponentUpdate and componentWilLReceiveProps tweaks
therewasaguy 6b672d2
Merge branch 'master' of https://github.com/catarak/p5.js-web-editor …
therewasaguy 0c7f713
console BEM style
therewasaguy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| import React, { PropTypes } from 'react'; | ||
|
|
||
| /** | ||
| * How many console messages to store | ||
| * @type {Number} | ||
| */ | ||
| const consoleMax = 5; | ||
|
|
||
| class Console extends React.Component { | ||
|
|
||
| constructor(props) { | ||
| super(props); | ||
|
|
||
| /** | ||
| * An array of React Elements that include previous console messages | ||
| * @type {Array} | ||
| */ | ||
| this.children = []; | ||
| } | ||
|
|
||
| componentWillReceiveProps(nextProps) { | ||
| if (nextProps.isPlaying && !this.props.isPlaying) { | ||
| this.children = []; | ||
| } else if (nextProps.consoleEvent !== this.props.consoleEvent) { | ||
| const args = nextProps.consoleEvent.arguments; | ||
| const method = nextProps.consoleEvent.method; | ||
| const nextChild = ( | ||
| <div key={this.children.length} className={method}> | ||
| {Object.keys(args).map((key) => <span key={`${this.children.length}-${key}`}>{args[key]}</span>)} | ||
| </div> | ||
| ); | ||
| this.children.push(nextChild); | ||
| } | ||
| } | ||
|
|
||
| shouldComponentUpdate(nextProps) { | ||
| return (nextProps.consoleEvent !== this.props.consoleEvent) || (nextProps.isPlaying && !this.props.isPlaying); | ||
| } | ||
|
|
||
| render() { | ||
| const childrenToDisplay = this.children.slice(-consoleMax); | ||
|
|
||
| return ( | ||
| <div ref="console" className="preview-console"> | ||
| {childrenToDisplay} | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| Console.propTypes = { | ||
| consoleEvent: PropTypes.object, | ||
| isPlaying: PropTypes.bool.isRequired | ||
| }; | ||
|
|
||
| export default Console; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| .preview-console { | ||
| position: fixed; | ||
| width:100%; | ||
| height:60px; | ||
| right:0px; | ||
| bottom: 0px; | ||
| background:grey; | ||
| z-index:1000; | ||
|
|
||
| & > { | ||
| position:relative; | ||
| text-align:left; | ||
| } | ||
|
|
||
| // assign styles to different types of console messages | ||
| .log { | ||
| color: black; | ||
| } | ||
|
|
||
| .error { | ||
| color: red; | ||
| } | ||
|
|
||
| .warn { | ||
| color: yellow; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this project I'm using BEM naming convention, so these class names should be .preview-console__log, .preview-console__warn, and .preview-console__error. Let's also make these colors the same as the linting error colors, #ffbe05 and #ff5f52. all of the other styling is fine for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good! I'll fix that