-
Notifications
You must be signed in to change notification settings - Fork 140
Expand file tree
/
Copy pathPanelContent.tsx
More file actions
56 lines (50 loc) · 1.1 KB
/
PanelContent.tsx
File metadata and controls
56 lines (50 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import classnames from 'classnames';
import React from 'react';
import type { CollapsePanelProps } from './interface';
const PanelContent = React.forwardRef<
HTMLDivElement,
React.PropsWithChildren<Readonly<CollapsePanelProps>>
>((props, ref) => {
const {
prefixCls,
forceRender,
className,
style,
children,
isActive,
role,
classNames: customizeClassNames,
styles,
} = props;
const rendered = isActive || forceRender;
if (!rendered) {
return null;
}
return (
<div
ref={ref}
className={classnames(
`${prefixCls}-panel`,
{
[`${prefixCls}-panel-active`]: isActive,
[`${prefixCls}-panel-inactive`]: !isActive,
},
className,
)}
style={{
display: isActive ? 'block' : 'none',
...style,
}}
role={role}
>
<div
className={classnames(`${prefixCls}-body`, customizeClassNames?.body)}
style={styles?.body}
>
{children}
</div>
</div>
);
});
PanelContent.displayName = 'PanelContent';
export default PanelContent;