45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
import type { FC } from 'react';
|
|
|
|
import { FormattedMessage } from 'react-intl';
|
|
|
|
import type { NavLinkProps } from 'react-router-dom';
|
|
import { NavLink } from 'react-router-dom';
|
|
|
|
import { useAccount } from '@/mastodon/hooks/useAccount';
|
|
import { useAccountId } from '@/mastodon/hooks/useAccountId';
|
|
|
|
import classes from './redesign.module.scss';
|
|
|
|
const isActive: Required<NavLinkProps>['isActive'] = (match, location) =>
|
|
match?.url === location.pathname ||
|
|
(!!match?.url && location.pathname.startsWith(`${match.url}/tagged/`));
|
|
|
|
export const AccountTabs: FC = () => {
|
|
const accountId = useAccountId();
|
|
const account = useAccount(accountId);
|
|
|
|
if (!account) {
|
|
return null;
|
|
}
|
|
|
|
const { acct, show_featured, show_media } = account;
|
|
|
|
return (
|
|
<div className={classes.tabs}>
|
|
<NavLink isActive={isActive} to={`/@${acct}`}>
|
|
<FormattedMessage id='account.activity' defaultMessage='Activity' />
|
|
</NavLink>
|
|
{show_media && (
|
|
<NavLink exact to={`/@${acct}/media`}>
|
|
<FormattedMessage id='account.media' defaultMessage='Media' />
|
|
</NavLink>
|
|
)}
|
|
{show_featured && (
|
|
<NavLink exact to={`/@${acct}/featured`}>
|
|
<FormattedMessage id='account.featured' defaultMessage='Featured' />
|
|
</NavLink>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|