feat: add component collapse
parent
2a49e993f1
commit
4c28bc1fe2
@ -0,0 +1,36 @@
|
||||
# 折叠面板
|
||||
|
||||
- order: 0
|
||||
|
||||
默认打开第二个面板。
|
||||
|
||||
---
|
||||
|
||||
````jsx
|
||||
var Collapse = antd.Collapse;
|
||||
var Panel = Collapse.Panel;
|
||||
|
||||
function callback(key) {
|
||||
console.log(key);
|
||||
}
|
||||
|
||||
var text = `
|
||||
A dog is a type of domesticated animal.
|
||||
Known for its loyalty and faithfulness,
|
||||
it can be found as a welcome guest in many households across the world.
|
||||
`;
|
||||
|
||||
React.render(
|
||||
<Collapse defaultActiveKey={["2"]} onChange={callback}>
|
||||
<Panel header={`This is panel header 1`} key="1">
|
||||
<p>{text}</p>
|
||||
</Panel>
|
||||
<Panel header={`This is panel header 2`} key="2">
|
||||
<p>{text}</p>
|
||||
</Panel>
|
||||
<Panel header={`This is panel header 3`} key="3">
|
||||
<p>{text}</p>
|
||||
</Panel>
|
||||
</Collapse>
|
||||
, document.getElementById('components-collapse-demo-basic'));
|
||||
````
|
@ -0,0 +1,19 @@
|
||||
'use strict';
|
||||
|
||||
var Collapse = require('rc-collapse');
|
||||
var React = require('react');
|
||||
var prefixCls = 'ant-collapse';
|
||||
|
||||
class AntCollapse extends React.Component {
|
||||
render() {
|
||||
return <Collapse {...this.props} />;
|
||||
}
|
||||
}
|
||||
|
||||
AntCollapse.defaultProps = {
|
||||
prefixCls: prefixCls
|
||||
};
|
||||
|
||||
AntCollapse.Panel = Collapse.Panel;
|
||||
|
||||
module.exports = AntCollapse;
|
@ -0,0 +1,74 @@
|
||||
@prefixCls: ant-collapse;
|
||||
@borderStyle: 1px solid #d9d9d9;
|
||||
|
||||
#arrow {
|
||||
.common(){
|
||||
width: 0;
|
||||
height: 0;
|
||||
font-size: 0;
|
||||
line-height: 0;
|
||||
}
|
||||
.right(@w, @h, @color) {
|
||||
border-top: @w solid transparent;
|
||||
border-bottom: @w solid transparent;
|
||||
border-left: @h solid @color;
|
||||
}
|
||||
|
||||
.bottom(@w, @h, @color) {
|
||||
border-left: @w solid transparent;
|
||||
border-right: @w solid transparent;
|
||||
border-top: @h solid @color;
|
||||
}
|
||||
}
|
||||
|
||||
.@{prefixCls} {
|
||||
background-color: #f3f5f7;
|
||||
border-radius: 3px;
|
||||
border-top: @borderStyle;
|
||||
border-left: @borderStyle;
|
||||
border-right: @borderStyle;
|
||||
|
||||
&-content {
|
||||
height: 0;
|
||||
opacity: 0;
|
||||
transition-property: all;
|
||||
transition-duration: .3s;
|
||||
transition-timing-function: ease-in;
|
||||
overflow: hidden;
|
||||
color: #999;
|
||||
padding: 0 16px;
|
||||
background-color: #fbfbfb;
|
||||
> p, div {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
&-content-active {
|
||||
opacity: 1;
|
||||
height: auto;
|
||||
border-bottom: @borderStyle;
|
||||
}
|
||||
|
||||
&-header {
|
||||
height: 38px;
|
||||
line-height: 38px;
|
||||
text-indent: 16px;
|
||||
color: #666;
|
||||
border-bottom: @borderStyle;
|
||||
&:before {
|
||||
display: inline-block;
|
||||
content: '\20';
|
||||
#arrow > .common();
|
||||
#arrow > .right(3px, 4px, #666);
|
||||
vertical-align: middle;
|
||||
margin-right: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
&-item-active {
|
||||
.@{prefixCls}-header::before {
|
||||
#arrow > .bottom(3px, 4px, #666);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue