pleroma/app/soapbox/features/groups/components/group-link-preview.tsx

43 lines
1.2 KiB
TypeScript
Raw Normal View History

2023-04-17 13:34:48 -07:00
import React from 'react';
import { useHistory } from 'react-router-dom';
import { Avatar, Button, CardTitle, Stack } from 'soapbox/components/ui';
import { type Card as StatusCard } from 'soapbox/types/entities';
interface IGroupLinkPreview {
card: StatusCard
}
const GroupLinkPreview: React.FC<IGroupLinkPreview> = ({ card }) => {
const history = useHistory();
const { group } = card;
if (!group) return null;
2023-04-18 07:00:18 -07:00
const navigateToGroup = () => history.push(`/group/${group.slug}`);
2023-04-17 13:34:48 -07:00
return (
2023-04-18 06:39:09 -07:00
<Stack className='cursor-default overflow-hidden rounded-lg border border-gray-300 text-center dark:border-gray-800'>
2023-04-17 13:34:48 -07:00
<div
className='-mb-8 h-32 w-full bg-center'
style={{ backgroundImage: `url(${group.header})` }}
/>
<Avatar
2023-04-18 06:39:09 -07:00
className='mx-auto border-4 border-white dark:border-primary-900'
2023-04-17 13:34:48 -07:00
src={group.avatar}
size={64}
/>
<Stack space={4} className='p-4'>
<CardTitle title={<span dangerouslySetInnerHTML={{ __html: group.display_name_html }} />} />
<Button theme='primary' onClick={navigateToGroup} block>
View Group
</Button>
</Stack>
</Stack>
);
};
export { GroupLinkPreview };