-
Notifications
You must be signed in to change notification settings - Fork 531
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reposition menus on narrow screens and add 2-column view (#3044)
* Fix positions of menus and overlays on narrow screens * Always show target locale code in the navbar * Implement a 2-column UI for middle screen widths between 600 and 800 pixels Also: * Expand Header navigation breakpoint to the middle screens * Prevent jumping when moving between tabs * useNarrowScreen() -> useWindowWidth()
- Loading branch information
Showing
7 changed files
with
121 additions
and
52 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 was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
const BREAKPOINTS = { | ||
narrow: 600, | ||
medium: 800, | ||
}; | ||
|
||
/** | ||
* Return window width range: narrow, medium or wide. | ||
* | ||
* Useful in Responsive Web Design. | ||
*/ | ||
export function useWindowWidth(): 'narrow' | 'medium' | 'wide' { | ||
function get_range(): 'narrow' | 'medium' | 'wide' { | ||
if (window.innerWidth <= BREAKPOINTS.narrow) { | ||
return 'narrow'; | ||
} | ||
if (window.innerWidth <= BREAKPOINTS.medium) { | ||
return 'medium'; | ||
} | ||
return 'wide'; | ||
} | ||
|
||
const [windowWidth, setWindowWidth] = useState(get_range()); | ||
|
||
useEffect(() => { | ||
const handleWindowResize = () => setWindowWidth(get_range()); | ||
window.addEventListener('resize', handleWindowResize); | ||
return () => window.removeEventListener('resize', handleWindowResize); | ||
}, []); | ||
|
||
return windowWidth; | ||
} |
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