/* eslint-disable spaced-comment */
import React from 'react';
//import Avatar from '@tutorbook/avatar';
import { Icon } from '@rmwc/icon';
import { Ripple } from '@rmwc/ripple';
import { Link } from '@tutorbook/intl';
//import { Account } from '@tutorbook/model';
import signout from '@tutorbook/account/signout';
import styles from './pop-over.module.scss';
interface PopOverLinkProps {
href: string;
as?: string;
children: string;
icon?: string;
}
function PopOverLink({
href,
as,
children,
icon,
}: PopOverLinkProps): JSX.Element {
return (
);
}
interface PopOverButtonProps {
onClick: () => void;
children: string;
icon?: string;
}
function PopOverButton({
onClick,
children,
icon,
}: PopOverButtonProps): JSX.Element {
return (
);
}
//interface PopOverAccountProps {
//account: Account;
//checked?: boolean;
//}
//function PopOverAccountButton({
//account,
//onClick,
//checked,
//}: { onClick: () => void } & PopOverAccountProps): JSX.Element {
//return (
//
//
//
//);
//}
//function PopOverAccountLink({
//account,
//href,
//checked,
//}: { href: string } & PopOverAccountProps): JSX.Element {
//return (
///* eslint-disable jsx-a11y/anchor-is-valid */
//
//
//
///* eslint-enable jsx-a11y/anchor-is-valid */
//);
//}
interface PopOverMenuProps {
open: boolean;
onClose: () => void;
children: JSX.Element;
}
export default function PopOverMenu({
open,
onClose,
children,
}: PopOverMenuProps): JSX.Element {
const menuRef: React.RefObject = React.createRef<
HTMLDivElement
>();
const [visible, setVisible] = React.useState(open);
const [closing, setClosing] = React.useState(false);
React.useEffect(() => {
if (!menuRef.current) return () => {};
const element: HTMLElement = menuRef.current;
const removeClickListener = () => {
/* eslint-disable-next-line @typescript-eslint/no-use-before-define */
document.removeEventListener('click', outsideClickListener);
};
const outsideClickListener = (event: MouseEvent) => {
if (!element.contains(event.target as Node) && open) {
onClose();
removeClickListener();
}
};
document.addEventListener('click', outsideClickListener);
return removeClickListener;
});
React.useEffect(() => {
// Workaround to ensure `visibility` stays `visible` while animating the
// opacity and elevation (during closing).
if (!open) {
setClosing(true);
setTimeout(() => setVisible(false), 500);
} else {
setClosing(false);
setVisible(true);
}
}, [open]);
return (
{children}
Profile
Dashboard
Home
Logout
);
}