This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon/app/javascript/flavours/glitch/features/drawer/account/index.js

77 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-12-26 16:54:28 -08:00
// Package imports.
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
import {
FormattedMessage,
defineMessages,
} from 'react-intl';
// Components.
import Avatar from 'flavours/glitch/components/avatar';
import Permalink from 'flavours/glitch/components/permalink';
// Utils.
import { hiddenComponent } from 'flavours/glitch/util/react_helpers';
2018-09-25 05:46:14 -07:00
import { profileLink } from 'flavours/glitch/util/backend_links';
2017-12-26 16:54:28 -08:00
// Messages.
const messages = defineMessages({
edit: {
defaultMessage: 'Edit profile',
id: 'navigation_bar.edit_profile',
},
});
// The component.
2017-12-29 14:55:06 -08:00
export default function DrawerAccount ({ account }) {
2017-12-26 16:54:28 -08:00
// We need an account to render.
if (!account) {
return (
<div className='drawer--account'>
2018-09-25 05:46:14 -07:00
{ profileLink !== undefined && (
<a
className='edit'
href={ profileLink }
>
<FormattedMessage {...messages.edit} />
</a>
)}
2017-12-26 16:54:28 -08:00
</div>
);
}
// The result.
return (
<div className='drawer--account'>
2017-12-26 16:54:28 -08:00
<Permalink
className='avatar'
href={account.get('url')}
to={`/accounts/${account.get('id')}`}
>
<span {...hiddenComponent}>{account.get('acct')}</span>
<Avatar
account={account}
size={40}
/>
</Permalink>
<Permalink
className='acct'
href={account.get('url')}
to={`/accounts/${account.get('id')}`}
>
<strong>@{account.get('acct')}</strong>
</Permalink>
2018-09-25 05:46:14 -07:00
{ profileLink !== undefined && (
<a
className='edit'
href={ profileLink }
><FormattedMessage {...messages.edit} /></a>
)}
2017-12-26 16:54:28 -08:00
</div>
);
}
// Props.
2017-12-29 14:55:06 -08:00
DrawerAccount.propTypes = { account: ImmutablePropTypes.map };