Files
Homarr/src/components/Dashboard/Wrappers/Sidebar/Sidebar.tsx

44 lines
1.3 KiB
TypeScript
Raw Normal View History

2022-12-04 17:36:30 +01:00
import { Card } from '@mantine/core';
import { RefObject } from 'react';
import { IWidgetDefinition } from '../../../../widgets/widgets';
2022-12-04 19:10:07 +01:00
import { Tiles } from '../../Tiles/tilesDefinitions';
import Widgets from '../../../../widgets';
2022-12-04 17:36:30 +01:00
import { GridstackTileWrapper } from '../../Tiles/TileWrapper';
import { useGridstack } from '../gridstack/use-gridstack';
import { WrapperContent } from '../WrapperContent';
2022-12-04 17:36:30 +01:00
interface DashboardSidebarProps {
location: 'right' | 'left';
}
export const DashboardSidebar = ({ location }: DashboardSidebarProps) => {
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}
>
<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;
};