bigbuffet-rw/app/soapbox/features/follow_recommendations/components/account.tsx
marcin mikołajczak 7a36837585 typescript, FC
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2022-04-12 22:40:09 +02:00

46 lines
1.4 KiB
TypeScript

import React from 'react';
import Avatar from 'soapbox/components/avatar';
import DisplayName from 'soapbox/components/display_name';
import Permalink from 'soapbox/components/permalink';
import ActionButton from 'soapbox/features/ui/components/action_button';
import { useAppSelector } from 'soapbox/hooks';
import { makeGetAccount } from 'soapbox/selectors';
const getAccount = makeGetAccount();
const getFirstSentence = (str: string) => {
const arr = str.split(/(([.?!]+\s)|[.。?!\n•])/);
return arr[0];
};
interface IAccount {
id: string,
}
const Account: React.FC<IAccount> = ({ id }) => {
const account = useAppSelector((state) => getAccount(state, id));
if (!account) return null;
return (
<div className='account follow-recommendations-account'>
<div className='account__wrapper'>
<Permalink className='account__display-name account__display-name--with-note' title={account.acct} href={account.url} to={`/@${account.get('acct')}`}>
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
<DisplayName account={account} />
<div className='account__note'>{getFirstSentence(account.get('note_plain'))}</div>
</Permalink>
<div className='account__relationship'>
<ActionButton account={account} />
</div>
</div>
</div>
);
};
export default Account;