2018-01-05 23:04:13 -05:00
|
|
|
// Package imports.
|
2017-12-29 17:55:06 -05:00
|
|
|
import classNames from 'classnames';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-05-02 20:04:16 -04:00
|
|
|
import React from 'react';
|
2016-09-01 08:12:11 -04:00
|
|
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
|
|
|
|
2018-01-05 23:04:13 -05:00
|
|
|
// The component.
|
|
|
|
export default function DisplayName ({
|
|
|
|
account,
|
|
|
|
className,
|
|
|
|
inline,
|
2019-01-19 12:55:27 -05:00
|
|
|
localDomain,
|
2018-01-05 23:04:13 -05:00
|
|
|
}) {
|
|
|
|
const computedClass = classNames('display-name', { inline }, className);
|
2016-09-01 08:12:11 -04:00
|
|
|
|
2019-01-19 12:55:27 -05:00
|
|
|
if (!account) return null;
|
|
|
|
|
|
|
|
let acct = account.get('acct');
|
|
|
|
if (acct.indexOf('@') === -1 && localDomain) {
|
|
|
|
acct = `${acct}@${localDomain}`;
|
|
|
|
}
|
|
|
|
|
2018-01-05 23:04:13 -05:00
|
|
|
// The result.
|
|
|
|
return account ? (
|
|
|
|
<span className={computedClass}>
|
2018-10-22 12:52:59 -04:00
|
|
|
<bdi><strong className='display-name__html' dangerouslySetInnerHTML={{ __html: account.get('display_name_html') }} /></bdi>
|
2018-01-05 23:04:13 -05:00
|
|
|
{inline ? ' ' : null}
|
2019-01-19 12:55:27 -05:00
|
|
|
<span className='display-name__account'>@{acct}</span>
|
2018-01-05 23:04:13 -05:00
|
|
|
</span>
|
|
|
|
) : null;
|
2017-04-21 14:05:35 -04:00
|
|
|
}
|
2018-01-05 23:04:13 -05:00
|
|
|
|
|
|
|
// Props.
|
|
|
|
DisplayName.propTypes = {
|
|
|
|
account: ImmutablePropTypes.map,
|
|
|
|
className: PropTypes.string,
|
|
|
|
inline: PropTypes.bool,
|
2019-01-19 12:55:27 -05:00
|
|
|
localDomain: PropTypes.string,
|
2018-01-05 23:04:13 -05:00
|
|
|
};
|