mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
made better tabs (with context)
This commit is contained in:
parent
f63d2d3228
commit
da510e346a
12 changed files with 103 additions and 194 deletions
|
@ -1,9 +1,7 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
import styles from './styles.module.scss';
|
||||
import classNames from 'classnames';
|
||||
import { IAuthState } from '~/redux/auth/types';
|
||||
import { Tabs } from '~/components/dialogs/Tabs';
|
||||
import { Tab } from '~/components/dialogs/Tab';
|
||||
|
||||
interface IProps {
|
||||
tab: string;
|
||||
|
@ -12,30 +10,11 @@ interface IProps {
|
|||
}
|
||||
|
||||
const ProfileTabs: FC<IProps> = ({ tab, is_own, setTab }) => {
|
||||
const changeTab = useCallback(
|
||||
(tab: IAuthState['profile']['tab']) => () => {
|
||||
if (!setTab) return;
|
||||
setTab(tab);
|
||||
},
|
||||
[setTab]
|
||||
);
|
||||
const items = ['Профиль', 'Сообщения', ...(is_own ? ['Настройки'] : [])];
|
||||
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
<Tabs>
|
||||
<Tab active={tab === 'profile'} onClick={changeTab('profile')}>
|
||||
Профиль
|
||||
</Tab>
|
||||
|
||||
<Tab active={tab === 'messages'} onClick={changeTab('messages')}>
|
||||
Сообщения
|
||||
</Tab>
|
||||
{is_own && (
|
||||
<Tab active={tab === 'settings'} onClick={changeTab('settings')}>
|
||||
Настройки
|
||||
</Tab>
|
||||
)}
|
||||
</Tabs>
|
||||
<Tabs.List items={items} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue