-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathDashKitView.tsx
More file actions
42 lines (31 loc) · 1.35 KB
/
DashKitView.tsx
File metadata and controls
42 lines (31 loc) · 1.35 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
import React from 'react';
import {DashKitContext} from '../../context';
import {withContext} from '../../hocs/withContext';
import type {DashKitWithContextProps} from '../../hocs/withContext';
import {useCalcPropsLayout} from '../../hooks/useCalcLayout';
import {cn} from '../../utils/cn';
import GridLayout from '../GridLayout/GridLayout';
import MobileLayout from '../MobileLayout/MobileLayout';
import './DashKitView.scss';
const b = cn('dashkit');
type DashKitViewProps = Omit<DashKitWithContextProps, 'layout' | 'forwardedMetaRef'>;
function DashKitView() {
const context = React.useContext(DashKitContext);
const {registerManager, forwardedMetaRef} = context;
return (
<div className={b({theme: registerManager.settings.theme})}>
{registerManager.settings.isMobile ? (
<MobileLayout />
) : (
<GridLayout ref={forwardedMetaRef} />
)}
</div>
);
}
const DashKitViewWithContext = withContext(DashKitView);
const DashKitViewForwardedMeta = React.forwardRef((props: DashKitViewProps, ref) => {
const layout = useCalcPropsLayout(props.config, props.registerManager);
return <DashKitViewWithContext {...props} layout={layout} forwardedMetaRef={ref} />;
});
DashKitViewForwardedMeta.displayName = 'DashKitViewForwardedMeta';
export default DashKitViewForwardedMeta;