Skip to content

Commit

Permalink
fix: globalBodyWidth
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 committed Jan 27, 2025
1 parent 0e19d7c commit 357fe56
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions webapp/src/globalContext/useLayoutService.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRef, useState } from 'react';
import { useResizeObserver } from 'usehooks-ts';
import { useState } from 'react';
import { useWindowSize } from 'usehooks-ts';
import type { useQuickStartGuideService } from './useQuickStartGuideService';

export const TOP_BAR_HEIGHT = 52;
Expand All @@ -14,18 +14,11 @@ export const useLayoutService = ({ quickStart }: Props) => {
const [topBannerHeight, setTopBannerHeight] = useState(0);
const [topSubBannerHeight, setTopSubBannerHeight] = useState(0);
const [topBarHidden, setTopBarHidden] = useState(false);
const [bodyWidth, setBodyWidth] = useState(document.body.offsetWidth);
const viewPortSize = useWindowSize();
const [rightPanelFloatingForced, setRightPanelFloatingForced] =
useState(false);

const bodyRef = useRef(document.body);

useResizeObserver({
ref: bodyRef,
onResize(size) {
Promise.resolve(() => setBodyWidth(size.width!));
},
});
const bodyWidth = viewPortSize.width;

const rightPanelShouldFloat = bodyWidth < 1200 || rightPanelFloatingForced;

Expand Down

0 comments on commit 357fe56

Please sign in to comment.