-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
103 additions
and
57 deletions.
There are no files selected for viewing
This file contains 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,8 +1,8 @@ | ||
{ | ||
"presets": ["react", "es2015"], | ||
"presets": ["react", "es2015", "stage-0"], | ||
"env": { | ||
"development": { | ||
"presets": ["react-hmre"] | ||
} | ||
} | ||
} | ||
} |
This file contains 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,17 @@ | ||
Benchmark React Material design frameworks | ||
=== | ||
|
||
- `material-ui` | ||
- `react-toolbox` | ||
|
||
Installation and how to run | ||
--- | ||
```bash | ||
npm install | ||
npm start | ||
|
||
# or build and then serve the dist/ folder | ||
|
||
npm run build | ||
npm run serve | ||
``` |
This file contains 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 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 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 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,8 @@ | ||
exports.list = Array.apply(null, {length: 1000}).map((item, index) => index.toString(16)); | ||
export const list = Array.apply(null, {length: 1000}).map((item, index) => index.toString(16)); | ||
|
||
exports.onClick = (e, msg = 'Hello world', index = null) => alert(msg + index); | ||
export const onClick = (message, index) => { | ||
if (message === 'Bad') { | ||
return console.log(`Bad ${index}`); | ||
} | ||
console.log('Good'); | ||
}; |
This file contains 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,33 +1,37 @@ | ||
import React, {Component, PropTypes, Children, cloneElement} from 'react'; | ||
import PureRenderMixin from 'react-addons-pure-render-mixin'; | ||
import React, {Component, PropTypes, Children, createElement} from 'react'; | ||
import shallowEqual from 'shallowequal'; | ||
|
||
class Iterate extends Component { | ||
constructor(props) { | ||
super(props); | ||
this.shouldComponentUpdate = PureRenderMixin.shouldComponentUpdate.bind(this); | ||
this.previousItems = []; | ||
this.previousRendered = null; | ||
constructor(...args) { | ||
super(...args); | ||
|
||
this.previousProps = null; | ||
} | ||
renderItems(items) { | ||
if (this.previousItems === items) { | ||
return this.previousRendered; | ||
} | ||
this.previousItems = items; | ||
this.previousRendered = Children.toArray(items).map(this.props.children); | ||
return this.previousRendered; | ||
shouldComponentUpdate(nextProps) { | ||
const {root, rootProps, items, children, ...props} = nextProps; | ||
return children !== this.props.children || | ||
items !== this.props.items || | ||
root !== this.props.root || | ||
!shallowEqual(rootProps, this.props.rootProps) || | ||
!shallowEqual(props, this.previousProps); | ||
} | ||
render() { | ||
const {root, items} = this.props; | ||
|
||
return cloneElement(root, { | ||
children: this.renderItems(items) | ||
const {root, rootProps, items, children, ...props} = this.props; | ||
this.previousProps = props; | ||
return createElement(root, { | ||
...rootProps, | ||
children: Children.toArray(items).map((item, index) => children(item, props, index)) | ||
}); | ||
} | ||
} | ||
Iterate.propTypes = { | ||
children: PropTypes.func, | ||
children: PropTypes.func.isRequired, | ||
items: PropTypes.array, | ||
root: PropTypes.element | ||
root: PropTypes.oneOfType([PropTypes.string, PropTypes.func]), | ||
rootProps: PropTypes.object | ||
}; | ||
Iterate.defaultProps = { | ||
root: 'div' | ||
}; | ||
|
||
export default Iterate; | ||
export default Iterate; |
This file contains 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 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 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 @@ | ||
import 'react-toolbox/lib/commons'; |
This file contains 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,2 +0,0 @@ | ||
$color-primary: $palette-blue-500 !default; | ||
$color-primary-dark: $palette-blue-700 !default; | ||
This file contains 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,13 +1,21 @@ | ||
import React from 'react'; | ||
import benchmark from '../benchmark'; | ||
import {list, onClick} from '../fixtures'; | ||
import './boilerplate'; | ||
|
||
import { List, ListItem } from 'react-toolbox'; | ||
import Iterate from '../iterate'; | ||
|
||
const renderItem = (item, props, index) => ( | ||
<ListItem key={index} onClick={props.badProps ? () => onClick('Bad', index) : onClick} caption={item} /> | ||
); | ||
|
||
benchmark(badProps => ( | ||
<List> | ||
{list.map((item, index) => ( | ||
<ListItem key={index} onClick={badProps ? () => onClick() : onClick} caption={item} legend={item} /> | ||
))} | ||
</List> | ||
)); | ||
<Iterate | ||
root={List} | ||
rootProps={{selectable: true, ripple: true}} | ||
items={list} | ||
children={renderItem} | ||
badProps={badProps} | ||
/> | ||
)); |
This file contains 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,13 +1,14 @@ | ||
import React from 'react'; | ||
import benchmark from '../benchmark'; | ||
import {list, onClick} from '../fixtures'; | ||
import './boilerplate'; | ||
|
||
import { List, ListItem } from 'react-toolbox'; | ||
|
||
benchmark(badProps => ( | ||
<List> | ||
<List selectable ripple> | ||
{list.map((item, index) => ( | ||
<ListItem key={index} onClick={badProps ? () => onClick() : onClick} caption={item} legend={item} /> | ||
<ListItem key={index} onClick={badProps ? () => onClick('Bad', index) : onClick} caption={item} /> | ||
))} | ||
</List> | ||
)); | ||
)); |
This file contains 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