mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added sidebar navigation
This commit is contained in:
parent
1bb08f72e6
commit
a03f80259d
6 changed files with 150 additions and 70 deletions
|
@ -1,22 +1,48 @@
|
|||
import { VFC } from 'react';
|
||||
import { useCallback, useMemo, VFC } from "react";
|
||||
|
||||
import { ProfileSidebarNotes } from '~/components/profile/ProfileSidebarNotes';
|
||||
import { ProfileSidebarSettings } from '~/components/profile/ProfileSidebarSettings';
|
||||
import { SidebarStack } from '~/components/sidebar/SidebarStack';
|
||||
import { SidebarStackCard } from '~/components/sidebar/SidebarStackCard';
|
||||
import { ProfileSidebarMenu } from '~/containers/profile/ProfileSidebarMenu';
|
||||
import { SidebarWrapper } from '~/containers/sidebars/SidebarWrapper';
|
||||
import { DialogComponentProps } from '~/types/modal';
|
||||
import { isNil } from "ramda";
|
||||
|
||||
interface ProfileSidebarProps extends DialogComponentProps {
|
||||
page: string;
|
||||
import { ProfileSidebarNotes } from "~/components/profile/ProfileSidebarNotes";
|
||||
import { ProfileSidebarSettings } from "~/components/profile/ProfileSidebarSettings";
|
||||
import { SidebarStack } from "~/components/sidebar/SidebarStack";
|
||||
import { SidebarStackCard } from "~/components/sidebar/SidebarStackCard";
|
||||
import { SidebarName } from "~/constants/sidebar";
|
||||
import { ProfileSidebarMenu } from "~/containers/profile/ProfileSidebarMenu";
|
||||
import { SidebarWrapper } from "~/containers/sidebars/SidebarWrapper";
|
||||
import { SidebarComponentProps } from "~/types/sidebar";
|
||||
import { useSidebar } from "~/utils/providers/SidebarProvider";
|
||||
|
||||
type TabName = "profile" | "bookmarks";
|
||||
interface ProfileSidebarProps extends SidebarComponentProps {
|
||||
page?: TabName;
|
||||
}
|
||||
|
||||
const ProfileSidebar: VFC<ProfileSidebarProps> = ({ onRequestClose }) => {
|
||||
const tabs: TabName[] = ["profile", "bookmarks"];
|
||||
|
||||
const ProfileSidebar: VFC<ProfileSidebarProps> = ({ onRequestClose, page }) => {
|
||||
const initialTab = useMemo(
|
||||
() => (page ? Math.min(tabs.indexOf(page), 0) : undefined),
|
||||
[page],
|
||||
);
|
||||
|
||||
const { open } = useSidebar();
|
||||
|
||||
const onTabChange = useCallback(
|
||||
(val: number | undefined) => {
|
||||
console.log({ val });
|
||||
open(SidebarName.Settings, { page: !isNil(val) ? tabs[val] : undefined });
|
||||
},
|
||||
[open],
|
||||
);
|
||||
|
||||
return (
|
||||
<SidebarWrapper onClose={onRequestClose}>
|
||||
<SidebarStack>
|
||||
<SidebarStackCard headerFeature="close" title="Профиль" onBackPress={onRequestClose}>
|
||||
<SidebarStack tab={initialTab} onTabChange={onTabChange}>
|
||||
<SidebarStackCard
|
||||
headerFeature="close"
|
||||
title="Профиль"
|
||||
onBackPress={onRequestClose}
|
||||
>
|
||||
<ProfileSidebarMenu onClose={onRequestClose} />
|
||||
</SidebarStackCard>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue