2022-12-04 17:36:30 +01:00
|
|
|
import { Card } from '@mantine/core';
|
|
|
|
|
import { RefObject } from 'react';
|
2022-12-18 21:50:08 +01:00
|
|
|
import { IWidgetDefinition } from '../../../../widgets/widgets';
|
2022-12-04 19:10:07 +01:00
|
|
|
import { Tiles } from '../../Tiles/tilesDefinitions';
|
2022-12-18 21:50:08 +01:00
|
|
|
import Widgets from '../../../../widgets';
|
2022-12-04 17:36:30 +01:00
|
|
|
import { GridstackTileWrapper } from '../../Tiles/TileWrapper';
|
|
|
|
|
import { useGridstack } from '../gridstack/use-gridstack';
|
2022-12-19 18:03:52 +01:00
|
|
|
import { WrapperContent } from '../WrapperContent';
|
2022-12-04 17:36:30 +01:00
|
|
|
|
|
|
|
|
interface DashboardSidebarProps {
|
|
|
|
|
location: 'right' | 'left';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const DashboardSidebar = ({ location }: DashboardSidebarProps) => {
|
2022-12-19 18:03:52 +01:00
|
|
|
const { refs, apps, widgets } = useGridstack('sidebar', location);
|
2022-12-04 17:36:30 +01:00
|
|
|
|
|
|
|
|
const minRow = useMinRowForFullHeight(refs.wrapper);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Card
|
|
|
|
|
withBorder
|
|
|
|
|
w={300}
|
|
|
|
|
style={{
|
|
|
|
|
background: 'none',
|
|
|
|
|
borderStyle: 'dashed',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div
|
|
|
|
|
className="grid-stack grid-stack-sidebar"
|
|
|
|
|
style={{ transitionDuration: '0s', height: '100%' }}
|
|
|
|
|
data-sidebar={location}
|
|
|
|
|
gs-min-row={minRow}
|
|
|
|
|
ref={refs.wrapper}
|
|
|
|
|
>
|
2022-12-19 18:03:52 +01:00
|
|
|
<WrapperContent apps={apps} refs={refs} widgets={widgets} />
|
2022-12-04 17:36:30 +01:00
|
|
|
</div>
|
|
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const useMinRowForFullHeight = (wrapperRef: RefObject<HTMLDivElement>) => {
|
|
|
|
|
return wrapperRef.current ? Math.floor(wrapperRef.current!.offsetHeight / 64) : 2;
|
|
|
|
|
};
|