style: subdrawer width

This commit is contained in:
jialin
2026-05-27 12:14:15 +08:00
committed by jialin
parent 1878753cde
commit 7287f8c81b
10 changed files with 176 additions and 68 deletions
@@ -0,0 +1,31 @@
import { useCallback, useEffect, useState } from 'react';
import instanceStyles from '../styles/instances.module.less';
const FALLBACK_WIDTH = `calc((100vw - 220px) / 3 + 16px)`;
const useOverlayLayout = (open: boolean) => {
const [drawerWidth, setDrawerWidth] = useState<number | string>(
FALLBACK_WIDTH
);
useEffect(() => {
if (!open) return;
const formWrapper = document.querySelector<HTMLElement>(
`.${instanceStyles.formWrapper}`
);
if (formWrapper) {
setDrawerWidth(formWrapper.clientWidth);
}
}, [open]);
const getOverlayContainer = useCallback(() => {
const containers = document.querySelectorAll<HTMLElement>(
'.ant-layout-content'
);
return containers[containers.length - 1] ?? null;
}, []);
return { drawerWidth, getOverlayContainer };
};
export default useOverlayLayout;