forked from microsoft/fluentui
/
Overlay.base.tsx
38 lines (28 loc) · 1.18 KB
/
Overlay.base.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
import * as React from 'react';
import { BaseComponent, classNamesFunction, getNativeProps, divProperties, enableBodyScroll, disableBodyScroll } from '../../Utilities';
import { IOverlayProps, IOverlayStyleProps, IOverlayStyles } from './Overlay.types';
const getClassNames = classNamesFunction<IOverlayStyleProps, IOverlayStyles>();
export class OverlayBase extends BaseComponent<IOverlayProps, {}> {
private _allowTouchBodyScroll: boolean;
constructor(props: IOverlayProps) {
super(props);
const { allowTouchBodyScroll = false } = this.props;
this._allowTouchBodyScroll = allowTouchBodyScroll;
}
public componentDidMount(): void {
!this._allowTouchBodyScroll && disableBodyScroll();
}
public componentWillUnmount(): void {
!this._allowTouchBodyScroll && enableBodyScroll();
}
public render(): JSX.Element {
const { isDarkThemed: isDark, className, theme, styles } = this.props;
const divProps = getNativeProps<React.HTMLAttributes<HTMLDivElement>>(this.props, divProperties);
const classNames = getClassNames(styles!, {
theme: theme!,
className,
isDark
});
return <div {...divProps} className={classNames.root} />;
}
}