-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
ae4d20a
commit 936ce11
Showing
13 changed files
with
151 additions
and
42 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,9 @@ | ||
import { createCtx } from '@dassana-io/web-utils' | ||
|
||
export interface TableContextProps { | ||
isMobile: boolean | ||
} | ||
|
||
const [useTableContext, TableCtxProvider] = createCtx<TableContextProps>() | ||
|
||
export { TableCtxProvider, useTableContext } |
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
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,38 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
const getWindowSize = () => ({ | ||
height: window.innerHeight, | ||
width: window.innerWidth | ||
}) | ||
|
||
export interface WindowSize { | ||
height: number | ||
width: number | ||
} | ||
|
||
export enum Breakpoints { | ||
mobile = 480 | ||
} | ||
|
||
export const useWindowSize = () => { | ||
const [windowSize, setWindowSize] = useState<WindowSize>(getWindowSize()) | ||
const [isMobile, setIsMobile] = useState(false) | ||
|
||
useEffect(() => { | ||
const handleResize = () => setWindowSize(getWindowSize()) | ||
|
||
window.addEventListener('resize', handleResize) | ||
|
||
handleResize() | ||
|
||
return () => window.removeEventListener('resize', handleResize) | ||
}, []) | ||
|
||
useEffect(() => { | ||
windowSize.width <= Breakpoints.mobile | ||
? setIsMobile(true) | ||
: setIsMobile(false) | ||
}, [windowSize]) | ||
|
||
return { isMobile, windowSize } | ||
} |
Oops, something went wrong.