Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ require('rc-collapse/assets/index.css');

var collapse = (
<Collapse accordion={true}>
<Panel header="hello">this is panel content</Panel>
<Panel header="hello" headerClass="my-header-class">this is panel content</Panel>
<Panel header="title2">this is panel content2 or other</Panel>
</Collapse>
);
Expand Down Expand Up @@ -138,6 +138,12 @@ If `accordion` is true, only one panel can be open. Opening another panel will
<th></th>
<td>header content of Panel</td>
</tr>
<tr>
<td>headerClass</td>
<td>String</td>
<th>' '</th>
<td>custom className to apply to header</td>
</tr>
<tr>
<td>showArrow</td>
<td>boolean</td>
Expand Down
2 changes: 2 additions & 0 deletions src/Collapse.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Collapse extends Component {
// If there is no key provide, use the panel order as default key
const key = child.key || String(index);
const header = child.props.header;
const headerClass = child.props.headerClass;
let isActive = false;
if (accordion) {
isActive = activeKey[0] === key;
Expand All @@ -81,6 +82,7 @@ class Collapse extends Component {
const props = {
key,
header,
headerClass,
isActive,
prefixCls,
destroyInactivePanel,
Expand Down
5 changes: 4 additions & 1 deletion src/Panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ class CollapsePanel extends Component {
style,
prefixCls,
header,
headerClass,
children,
isActive,
showArrow,
destroyInactivePanel,
} = this.props;
const headerCls = `${prefixCls}-header`;
const headerCls = `${prefixCls}-header ${headerClass}`;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use classNames here.

const itemCls = classNames({
[`${prefixCls}-item`]: true,
[`${prefixCls}-item-active`]: isActive,
Expand Down Expand Up @@ -68,6 +69,7 @@ CollapsePanel.propTypes = {
PropTypes.number,
PropTypes.node,
]),
headerClass: PropTypes.string,
showArrow: PropTypes.bool,
isActive: PropTypes.bool,
onItemClick: PropTypes.func,
Expand All @@ -80,6 +82,7 @@ CollapsePanel.defaultProps = {
isActive: false,
destroyInactivePanel: false,
onItemClick() {},
headerClass: '',
};

export default CollapsePanel;