-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement #117 to help cooling small GPUs down
- Loading branch information
1 parent
79b9688
commit e12935f
Showing
6 changed files
with
117 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { useState, useEffect } from 'react' | ||
|
||
export type Breakpoints = { | ||
isSm: boolean | ||
isMd: boolean | ||
isLg: boolean | ||
isXl: boolean | ||
is2xl: boolean | ||
} | ||
|
||
export function useBreakpoints(): Breakpoints { | ||
const [breakpoints, setBreakpoints] = useState<Breakpoints>({ | ||
isSm: false, | ||
isMd: false, | ||
isLg: false, | ||
isXl: false, | ||
is2xl: false, | ||
}) | ||
|
||
useEffect(() => { | ||
const updateBreakpoints = () => { | ||
const width = window.innerWidth | ||
setBreakpoints({ | ||
isSm: width >= 640, | ||
isMd: width >= 768, | ||
isLg: width >= 1024, | ||
isXl: width >= 1280, | ||
is2xl: width >= 1536, | ||
}) | ||
} | ||
|
||
// Initial check | ||
updateBreakpoints() | ||
|
||
// Add event listener | ||
window.addEventListener('resize', updateBreakpoints) | ||
|
||
// Cleanup | ||
return () => window.removeEventListener('resize', updateBreakpoints) | ||
}, []) | ||
|
||
return breakpoints | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters