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
1 parent
fd388fa
commit 3ae7070
Showing
11 changed files
with
227 additions
and
10 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
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,123 @@ | ||
Card 卡片 | ||
=== | ||
|
||
通用卡片容器,将信息聚合在卡片容器中展示,用来显示文字、列表、图文等内容。 | ||
|
||
|
||
## 基础用法 | ||
|
||
包含标题、内容、操作区域。 | ||
|
||
<!--DemoStart--> | ||
```js | ||
render() { | ||
return ( | ||
<Card title="Card标题" extra={<a href="#">更多</a>} style={{ width: 300 }}> | ||
卡片内容<br/> | ||
卡片内容<br/> | ||
卡片内容<br/> | ||
</Card> | ||
) | ||
} | ||
``` | ||
<!--End--> | ||
|
||
## 无边框 | ||
|
||
在灰色背景上使用无边框的卡片。 | ||
|
||
<!--DemoStart--> | ||
```js | ||
render() { | ||
return ( | ||
<div style={{ background: '#ECECEC', padding: '30px' }}> | ||
<Card title="Card标题" bordered={false} style={{ width: 300 }}> | ||
卡片内容<br/> | ||
卡片内容<br/> | ||
卡片内容<br/> | ||
</Card> | ||
</div> | ||
) | ||
} | ||
``` | ||
<!--End--> | ||
|
||
## 简洁卡片 | ||
|
||
只包含内容区域。 | ||
|
||
<!--DemoStart--> | ||
```js | ||
render() { | ||
return ( | ||
<Card style={{ width: 300 }}> | ||
卡片内容<br/> | ||
卡片内容<br/> | ||
卡片内容<br/> | ||
</Card> | ||
) | ||
} | ||
``` | ||
<!--End--> | ||
|
||
## 更灵活的内容展示 | ||
|
||
可以调整默认边距,设定宽度。 | ||
|
||
<!--DemoStart--> | ||
```js | ||
render() { | ||
let titleStyle = {padding: `10px 16px`} | ||
return ( | ||
<Card style={{ width: 240 }} bodyStyle={{ padding: 0 }}> | ||
<div> | ||
<img alt="example" width="100%" src="http://7xi8d6.com1.z0.glb.clouddn.com/20171018091347_Z81Beh_nini.nicky_18_10_2017_9_13_35_727.jpeg" /> | ||
</div> | ||
<div style={titleStyle}> | ||
<h3 style={{margin:0}}>我爱漂亮妹妹</h3> | ||
<p style={{margin:0}}><a href="https://uiw-react.github.io">https://uiw-react.github.io</a></p> | ||
</div> | ||
</Card> | ||
) | ||
} | ||
``` | ||
<!--End--> | ||
|
||
## 更灵活的内容展示 | ||
|
||
可以调整默认边距,设定宽度。 | ||
|
||
<!--DemoStart--> | ||
```js | ||
render() { | ||
const {Row,Col} = Layout; | ||
return ( | ||
<div style={{ background: '#ECECEC', padding: '20px 10px' }}> | ||
<Row gutter={16}> | ||
<Col span={8}> | ||
<Card title="卡片标题" bordered={false}>卡片内容!</Card> | ||
</Col> | ||
<Col span={8}> | ||
<Card title="卡片标题" bordered={false}>卡片内容!</Card> | ||
</Col> | ||
<Col span={8}> | ||
<Card title="卡片标题" bordered={false}>卡片内容!</Card> | ||
</Col> | ||
</Row> | ||
</div> | ||
) | ||
} | ||
``` | ||
<!--End--> | ||
|
||
## API | ||
|
||
### Card | ||
|
||
| 参数 | 说明 | 类型 | 默认值 | | ||
|--------- |-------- |--------- |-------- | | ||
| title | 卡片标题 | String/ReactNode | - | | ||
| extra | 卡片右上角的操作区域 | String/ReactNode | - | | ||
| bordered | 是否显示边框 | Boolean | `true` | | ||
| noHover | 取消鼠标移过浮起 | Boolean | `false` | | ||
| bodyStyle | 设置 body 的样式 | Object | - | |
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,5 @@ | ||
import Markdown from '../../libs/markdown/'; | ||
|
||
export default class App extends Markdown { | ||
|
||
} |
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,43 @@ | ||
import React from 'react'; | ||
import { Component, PropTypes } from '../utils/'; | ||
|
||
export default class Card extends Component { | ||
render() { | ||
const { prefixCls, className, title, extra, bordered, noHover, bodyStyle, children, ...resetProps } = this.props; | ||
|
||
const cls = this.classNames(prefixCls, className, { | ||
[`${prefixCls}-bordered`]: bordered, | ||
[`${prefixCls}-no-hover`]: noHover, | ||
}); | ||
|
||
let head; | ||
if (title || extra) { | ||
head = ( | ||
<div className={`${prefixCls}-head`}> | ||
{title ? <div className={`${prefixCls}-head-title`}>{title}</div> : null} | ||
{extra ? <div className={`${prefixCls}-extra`}>{extra}</div> : null} | ||
</div> | ||
); | ||
} | ||
return ( | ||
<div {...resetProps} className={cls}> | ||
{head} | ||
<div className={`${prefixCls}-body`} style={bodyStyle}>{children}</div> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Card.propTypes = { | ||
prefixCls: PropTypes.string, | ||
bordered: PropTypes.bool, | ||
extra: PropTypes.node, | ||
noHover: PropTypes.bool, | ||
bodyStyle: PropTypes.object, | ||
} | ||
|
||
Card.defaultProps = { | ||
prefixCls: 'w-card', | ||
bordered: true, | ||
noHover: false, | ||
} |
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,3 @@ | ||
import Card from './Card'; | ||
import "./style/index.less"; | ||
export default Card; |
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,47 @@ | ||
@import "../../style/variables.less"; | ||
@import "../../style/mixins/index.less"; | ||
|
||
@card-prefix: ~"w-card"; | ||
|
||
.@{card-prefix}{ | ||
background: #fff; | ||
border-radius: 5px; | ||
font-size: 12px; | ||
position: relative; | ||
transition: all .3s; | ||
overflow: hidden; | ||
&:not(&-no-hovering):hover { | ||
box-shadow: 0 1px 6px rgba(0,0,0,.2); | ||
border-color: rgba(0,0,0,.2); | ||
} | ||
&-bordered{ | ||
border: 1px solid #e9e9e9; | ||
} | ||
&-head{ | ||
height: 48px; | ||
line-height: 48px; | ||
border-bottom: 1px solid #e9e9e9; | ||
padding: 0 14px; | ||
border-radius: 2px 2px 0 0; | ||
zoom: 1; | ||
} | ||
|
||
&-head-title{ | ||
font-size: 14px; | ||
text-overflow: ellipsis; | ||
max-width: 100%; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
color: rgba(0,0,0,.85); | ||
font-weight: 500; | ||
display: inline-block; | ||
} | ||
&-extra{ | ||
position: absolute; | ||
right: 16px; | ||
top: 0px; | ||
} | ||
&-body{ | ||
padding:14px; | ||
} | ||
} |
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