mirror of
https://github.com/docmost/docmost.git
synced 2025-11-17 05:31:09 +10:00
switch to nx monorepo
This commit is contained in:
16
apps/client/src/hooks/use-match-path.tsx
Normal file
16
apps/client/src/hooks/use-match-path.tsx
Normal file
@ -0,0 +1,16 @@
|
||||
import { useLocation } from 'react-router-dom';
|
||||
|
||||
export const useMatchPath = () => {
|
||||
const location = useLocation();
|
||||
|
||||
const matchPath = (pattern) => {
|
||||
const modifiedPattern = pattern
|
||||
.replace(/:([^/]+)/g, '([^/]+)(?:/.*)?')
|
||||
.replace(/\//g, '\\/');
|
||||
|
||||
const regex = new RegExp(`^${modifiedPattern}$`);
|
||||
return regex.test(location.pathname);
|
||||
};
|
||||
|
||||
return matchPath;
|
||||
};
|
||||
18
apps/client/src/hooks/use-toggle-aside.tsx
Normal file
18
apps/client/src/hooks/use-toggle-aside.tsx
Normal file
@ -0,0 +1,18 @@
|
||||
import { asideStateAtom } from '@/components/navbar/atoms/sidebar-atom';
|
||||
import { useAtom } from 'jotai';
|
||||
|
||||
const useToggleAside = () => {
|
||||
const [asideState, setAsideState] = useAtom(asideStateAtom);
|
||||
|
||||
const toggleAside = (tab: string) => {
|
||||
if (asideState.tab === tab) {
|
||||
setAsideState({ tab, isAsideOpen: !asideState.isAsideOpen });
|
||||
} else {
|
||||
setAsideState({ tab, isAsideOpen: true });
|
||||
}
|
||||
};
|
||||
|
||||
return toggleAside;
|
||||
};
|
||||
|
||||
export default useToggleAside;
|
||||
Reference in New Issue
Block a user