forked from alibaba-fusion/next
-
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.
feat(List): add loading/emptyContent/dataSource/renderItem, close ali…
…baba-fusion#2050 (alibaba-fusion#2105) * feat(List): add loading/emptyContent/dataSource/renderItem, close alibaba-fusion#2050
- Loading branch information
Showing
21 changed files
with
473 additions
and
61 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
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,79 @@ | ||
# 自定义 loading 样式 | ||
|
||
- order: 3 | ||
|
||
自定义 `loading` 样式。 | ||
|
||
:::lang=en-us | ||
# Basic Usage | ||
|
||
- order: 3 | ||
|
||
Custom Loading component. | ||
|
||
::: | ||
--- | ||
|
||
````jsx | ||
import { List, Avatar, Button, Loading, Icon } from '@alifd/next'; | ||
import { useState } from 'react'; | ||
|
||
const data = [ | ||
{ | ||
title: 'A Title', | ||
img: 'https://img.alicdn.com/tfs/TB1QS.4l4z1gK0jSZSgXXavwpXa-1024-1024.png', | ||
money: '$20', | ||
}, | ||
{ | ||
title: 'B Title', | ||
img: 'https://img.alicdn.com/tfs/TB1QS.4l4z1gK0jSZSgXXavwpXa-1024-1024.png', | ||
money: '$10', | ||
}, | ||
{ | ||
title: 'Title', | ||
img: 'https://img.alicdn.com/tfs/TB1QS.4l4z1gK0jSZSgXXavwpXa-1024-1024.png', | ||
money: '$20', | ||
}, | ||
{ | ||
title: 'Title', | ||
img: 'https://img.alicdn.com/tfs/TB1QS.4l4z1gK0jSZSgXXavwpXa-1024-1024.png', | ||
money: '$20', | ||
}, | ||
]; | ||
|
||
const indicator = ( | ||
<div> | ||
<Icon type="loading" /> | ||
</div> | ||
); | ||
|
||
const CustomLoading = (props) => ( | ||
<Loading | ||
indicator={indicator} | ||
{...props} | ||
/> | ||
); | ||
|
||
const App = () => { | ||
const [loading, setLoading] = useState(false); | ||
|
||
return <div style={{width: 288}}> | ||
<Button onClick={() => setLoading(!loading)}>Toggle loading</Button> | ||
<List | ||
size="small" | ||
loading={loading} | ||
loadingComponent={CustomLoading} | ||
header={<div>Notifications</div>} | ||
dataSource={data} | ||
renderItem={(item, i) => <List.Item key={i} extra={item.money} title={item.title} media={<Avatar src={item.img}/>}>List Item {i}</List.Item>} | ||
/> | ||
</div> | ||
} | ||
ReactDOM.render( | ||
<App /> | ||
, mountNode); | ||
```` | ||
|
||
````css | ||
|
||
```` |
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,33 @@ | ||
# 空状态 | ||
|
||
- order: 4 | ||
|
||
无数据时候的列表展示。 | ||
|
||
:::lang=en-us | ||
# Basic Usage | ||
|
||
- order: 4 | ||
|
||
List widthout data. | ||
|
||
::: | ||
--- | ||
|
||
````jsx | ||
import { List, Avatar, Button } from '@alifd/next'; | ||
|
||
ReactDOM.render( | ||
<div style={{width: 288}}> | ||
<List | ||
size="small" | ||
header={<div>Notifications</div>} | ||
dataSource={[]} | ||
renderItem={(item, i) => <List.Item key={i} extra={item.money} title={item.title} media={<Avatar src={item.img}/>}>List Item {i}</List.Item>} | ||
/> | ||
</div> | ||
, mountNode); | ||
```` | ||
````css | ||
|
||
```` |
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,65 @@ | ||
# 带 loading 列表 | ||
|
||
- order: 2 | ||
|
||
带 `loading` 的列表展示。 | ||
|
||
:::lang=en-us | ||
# Basic Usage | ||
|
||
- order: 2 | ||
|
||
List width loading. | ||
|
||
::: | ||
--- | ||
|
||
````jsx | ||
import { List, Avatar, Button } from '@alifd/next'; | ||
import { useState } from 'react'; | ||
|
||
const data = [ | ||
{ | ||
title: 'A Title', | ||
img: 'https://img.alicdn.com/tfs/TB1QS.4l4z1gK0jSZSgXXavwpXa-1024-1024.png', | ||
money: '$20', | ||
}, | ||
{ | ||
title: 'B Title', | ||
img: 'https://img.alicdn.com/tfs/TB1QS.4l4z1gK0jSZSgXXavwpXa-1024-1024.png', | ||
money: '$10', | ||
}, | ||
{ | ||
title: 'Title', | ||
img: 'https://img.alicdn.com/tfs/TB1QS.4l4z1gK0jSZSgXXavwpXa-1024-1024.png', | ||
money: '$20', | ||
}, | ||
{ | ||
title: 'Title', | ||
img: 'https://img.alicdn.com/tfs/TB1QS.4l4z1gK0jSZSgXXavwpXa-1024-1024.png', | ||
money: '$20', | ||
}, | ||
]; | ||
|
||
const App = () => { | ||
const [loading, setLoading] = useState(false); | ||
|
||
return <div style={{width: 288}}> | ||
<Button onClick={() => setLoading(!loading)}>Toggle loading</Button> | ||
<List | ||
size="small" | ||
loading={loading} | ||
header={<div>Notifications</div>} | ||
dataSource={data} | ||
renderItem={(item, i) => <List.Item key={i} extra={item.money} title={item.title} media={<Avatar src={item.img}/>}>List Item {i}</List.Item>} | ||
/> | ||
</div> | ||
} | ||
ReactDOM.render( | ||
<App /> | ||
, mountNode); | ||
```` | ||
|
||
````css | ||
|
||
```` |
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 |
---|---|---|
|
@@ -40,8 +40,8 @@ | |
} | ||
</script> | ||
<script src="//shadow.elemecdn.com/npm/[email protected]/dist/polyfill.min.js"></script> | ||
<script src="//shadow.elemecdn.com/npm/react@16.0.0/umd/react.development.js"></script> | ||
<script src="//shadow.elemecdn.com/npm/react-dom@16.0.0/umd/react-dom.development.js"></script> | ||
<script src="//shadow.elemecdn.com/npm/react@16.13.0/umd/react.development.js"></script> | ||
<script src="//shadow.elemecdn.com/npm/react-dom@16.13.0/umd/react-dom.development.js"></script> | ||
<script src="//shadow.elemecdn.com/npm/[email protected]/min/moment-with-locales.js"></script> | ||
<script> | ||
window.mountNode = document.getElementById('mount-node'); | ||
|
Oops, something went wrong.