Ivan - Add Loading to table [skip ci]

This commit is contained in:
ivan 2016-10-13 21:42:37 -03:00
parent a51bc5c3ad
commit 1337564d87
3 changed files with 38 additions and 1 deletions

View File

@ -1,6 +1,7 @@
'use strict'; 'use strict';
const React = require('react'); const React = require('react');
const _ = require('lodash');
const DocumentTitle = require('react-document-title'); const DocumentTitle = require('react-document-title');
const ModalContainer = require('app-components/modal-container'); const ModalContainer = require('app-components/modal-container');
@ -123,6 +124,20 @@ let DemoPage = React.createClass({
</Button> </Button>
) )
}, },
{
title: 'ModalTrigger Large',
render: (
<Button onClick={function () {
ModalContainer.openModal(
<div>
{_.range(1, 60).map(() => <div>Some modal content</div>)}
</div>
);
}}>
Open Large Modal
</Button>
)
},
{ {
title: 'Table', title: 'Table',
render: ( render: (

View File

@ -3,6 +3,7 @@ import _ from 'lodash';
import classNames from 'classnames'; import classNames from 'classnames';
import Menu from 'core-components/menu'; import Menu from 'core-components/menu';
import Loading from 'core-components/loading';
class Table extends React.Component { class Table extends React.Component {
static propTypes = { static propTypes = {
@ -13,6 +14,7 @@ class Table extends React.Component {
})), })),
rows: React.PropTypes.arrayOf(React.PropTypes.object), rows: React.PropTypes.arrayOf(React.PropTypes.object),
pageSize: React.PropTypes.number, pageSize: React.PropTypes.number,
loading: React.PropTypes.bool,
type: React.PropTypes.oneOf(['default']) type: React.PropTypes.oneOf(['default'])
}; };
@ -34,9 +36,10 @@ class Table extends React.Component {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{this.props.rows.map(this.renderRow.bind(this))} {(!this.props.loading) ? this.props.rows.map(this.renderRow.bind(this)) : null}
</tbody> </tbody>
</table> </table>
{(this.props.loading) ? this.renderLoading() : null}
{(this.props.pageSize && this.props.rows.length > this.props.pageSize) ? this.renderNavigation() : null} {(this.props.pageSize && this.props.rows.length > this.props.pageSize) ? this.renderNavigation() : null}
</div> </div>
); );
@ -86,6 +89,14 @@ class Table extends React.Component {
); );
} }
renderLoading() {
return (
<div className="table__loading-wrapper">
<Loading className="table__loading" backgrounded size="large"/>
</div>
)
}
onNavigationItemClick(index) { onNavigationItemClick(index) {
this.setState({ this.setState({
page: index + 1 page: index + 1

View File

@ -48,4 +48,15 @@
&__navigation { &__navigation {
margin-top: 10px; margin-top: 10px;
} }
&__loading-wrapper {
min-height: 200px;
}
&__loading {
position: initial;
width: initial;
height: initial;
margin: auto;
}
} }