Commit abca36bd authored by nikogu's avatar nikogu

fixed list loading

parent bbb56769
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import { connect } from 'dva'; import { connect } from 'dva';
import { Row, Col, Card, Avatar, Spin, Button, Icon } from 'antd'; import { Card, Avatar, Button, Icon, List } from 'antd';
import PageHeaderLayout from '../../layouts/PageHeaderLayout'; import PageHeaderLayout from '../../layouts/PageHeaderLayout';
...@@ -53,37 +53,35 @@ export default class CardList extends PureComponent { ...@@ -53,37 +53,35 @@ export default class CardList extends PureComponent {
extraContent={extraContent} extraContent={extraContent}
> >
<div className={styles.cardList}> <div className={styles.cardList}>
{ <List
loading ? loading={loading}
<Spin /> grid={{ gutter: 16, lg: 3, md: 2, sm: 1, xs: 1 }}
: >
<Row gutter={16}> <List.Item>
<Col lg={8} md={12} sm={12} xs={24} style={{ marginBottom: 16 }}> <Button type="dashed" className={styles.newButton}>
<Button type="dashed" className={styles.newButton}> <Icon type="plus" /> ζ–°ε’žδΊ§ε“
<Icon type="plus" /> ζ–°ε’žδΊ§ε“ </Button>
</Button> </List.Item>
</Col> {
{ list && list.map(item => (
list && list.map(item => ( <List.Item key={item.id}>
<Col lg={8} md={12} sm={12} xs={24} key={item.id} style={{ marginBottom: 16 }}> <Card
<Card actions={[<a>ζ“δ½œδΈ€</a>, <a>ζ“δ½œδΊŒ</a>]}
actions={[<a>ζ“δ½œδΈ€</a>, <a>ζ“δ½œδΊŒ</a>]} >
> <Card.Meta
<Card.Meta avatar={<Avatar size="large" src={item.avatar} />}
avatar={<Avatar size="large" src={item.avatar} />} title={item.title}
title={item.title} description={(
description={( <p className={styles.cardDescription}>
<p className={styles.cardDescription}> <span>{item.description}</span>
<span>{item.description}</span> </p>
</p> )}
)} />
/> </Card>
</Card> </List.Item>
</Col> ))
)) }
} </List>
</Row>
}
</div> </div>
</PageHeaderLayout> </PageHeaderLayout>
); );
......
...@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; ...@@ -2,7 +2,7 @@ import React, { PureComponent } from 'react';
import moment from 'moment'; import moment from 'moment';
import { connect } from 'dva'; import { connect } from 'dva';
import { routerRedux } from 'dva/router'; import { routerRedux } from 'dva/router';
import { Row, Col, Form, Card, Select, Spin } from 'antd'; import { Row, Col, Form, Card, Select, List } from 'antd';
import PageHeaderLayout from '../../layouts/PageHeaderLayout'; import PageHeaderLayout from '../../layouts/PageHeaderLayout';
import StandardFormRow from '../../components/StandardFormRow'; import StandardFormRow from '../../components/StandardFormRow';
...@@ -72,10 +72,13 @@ export default class CoverCardList extends PureComponent { ...@@ -72,10 +72,13 @@ export default class CoverCardList extends PureComponent {
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const cardList = list ? ( const cardList = list ? (
<Row gutter={16} style={{ marginTop: 16 }}> <List
loading={loading}
grid={{ gutter: 16, lg: 4, md: 3, sm: 2, xs: 1 }}
>
{ {
list.map(item => ( list.map(item => (
<Col lg={6} md={8} sm={12} xs={24} style={{ marginBottom: 16 }} key={item.id}> <List.Item key={item.id}>
<Card <Card
cover={<img alt={item.title} src={item.cover} />} cover={<img alt={item.title} src={item.cover} />}
> >
...@@ -100,10 +103,10 @@ export default class CoverCardList extends PureComponent { ...@@ -100,10 +103,10 @@ export default class CoverCardList extends PureComponent {
</div> </div>
</div> </div>
</Card> </Card>
</Col> </List.Item>
)) ))
} }
</Row> </List>
) : null; ) : null;
const tabList = [ const tabList = [
...@@ -209,17 +212,9 @@ export default class CoverCardList extends PureComponent { ...@@ -209,17 +212,9 @@ export default class CoverCardList extends PureComponent {
</StandardFormRow> </StandardFormRow>
</Form> </Form>
</Card> </Card>
{ <div className={styles.cardList}>
loading && (list.length > 0) && <Spin> { cardList }
{cardList} </div>
</Spin>
}
{
loading && (list.length < 1) && <div style={{ marginTop: 16 }}><Spin /></div>
}
{
!loading && cardList
}
</div> </div>
</PageHeaderLayout> </PageHeaderLayout>
); );
......
...@@ -21,4 +21,7 @@ ...@@ -21,4 +21,7 @@
flex: 0 1 auto; flex: 0 1 auto;
} }
} }
.cardList {
margin-top: 24px;
}
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment