-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPane.tsx
51 lines (45 loc) · 1.27 KB
/
Pane.tsx
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
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import PaneContent from './Content';
import { ForwardComponentWithStatics } from '../utils';
import { PaneContainer } from './index';
export type PaneStatics = {
Content: typeof PaneContent;
Container: typeof PaneContainer;
}
export interface PaneProps extends React.HTMLAttributes<HTMLDivElement> {
horizontal?: boolean;
}
// Static properties are not given yet, when declaring the card const. Therefore, the error saying
// that Pane is missing above PaneStatics properties. These will defined after the pane component
// is defined.
// @ts-ignore
const Pane: ForwardComponentWithStatics<HTMLDivElement, PaneProps, PaneStatics> = React.forwardRef<HTMLDivElement, PaneProps>((
{
children,
className,
horizontal
},
ref
): React.ReactElement => (
<div
ref={ref}
className={clsx(
'pane',
horizontal && 'horizontal',
className
)}
>
{children}
</div>
));
Pane.displayName = 'Pane';
Pane.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
horizontal: PropTypes.bool
}
Pane.Content = PaneContent;
Pane.Container = PaneContainer;
export default Pane;