[WIP] Import Plans

This commit is contained in:
2022-07-07 10:17:46 +07:00
parent f18bb85b94
commit 574004d408
146 changed files with 28928 additions and 71 deletions

View File

@@ -83,7 +83,7 @@ function NavListSub({ list }: NavListSubProps) {
const { pathname } = useLocation();
const active = getActive(list.path, pathname);
const active = getActive(list.path, pathname, list.openWhen);
const [open, setOpen] = useState(false);

View File

@@ -9,6 +9,9 @@ export function isExternalLink(path: string) {
return path.includes('http');
}
export function getActive(path: string, pathname: string) {
return path ? !!matchPath({ path: path, end: false }, pathname) : false;
export function getActive(path: string, pathname: string, openWhen?: string[]) {
const listPathWhenActive = [ ...openWhen ?? [], path ];
return listPathWhenActive.includes(pathname);
// return path ? !!matchPath({ path: path, end: false }, pathname) : false;
}

View File

@@ -8,6 +8,7 @@ export type NavListProps = {
path: string;
icon?: ReactElement;
info?: ReactElement;
openWhen? : string[];
children?: {
title: string;
path: string;

View File

@@ -18,7 +18,7 @@ type NavListRootProps = {
export function NavListRoot({ list, isCollapse }: NavListRootProps) {
const { pathname } = useLocation();
const active = getActive(list.path, pathname);
const active = getActive(list.path, pathname, list.openWhen);
const [open, setOpen] = useState(active);