Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for contentClass prop #166

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ If `accordion` is true, only one panel can be open. Opening another panel will
<th>' '</th>
<td>custom className to apply to header</td>
</tr>
<tr>
<td>contentClass</td>
<td>String</td>
<th>' '</th>
<td>custom className to apply to content</td>
</tr>
<tr>
<td>showArrow</td>
<td>boolean</td>
Expand Down
3 changes: 3 additions & 0 deletions src/Panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class CollapsePanel extends React.Component<CollapsePanelProps, any> {
destroyInactivePanel: false,
onItemClick() {},
headerClass: '',
contentClass: '',
forceRender: false,
};

Expand Down Expand Up @@ -42,6 +43,7 @@ class CollapsePanel extends React.Component<CollapsePanelProps, any> {
prefixCls,
header,
headerClass,
contentClass,
children,
isActive,
showArrow,
Expand Down Expand Up @@ -85,6 +87,7 @@ class CollapsePanel extends React.Component<CollapsePanelProps, any> {
</div>
<Animate showProp="isActive" exclusive component="" animation={this.props.openAnimation}>
<PanelContent
contentClass={contentClass}
prefixCls={prefixCls}
isActive={isActive}
destroyInactivePanel={destroyInactivePanel}
Expand Down
11 changes: 10 additions & 1 deletion src/PanelContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@ class PanelContent extends React.Component<CollapsePanelProps, any> {
if (!this._isActived) {
return null;
}
const { prefixCls, isActive, children, destroyInactivePanel, forceRender, role } = this.props;
const {
prefixCls,
contentClass,
isActive,
children,
destroyInactivePanel,
forceRender,
role,
} = this.props;

const contentCls = classnames(`${prefixCls}-content`, {
[`${prefixCls}-content-active`]: isActive,
[`${prefixCls}-content-inactive`]: !isActive,
[contentClass]: contentClass,
});

const child =
Expand Down
1 change: 1 addition & 0 deletions src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface CollapsePanelProps {
header?: string | React.ReactNode;
prefixCls?: string;
headerClass?: string;
contentClass?: string;
showArrow?: boolean;
className?: string;
style?: object;
Expand Down