mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-17 06:33:53 -05:00
- `curly` requires conditionals to use curly braces - `react/jsx-curly-brace-presence` requires string props to *not* have curly braces
25 lines
581 B
TypeScript
25 lines
581 B
TypeScript
import { useBreakpoint } from '@chakra-ui/react';
|
|
|
|
export default function useResolution():
|
|
| 'mobile'
|
|
| 'tablet'
|
|
| 'desktop'
|
|
| 'unknown' {
|
|
const breakpointValue = useBreakpoint();
|
|
|
|
const mobileResolutions = ['base', 'sm'];
|
|
const tabletResolutions = ['md', 'lg'];
|
|
const desktopResolutions = ['xl', '2xl'];
|
|
|
|
if (mobileResolutions.includes(breakpointValue)) {
|
|
return 'mobile';
|
|
}
|
|
if (tabletResolutions.includes(breakpointValue)) {
|
|
return 'tablet';
|
|
}
|
|
if (desktopResolutions.includes(breakpointValue)) {
|
|
return 'desktop';
|
|
}
|
|
return 'unknown';
|
|
}
|