diff --git a/app/javascript/mastodon/features/account/components/domain_pill.jsx b/app/javascript/mastodon/features/account/components/domain_pill.jsx deleted file mode 100644 index 0dadb947f9..0000000000 --- a/app/javascript/mastodon/features/account/components/domain_pill.jsx +++ /dev/null @@ -1,86 +0,0 @@ -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, -}; diff --git a/app/javascript/mastodon/features/account/components/domain_pill.tsx b/app/javascript/mastodon/features/account/components/domain_pill.tsx new file mode 100644 index 0000000000..956afa19c3 --- /dev/null +++ b/app/javascript/mastodon/features/account/components/domain_pill.tsx @@ -0,0 +1,197 @@ +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: React.FC<{ + domain: string; + username: string; + isSelf: boolean; +}> = ({ 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 && ( + <> + + + + + + + > + )} + + )} + + > + ); +};
{isSelf ? : }
{isSelf ? {x} }} /> : {x} }} />}
+ {isSelf ? ( + + ) : ( + + )} +
+ {isSelf ? ( + ( + + {x} + + ), + }} + /> + ) : ( + ( + + {x} + + ), + }} + /> + )} +
+ +