🎨 Format with prettier

This commit is contained in:
Meierschlumpf
2023-01-07 09:45:00 +01:00
parent 6be0779ac3
commit 1ea4ca2149
15 changed files with 307 additions and 304 deletions

View File

@@ -9,21 +9,21 @@ interface DashboardSidebarProps extends DashboardSidebarInnerProps {
}
export const DashboardSidebar = ({ location, isGridstackReady }: DashboardSidebarProps) => (
<Card
withBorder
w={300}
style={{
background: 'none',
borderStyle: 'dashed',
}}
>
{isGridstackReady && <SidebarInner location={location} />}
</Card>
);
<Card
withBorder
w={300}
style={{
background: 'none',
borderStyle: 'dashed',
}}
>
{isGridstackReady && <SidebarInner location={location} />}
</Card>
);
interface DashboardSidebarInnerProps {
location: 'right' | 'left';
}
interface DashboardSidebarInnerProps {
location: 'right' | 'left';
}
// Is Required because of the gridstack main area width.
const SidebarInner = ({ location }: DashboardSidebarInnerProps) => {
@@ -32,16 +32,17 @@ const SidebarInner = ({ location }: DashboardSidebarInnerProps) => {
const minRow = useMinRowForFullHeight(refs.wrapper);
return (
<div
className="grid-stack grid-stack-sidebar"
style={{ transitionDuration: '0s', height: '100%' }}
data-sidebar={location}
// eslint-disable-next-line react/no-unknown-property
gs-min-row={minRow}
ref={refs.wrapper}
>
<WrapperContent apps={apps} refs={refs} widgets={widgets} />
</div>);
<div
className="grid-stack grid-stack-sidebar"
style={{ transitionDuration: '0s', height: '100%' }}
data-sidebar={location}
// eslint-disable-next-line react/no-unknown-property
gs-min-row={minRow}
ref={refs.wrapper}
>
<WrapperContent apps={apps} refs={refs} widgets={widgets} />
</div>
);
};
const useMinRowForFullHeight = (wrapperRef: RefObject<HTMLDivElement>) =>

View File

@@ -19,9 +19,9 @@ interface WrapperContentProps {
}
export function WrapperContent({ apps, refs, widgets }: WrapperContentProps) {
const shapeSize = useGridstackStore(x => x.currentShapeSize);
const shapeSize = useGridstackStore((x) => x.currentShapeSize);
if (!shapeSize) return null;
if (!shapeSize) return null;
return (
<>

View File

@@ -64,20 +64,16 @@ export const initializeGridstack = (
grid.batchUpdate();
grid.removeAll(false);
items.forEach(
({ id, shape }) => {
const item = itemRefs.current[id]?.current;
setAttributesFromShape(item, shape[shapeSize]);
item && grid.makeWidget(item as HTMLDivElement);
}
);
widgets.forEach(
({ id, shape }) => {
const item = itemRefs.current[id]?.current;
setAttributesFromShape(item, shape[shapeSize]);
item && grid.makeWidget(item as HTMLDivElement);
}
);
items.forEach(({ id, shape }) => {
const item = itemRefs.current[id]?.current;
setAttributesFromShape(item, shape[shapeSize]);
item && grid.makeWidget(item as HTMLDivElement);
});
widgets.forEach(({ id, shape }) => {
const item = itemRefs.current[id]?.current;
setAttributesFromShape(item, shape[shapeSize]);
item && grid.makeWidget(item as HTMLDivElement);
});
grid.batchUpdate(false);
};

View File

@@ -1,11 +1,5 @@
import { GridStack, GridStackNode } from 'fily-publish-gridstack';
import {
createRef,
MutableRefObject,
RefObject,
useEffect, useMemo,
useRef,
} from 'react';
import { createRef, MutableRefObject, RefObject, useEffect, useMemo, useRef } from 'react';
import { useConfigContext } from '../../../../config/provider';
import { useConfigStore } from '../../../../config/store';
import { AppType } from '../../../../types/app';
@@ -39,12 +33,13 @@ export const useGridstack = (
// reference of the gridstack object for modifications after initialization
const gridRef = useRef<GridStack>();
const wrapperColumnCount = useWrapperColumnCount();
const shapeSize = useGridstackStore(x => x.currentShapeSize);
const mainAreaWidth = useGridstackStore(x => x.mainAreaWidth);
const shapeSize = useGridstackStore((x) => x.currentShapeSize);
const mainAreaWidth = useGridstackStore((x) => x.mainAreaWidth);
// width of the wrapper (updating on page resize)
const root: HTMLHtmlElement = useMemo(() => document.querySelector(':root')!, []);
if (!mainAreaWidth || !shapeSize || !wrapperColumnCount) throw new Error('UseGridstack should not be executed before mainAreaWidth has been set!');
if (!mainAreaWidth || !shapeSize || !wrapperColumnCount)
throw new Error('UseGridstack should not be executed before mainAreaWidth has been set!');
const items = useMemo(
() =>
@@ -86,7 +81,7 @@ export const useGridstack = (
}, [mainAreaWidth, wrapperColumnCount, gridRef.current]);
useEffect(() => {
// column count is used to define count of columns of gridstack within global.scss
// column count is used to define count of columns of gridstack within global.scss
root.style.setProperty('--gridstack-column-count', wrapperColumnCount.toString());
}, [wrapperColumnCount]);