2023-10-24 17:45:08 +00:00
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
|
|
|
|
2024-01-16 10:27:26 +00:00
|
|
|
import AlternateEmailIcon from '@/material-icons/400-24px/alternate_email.svg?react';
|
|
|
|
import LockIcon from '@/material-icons/400-24px/lock.svg?react';
|
|
|
|
import PublicIcon from '@/material-icons/400-24px/public.svg?react';
|
2024-01-25 15:41:31 +00:00
|
|
|
import QuietTimeIcon from '@/material-icons/400-24px/quiet_time.svg?react';
|
2024-03-28 15:33:15 +00:00
|
|
|
import type { StatusVisibility } from 'mastodon/models/status';
|
2023-10-24 17:45:08 +00:00
|
|
|
|
|
|
|
import { Icon } from './icon';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
public_short: { id: 'privacy.public.short', defaultMessage: 'Public' },
|
2024-01-25 15:41:31 +00:00
|
|
|
unlisted_short: {
|
|
|
|
id: 'privacy.unlisted.short',
|
|
|
|
defaultMessage: 'Quiet public',
|
|
|
|
},
|
2023-10-24 17:45:08 +00:00
|
|
|
private_short: {
|
|
|
|
id: 'privacy.private.short',
|
2024-01-25 15:41:31 +00:00
|
|
|
defaultMessage: 'Followers',
|
2023-10-24 17:45:08 +00:00
|
|
|
},
|
|
|
|
direct_short: {
|
|
|
|
id: 'privacy.direct.short',
|
2024-01-25 15:41:31 +00:00
|
|
|
defaultMessage: 'Specific people',
|
2023-10-24 17:45:08 +00:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2024-03-28 15:33:15 +00:00
|
|
|
export const VisibilityIcon: React.FC<{ visibility: StatusVisibility }> = ({
|
2023-10-24 17:45:08 +00:00
|
|
|
visibility,
|
|
|
|
}) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
const visibilityIconInfo = {
|
|
|
|
public: {
|
|
|
|
icon: 'globe',
|
|
|
|
iconComponent: PublicIcon,
|
|
|
|
text: intl.formatMessage(messages.public_short),
|
|
|
|
},
|
|
|
|
unlisted: {
|
|
|
|
icon: 'unlock',
|
2024-01-25 15:41:31 +00:00
|
|
|
iconComponent: QuietTimeIcon,
|
2023-10-24 17:45:08 +00:00
|
|
|
text: intl.formatMessage(messages.unlisted_short),
|
|
|
|
},
|
|
|
|
private: {
|
|
|
|
icon: 'lock',
|
|
|
|
iconComponent: LockIcon,
|
|
|
|
text: intl.formatMessage(messages.private_short),
|
|
|
|
},
|
|
|
|
direct: {
|
|
|
|
icon: 'at',
|
|
|
|
iconComponent: AlternateEmailIcon,
|
|
|
|
text: intl.formatMessage(messages.direct_short),
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
const visibilityIcon = visibilityIconInfo[visibility];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Icon
|
|
|
|
id={visibilityIcon.icon}
|
|
|
|
icon={visibilityIcon.iconComponent}
|
|
|
|
title={visibilityIcon.text}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
};
|