mirror of
https://codeberg.org/MarkusThielker/next-ory.git
synced 2025-07-02 04:59:17 +00:00
NORY-8: add shadcn-ui sidebar component
This commit is contained in:
parent
71c7d6fda0
commit
7d04a8faa1
8 changed files with 1179 additions and 72 deletions
19
dashboard/src/hooks/use-mobile.tsx
Normal file
19
dashboard/src/hooks/use-mobile.tsx
Normal file
|
@ -0,0 +1,19 @@
|
|||
import * as React from 'react';
|
||||
|
||||
const MOBILE_BREAKPOINT = 768;
|
||||
|
||||
export function useIsMobile() {
|
||||
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
|
||||
|
||||
React.useEffect(() => {
|
||||
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
||||
const onChange = () => {
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
};
|
||||
mql.addEventListener('change', onChange);
|
||||
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
||||
return () => mql.removeEventListener('change', onChange);
|
||||
}, []);
|
||||
|
||||
return !!isMobile;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue