1
0
Fork 0
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:
Fedor Katurov 2022-08-05 18:45:11 +07:00
parent 1bb08f72e6
commit a03f80259d
6 changed files with 150 additions and 70 deletions

View file

@ -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>