mirror of
https://github.com/mastodon/mastodon.git
synced 2025-05-07 12:16:14 +00:00
refactor: Badge
This commit is contained in:
parent
733c1171b1
commit
1fa95e13cd
|
@ -1,31 +0,0 @@
|
||||||
import PropTypes from 'prop-types';
|
|
||||||
|
|
||||||
import { FormattedMessage } from 'react-intl';
|
|
||||||
|
|
||||||
import GroupsIcon from '@/material-icons/400-24px/group.svg?react';
|
|
||||||
import PersonIcon from '@/material-icons/400-24px/person.svg?react';
|
|
||||||
import SmartToyIcon from '@/material-icons/400-24px/smart_toy.svg?react';
|
|
||||||
|
|
||||||
|
|
||||||
export const Badge = ({ icon = <PersonIcon />, label, domain, roleId }) => (
|
|
||||||
<div className='account-role' data-account-role-id={roleId}>
|
|
||||||
{icon}
|
|
||||||
{label}
|
|
||||||
{domain && <span className='account-role__domain'>{domain}</span>}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
|
|
||||||
Badge.propTypes = {
|
|
||||||
icon: PropTypes.node,
|
|
||||||
label: PropTypes.node,
|
|
||||||
domain: PropTypes.node,
|
|
||||||
roleId: PropTypes.string
|
|
||||||
};
|
|
||||||
|
|
||||||
export const GroupBadge = () => (
|
|
||||||
<Badge icon={<GroupsIcon />} label={<FormattedMessage id='account.badges.group' defaultMessage='Group' />} />
|
|
||||||
);
|
|
||||||
|
|
||||||
export const AutomatedBadge = () => (
|
|
||||||
<Badge icon={<SmartToyIcon />} label={<FormattedMessage id='account.badges.bot' defaultMessage='Automated' />} />
|
|
||||||
);
|
|
45
app/javascript/mastodon/components/badge.tsx
Normal file
45
app/javascript/mastodon/components/badge.tsx
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
import type { FC, ReactNode } from 'react';
|
||||||
|
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
|
|
||||||
|
import GroupsIcon from '@/material-icons/400-24px/group.svg?react';
|
||||||
|
import PersonIcon from '@/material-icons/400-24px/person.svg?react';
|
||||||
|
import SmartToyIcon from '@/material-icons/400-24px/smart_toy.svg?react';
|
||||||
|
|
||||||
|
interface BadgeProps {
|
||||||
|
icon?: ReactNode;
|
||||||
|
label?: ReactNode;
|
||||||
|
domain?: ReactNode;
|
||||||
|
roleId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Badge: FC<BadgeProps> = ({
|
||||||
|
icon = <PersonIcon />,
|
||||||
|
label,
|
||||||
|
domain,
|
||||||
|
roleId,
|
||||||
|
}) => (
|
||||||
|
<div className='account-role' data-account-role-id={roleId}>
|
||||||
|
{icon}
|
||||||
|
{label}
|
||||||
|
{domain && <span className='account-role__domain'>{domain}</span>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const GroupBadge = () => (
|
||||||
|
<Badge
|
||||||
|
icon={<GroupsIcon />}
|
||||||
|
label={
|
||||||
|
<FormattedMessage id='account.badges.group' defaultMessage='Group' />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const AutomatedBadge = () => (
|
||||||
|
<Badge
|
||||||
|
icon={<SmartToyIcon />}
|
||||||
|
label={
|
||||||
|
<FormattedMessage id='account.badges.bot' defaultMessage='Automated' />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user