webapp/src/components/Nav/ProfilePopup.tsx

75 lines
2.3 KiB
TypeScript
Raw Normal View History

2022-11-14 10:02:08 +00:00
import type { PopupProps } from '../_shared/Popup'
import { getPagePath } from '@nanostores/router'
2023-02-17 09:21:02 +00:00
import { useLocalize } from '../../context/localize'
import { useSession } from '../../context/session'
import { router } from '../../stores/router'
2024-05-06 22:01:20 +00:00
import { Icon } from '../_shared/Icon'
2024-05-06 22:13:16 +00:00
import { Popup } from '../_shared/Popup'
2024-05-06 22:13:16 +00:00
import { clsx } from 'clsx'
import styles from '../_shared/Popup/Popup.module.scss'
2022-10-26 19:22:22 +00:00
type ProfilePopupProps = Omit<PopupProps, 'children'>
export const ProfilePopup = (props: ProfilePopupProps) => {
2024-02-04 17:40:15 +00:00
const { author, signOut } = useSession()
const { t } = useLocalize()
2023-02-17 09:21:02 +00:00
2022-10-26 19:22:22 +00:00
return (
2022-12-17 03:27:00 +00:00
<Popup {...props} horizontalAnchor="right" variant="bordered">
2022-10-26 19:22:22 +00:00
<ul class="nodash">
<li>
2024-05-06 22:01:20 +00:00
<a class={styles.action} href={getPagePath(router, 'author', { slug: author().slug })}>
2024-05-06 22:13:16 +00:00
<Icon name="profile" class={styles.icon} />
2024-05-06 22:01:20 +00:00
{t('Profile')}
</a>
2022-10-26 19:22:22 +00:00
</li>
<li>
2024-05-06 22:01:20 +00:00
<a class={styles.action} href={getPagePath(router, 'drafts')}>
2024-05-06 22:13:16 +00:00
<Icon name="pencil-outline" class={styles.icon} />
2024-05-06 22:01:20 +00:00
{t('Drafts')}
</a>
2022-10-26 19:22:22 +00:00
</li>
<li>
2024-05-06 22:13:16 +00:00
<a
class={styles.action}
href={`${getPagePath(router, 'author', { slug: author().slug })}?m=following`}
>
<Icon name="feed-all" class={styles.icon} />
{t('Subscriptions')}
</a>
2022-10-26 19:22:22 +00:00
</li>
<li>
2024-05-06 22:13:16 +00:00
<a
class={styles.action}
href={`${getPagePath(router, 'authorComments', { slug: author().slug })}`}
>
<Icon name="comment" class={styles.icon} />
2024-05-06 22:01:20 +00:00
{t('Comments')}
</a>
2022-10-26 19:22:22 +00:00
</li>
<li>
2024-05-06 22:01:20 +00:00
<a class={styles.action} href="#">
2024-05-06 22:13:16 +00:00
<Icon name="bookmark" class={styles.icon} />
2024-05-06 22:01:20 +00:00
{t('Bookmarks')}
</a>
2022-10-26 19:22:22 +00:00
</li>
<li>
2024-05-06 22:01:20 +00:00
<a class={styles.action} href={getPagePath(router, 'profileSettings')}>
2024-05-06 22:13:16 +00:00
<Icon name="settings" class={styles.icon} />
2024-05-06 22:01:20 +00:00
{t('Settings')}
</a>
2022-10-26 19:22:22 +00:00
</li>
2022-11-02 21:55:29 +00:00
<li class={styles.topBorderItem}>
2024-05-06 22:01:20 +00:00
<span class={clsx(styles.action, 'link')} onClick={() => signOut()}>
2024-05-06 22:13:16 +00:00
<Icon name="logout" class={styles.icon} />
2023-02-17 09:21:02 +00:00
{t('Logout')}
</span>
2022-10-26 19:22:22 +00:00
</li>
</ul>
</Popup>
)
}