-
-
Notifications
You must be signed in to change notification settings - Fork 182
Fiber #60
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
Fiber #60
Changes from 9 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1ba849e
first fiber commit
iamdustan b184e75
with devtools!
iamdustan e981755
fix rendering simple components with children
iamdustan fdd91e5
Support text updates
iamdustan c32f97f
removeChild
iamdustan a8699ee
optimize solveClass for less array allocation
iamdustan 418c4cf
insertBefore
iamdustan d25188b
Trigger renders at commit phases
iamdustan 141db54
event handlers
iamdustan fafbcf9
wip examples
iamdustan b1cb793
bleh
iamdustan 01b7a23
Official react-reconciler package
iamdustan 4ac4082
Start updating to _next_ release of react-reconciler for devtools hook
iamdustan 660e186
react package bumps
iamdustan 966b825
remove logs
iamdustan 312bb6c
remove yoga-layout from package.json for a future test
iamdustan e7d2146
remove ws from deps, bump other deps
iamdustan b43aaca
Move devtools setup to try/catch with a warning
iamdustan 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
{ | ||
"presets": ["es2015", "stage-0", "react"] | ||
"presets": ["es2015", "react"], | ||
"plugins": [ | ||
"transform-flow-strip-types", | ||
"transform-object-rest-spread" | ||
] | ||
} |
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,41 @@ | ||
import React, {Component} from 'react'; | ||
|
||
class AnimatedBox extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
position: props.initialPosition || 0, | ||
toRight: true | ||
}; | ||
|
||
setInterval(() => { | ||
const {position, toRight} = this.state, | ||
newDirection = (position === (toRight ? 90 : 0)) ? | ||
!toRight : | ||
toRight, | ||
newPosition = newDirection ? position + 1 : position - 1; | ||
|
||
|
||
this.setState({ | ||
position: newPosition, | ||
toRight: newDirection | ||
}); | ||
}, props.time || 33.333333); | ||
} | ||
render() { | ||
const position = `${this.state.position}%`; | ||
|
||
return ( | ||
<box top="center" | ||
left={position} | ||
width={this.props.width || "10%"} | ||
height={this.props.height || "20%"} | ||
border={{type: 'line'}} | ||
style={{bg: 'cyan', border: {fg: 'blue'}}} /> | ||
); | ||
} | ||
} | ||
|
||
module.exports = AnimatedBox; | ||
|
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,61 @@ | ||
import React, {Component} from 'react'; | ||
import blessed from 'blessed'; | ||
import {render} from '../src'; | ||
import AnimatedBox from './components/AnimatedBox'; | ||
|
||
class Form extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
name: '', | ||
}; | ||
|
||
this.submit = data => this.setState(state => ({name: data})); | ||
this.cancel = _ => console.log('Form canceled'); | ||
} | ||
render() { | ||
return ( | ||
<form | ||
keys | ||
vi | ||
onSubmit={this.submit} | ||
onReset={this.cancel} | ||
left="5%" | ||
top="5%" | ||
width="90%" | ||
height="90%" | ||
border={{type: 'line'}} | ||
style={{bg: 'cyan', border: {fg: 'blue'}}} | ||
> | ||
<box width={6} height={3}>Name: </box> | ||
<textbox | ||
onSubmit={this.submit} | ||
left={6} | ||
height={3} | ||
keys | ||
mouse | ||
inputOnFocus | ||
/> | ||
<box top={3} height={3}> | ||
{`Result: ${this.state.name}`} | ||
</box> | ||
<AnimatedBox /> | ||
</form> | ||
); | ||
} | ||
} | ||
|
||
const screen = blessed.screen({ | ||
autoPadding: true, | ||
// smartCSR: true, | ||
title: 'react-blessed form example' | ||
}); | ||
|
||
screen.key(['escape', 'q', 'C-c'], function(ch, key) { | ||
return process.exit(0); | ||
}); | ||
|
||
render(<Form />, screen, (inst) => console.log('Rendered Form!')); | ||
|
||
|
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,67 @@ | ||
import React, {Component} from 'react'; | ||
import blessed from 'blessed'; | ||
import {render} from '../src'; | ||
|
||
class ProgressBox extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
position: 0, | ||
toRight: true | ||
}; | ||
|
||
setInterval(() => { | ||
const {position, toRight} = this.state, | ||
newDirection = (position === (toRight ? 90 : 0)) ? | ||
!toRight : | ||
toRight, | ||
newPosition = newDirection ? position + 1 : position - 1; | ||
|
||
|
||
this.setState({ | ||
position: newPosition, | ||
toRight: newDirection | ||
}); | ||
}, 30); | ||
} | ||
render() { | ||
const position = `${this.state.position}%`; | ||
|
||
return ( | ||
<box | ||
top="center" | ||
left="0" | ||
width="10%" | ||
height="20%" | ||
border={{type: 'line'}} | ||
style={{bg: 'cyan', border: {fg: 'blue'}}} | ||
> | ||
<progressbar | ||
orientation="horizontal" | ||
filled={this.state.position} | ||
top="80%" | ||
left="center" | ||
height="15%" | ||
width="100%" | ||
label="progress" | ||
border={{type: 'line'}} | ||
style={{border: {fg: 'red'}, bar: {bg: 'red'}}} | ||
/> | ||
</box> | ||
); | ||
} | ||
} | ||
|
||
const screen = blessed.screen({ | ||
autoPadding: true, | ||
smartCSR: true, | ||
title: 'react-blessed box animation' | ||
}); | ||
|
||
screen.key(['escape', 'q', 'C-c'], function(ch, key) { | ||
return process.exit(0); | ||
}); | ||
|
||
render(<ProgressBox />, screen, (inst) => console.log('Rendered ProgressBox!')); | ||
|
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,55 @@ | ||
import React, {Component} from 'react'; | ||
import blessed from 'blessed'; | ||
import {render} from '../src'; | ||
|
||
class RemovesChild extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = {renderChild: true}; | ||
|
||
setInterval(() => { | ||
this.setState(state => ({renderChild: !state.renderChild})); | ||
}, props.freq || 500); | ||
} | ||
render() { | ||
const {renderChild} = this.state; | ||
|
||
return ( | ||
<box | ||
top="center" | ||
left="10%" | ||
top="10%" | ||
width="80%" | ||
height="80%" | ||
border={{type: 'line'}} | ||
style={{bg: 'cyan', border: {fg: 'blue'}}} | ||
> | ||
{renderChild && ( | ||
<box | ||
top="center" | ||
left="0" | ||
width="10%" | ||
height="20%" | ||
border={{type: 'line'}} | ||
style={{bg: 'cyan', border: {fg: 'blue'}}}> | ||
I will be removed | ||
</box> | ||
)} | ||
</box> | ||
); | ||
} | ||
} | ||
|
||
const screen = blessed.screen({ | ||
autoPadding: true, | ||
smartCSR: true, | ||
title: 'react-blessed box animation' | ||
}); | ||
|
||
screen.key(['escape', 'q', 'C-c'], function(ch, key) { | ||
return process.exit(0); | ||
}); | ||
|
||
render(<RemovesChild />, screen, (inst) => console.log('Rendered RemovesChild!')); | ||
|
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 |
---|---|---|
|
@@ -29,17 +29,22 @@ | |
}, | ||
"homepage": "https://github.com/yomguithereal/react-blessed#readme", | ||
"devDependencies": { | ||
"babel-cli": "^6.6.4", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-react": "^6.5.0", | ||
"babel-preset-stage-0": "^6.5.0", | ||
"babel-register": "^6.6.0", | ||
"babel-cli": "^6.20.0", | ||
"babel-plugin-transform-flow-strip-types": "^6.22.0", | ||
"babel-plugin-transform-object-rest-spread": "^6.23.0", | ||
"babel-preset-es2015": "^6.22.0", | ||
"babel-preset-react": "^6.22.0", | ||
"babel-preset-stage-0": "^6.22.0", | ||
"babel-register": "^6.22.0", | ||
"blessed": "^0.1.81", | ||
"mocha": "^2.4.5", | ||
"react": "^0.14.7" | ||
"react": "16.0.0-alpha.3", | ||
"react-dom": "^16.0.0-alpha.3" | ||
}, | ||
"dependencies": { | ||
"invariant": "^2.2.0", | ||
"lodash": "^3.x.x" | ||
"lodash": "^3.x.x", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess we can upgrade |
||
"react-devtools": "^2.0.12", | ||
"ws": "^1.1.0" | ||
} | ||
} |
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,24 @@ | ||
|
||
require('babel-register')({}); | ||
const argv = process.argv.slice(2); | ||
const example = argv[0]; | ||
const examples = [ | ||
'animation', | ||
'dashboard', | ||
'demo', | ||
'form', | ||
'progressbar', | ||
'remove', | ||
]; | ||
|
||
if (examples.indexOf(example) === -1) { | ||
console.warn( | ||
'Invalid example "%s" provided. Must be one of:\n * ', | ||
example, | ||
examples.join(' * ') | ||
); | ||
process.exit(1); | ||
} | ||
|
||
require('./examples/' + example); | ||
|
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,22 @@ | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
|
||
const defineProperty = Object.defineProperty; | ||
defineProperty(global, 'WebSocket', { | ||
value: require('ws') | ||
}); | ||
defineProperty(global, 'window', { | ||
value: global | ||
}); | ||
|
||
const {connectToDevTools} = require('react-devtools-core'); | ||
|
||
connectToDevTools({ | ||
isAppActive() { | ||
// Don't steal the DevTools from currently active app. | ||
return true; | ||
}, | ||
host: 'localhost', | ||
// default port? port: , | ||
resolveRNStyle: null, // TODO maybe: require('flattenStyle') | ||
}); | ||
|
Oops, something went wrong.
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.
uhhhh?