2023-10-13 18:48:01 -07:00
|
|
|
import React from 'react';
|
2023-10-13 19:32:59 -07:00
|
|
|
import { Link } from 'react-router-dom';
|
2023-10-13 18:48:01 -07:00
|
|
|
|
|
|
|
import { Tooltip } from './ui';
|
|
|
|
|
|
|
|
import type { Mention as MentionEntity } from 'soapbox/schemas';
|
|
|
|
|
|
|
|
interface IMention {
|
|
|
|
mention: Pick<MentionEntity, 'acct' | 'username'>;
|
2023-10-13 19:32:59 -07:00
|
|
|
disabled?: boolean;
|
2023-10-13 18:48:01 -07:00
|
|
|
}
|
|
|
|
|
2023-10-13 19:32:59 -07:00
|
|
|
/** Mention for display in post content and the composer. */
|
|
|
|
const Mention: React.FC<IMention> = ({ mention: { acct, username }, disabled }) => {
|
|
|
|
const handleClick: React.MouseEventHandler = (e) => {
|
|
|
|
if (disabled) {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2023-10-13 18:48:01 -07:00
|
|
|
return (
|
|
|
|
<Tooltip text={`@${acct}`}>
|
2023-10-13 19:32:59 -07:00
|
|
|
<Link
|
|
|
|
to={`/@${acct}`}
|
2023-10-13 18:48:01 -07:00
|
|
|
className='text-primary-600 hover:underline dark:text-accent-blue'
|
2023-10-13 19:32:59 -07:00
|
|
|
onClick={handleClick}
|
2023-10-13 18:48:01 -07:00
|
|
|
dir='ltr'
|
|
|
|
>
|
2024-04-29 09:43:33 -07:00
|
|
|
@{username}
|
2023-10-13 19:32:59 -07:00
|
|
|
</Link>
|
2023-10-13 18:48:01 -07:00
|
|
|
</Tooltip>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-05-13 10:00:42 -07:00
|
|
|
export { Mention as default };
|