This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
231711a
commit a295ae8
Showing
4 changed files
with
73 additions
and
13 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,24 @@ | ||
import { makeStyles } from '@material-ui/core'; | ||
import LanguageFilter from './LanguageFilter'; | ||
import MenuPages from './MenuPages'; | ||
import SocialLinks from './SocialLinks'; | ||
|
||
const useStyles = makeStyles((theme) => ({ | ||
filter: { width: 'auto', margin: theme.spacing(2, 0) }, | ||
})); | ||
|
||
const HomeSidebar = () => { | ||
const classes = useStyles(); | ||
|
||
return ( | ||
<aside> | ||
<MenuPages /> | ||
<SocialLinks /> | ||
<div className={classes.filter}> | ||
<LanguageFilter /> | ||
</div> | ||
</aside> | ||
); | ||
}; | ||
|
||
export default HomeSidebar; |
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,7 @@ | ||
import useMediaQuery from './useMediaQuery'; | ||
|
||
const useIsMobile = () => { | ||
return useMediaQuery(640); | ||
}; | ||
|
||
export default useIsMobile; |
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,33 @@ | ||
import { useState, useCallback, useEffect } from 'react'; | ||
|
||
/** | ||
* Check if a media query meets its target. | ||
* Forked from https://github.com/vercel/next-site/blob/master/components/media-query.js | ||
*/ | ||
const useMediaQuery = (width: string | number) => { | ||
const [targetReached, setTargetReached] = useState(false); | ||
|
||
const updateTarget = useCallback((e) => { | ||
if (e.matches) { | ||
setTargetReached(true); | ||
} else { | ||
setTargetReached(false); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
const media = window.matchMedia(`(max-width: ${width}px)`); | ||
media.addListener(updateTarget); | ||
|
||
// Check on mount (callback is not called until a change occurs) | ||
if (media.matches) { | ||
setTargetReached(true); | ||
} | ||
|
||
return () => media.removeListener(updateTarget); | ||
}, [updateTarget, width]); | ||
|
||
return targetReached; | ||
}; | ||
|
||
export default useMediaQuery; |