-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow virtuoso to resize dynamically, ref #5242
- Loading branch information
1 parent
b0276ec
commit 6f242c3
Showing
13 changed files
with
190 additions
and
121 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
import { BreakpointToken, token } from 'leather-styles/tokens'; | ||
|
||
function useMediaQuery(query: string) { | ||
const [matches, setMatches] = useState(false); | ||
|
||
useEffect(() => { | ||
const media = window.matchMedia(query); | ||
if (media.matches !== matches) { | ||
setMatches(media.matches); | ||
} | ||
const listener = () => setMatches(media.matches); | ||
window.addEventListener('resize', listener); | ||
return () => window.removeEventListener('resize', listener); | ||
}, [matches, query]); | ||
|
||
return matches; | ||
} | ||
|
||
export function useViewportMinWidth(viewport: BreakpointToken) { | ||
return useMediaQuery(`(min-width: ${token(`breakpoints.${viewport}`)})`); | ||
} |
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
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
Oops, something went wrong.