mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: responsive sidebar
This commit is contained in:
19
assets/hooks/useBreakpoint.tsx
Normal file
19
assets/hooks/useBreakpoint.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { Breakpoint, theme } from 'antd';
|
||||
import { useMediaQuery } from 'react-responsive';
|
||||
|
||||
const { useToken } = theme;
|
||||
|
||||
type ScreenProperty = 'screenXXL' | 'screenXL' | 'screenLG' | 'screenMD' | 'screenSM' | 'screenXS';
|
||||
|
||||
const propertyName = (breakpoint: Breakpoint): ScreenProperty => {
|
||||
return 'screen' + breakpoint.toUpperCase() as ScreenProperty
|
||||
};
|
||||
|
||||
export default function useBreakpoint(
|
||||
breakpoint: Breakpoint
|
||||
) {
|
||||
const { token } = useToken()
|
||||
const width: number = token[propertyName(breakpoint)]
|
||||
|
||||
return useMediaQuery({maxWidth: width})
|
||||
}
|
||||
Reference in New Issue
Block a user