perf(AppContainer): dynamic width

This commit is contained in:
molvqingtai 2024-09-17 15:59:55 +08:00
parent 15821eaa47
commit 3d45e4609c
2 changed files with 9 additions and 4 deletions

View file

@ -1,14 +1,18 @@
import { type ReactNode, type FC } from 'react'
import useResizable from '@/hooks/useResizable'
import useBreakpoint from '@/hooks/useBreakpoint'
export interface AppContainerProps {
children?: ReactNode
}
const AppContainer: FC<AppContainerProps> = ({ children }) => {
const { breakpoint } = useBreakpoint()
console.log(breakpoint)
const { size, ref } = useResizable({
initSize: 375,
maxSize: 750,
minSize: 375,
initSize: Math.max(375, window.innerWidth / 5),
maxSize: Math.max(750, window.innerWidth / 3),
minSize: Math.max(375, window.innerWidth / 5),
direction: 'left'
})

View file

@ -11,7 +11,8 @@ const useBreakpoint = () => {
isMD: breakpoint === 'md',
isLG: breakpoint === 'lg',
isXL: breakpoint === 'xl',
is2XL: breakpoint === '2xl'
is2XL: breakpoint === '2xl',
breakpoint
}
}