import PropTypes from 'prop-types'; import { useState, useRef, useCallback } from 'react'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import Overlay from 'react-overlays/Overlay'; import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react'; import BadgeIcon from '@/material-icons/400-24px/badge.svg?react'; import GlobeIcon from '@/material-icons/400-24px/globe.svg?react'; import { Icon } from 'mastodon/components/icon'; export const DomainPill = ({ domain, username, isSelf }) => { const [open, setOpen] = useState(false); const [expanded, setExpanded] = useState(false); const triggerRef = useRef(null); const handleClick = useCallback(() => { setOpen(!open); }, [open, setOpen]); const handleExpandClick = useCallback(() => { setExpanded(!expanded); }, [expanded, setExpanded]); return ( <> {domain} {({ props }) => ( {isSelf ? : } @{username}@{domain} {isSelf ? : } {isSelf ? : } {isSelf ? {x} }} /> : {x} }} />} {expanded && ( <> > )} )} > ); }; DomainPill.propTypes = { username: PropTypes.string.isRequired, domain: PropTypes.string.isRequired, isSelf: PropTypes.bool, };
{isSelf ? : }
{isSelf ? {x} }} /> : {x} }} />}