import React, { ReactElement, ReactNode } from "react"; import classNames from "classnames"; import { THEME } from "../../types"; import { Avatar, AvatarProps, AvatarSize, AVATAR_TYPE } from "../Avatar"; import { Box } from "../Box"; import { Flex } from "../Flex"; import { Link } from "../Link"; import { MenuRenderer, useMenuContext } from "../MenuRenderer"; import { PopoverMenu } from "../PopoverMenu"; import { Text } from "../Text"; import { AppbarDropdownIcon } from "./AppbarDropdownIcon"; import { AppbarTabMarker } from "./AppbarTabMarker"; import { cn, popperModifiers } from "./config"; type AppbarUserNameProps = { avatar: ReactElement; name?: string; }; type AppbarUserDropdownProps = { avatar: ReactElement; children: ReactNode; name?: string; onClose?: () => void; }; type AppbarUserDropdownMenuProps = { children: ReactNode; }; type AppbarUserProps = { avatar: ReactElement; name?: string; }; type AppbarUserDropdownMenuItemProps = { as?: any; onClick?: () => void; selected?: boolean; [key: string]: any; }; const AppbarUserName = ({ name, avatar }: AppbarUserNameProps) => ( {avatar} {name && {name}} ); // Deprecated: Remove this component in v2 export const AppbarUserAvatar = (props: AvatarProps) => { const sharedClassNames = "mr-2"; const sharedProps = { size: "medium" as AvatarSize, square: true, }; if (props.type === AVATAR_TYPE.SYSTEM) { return ( ); } if (props.type === AVATAR_TYPE.USER && props.email) { return ( ); } return ( ); }; export const AppbarUserDropdown = ({ name, avatar, children, onClose, }: AppbarUserDropdownProps) => { return ( ( )} > {({ listProps }) => ( {children} )} ); }; export const AppbarUserDropdownMenu = ({ children, }: AppbarUserDropdownMenuProps) => <>{children}; export const AppbarUserDropdownMenuItem = ({ children, onClick, as, className, ...rest }: AppbarUserDropdownMenuItemProps) => { const { itemProps, onClose } = useMenuContext(); return ( { if (typeof onClick === "function") { onClick(); } if (typeof onClose === "function") { onClose(); } }} {...rest} {...itemProps} > {children} ); }; export const AppbarUser = ({ name, avatar }: AppbarUserProps) => { return ( ); };