2022-12-15 14:51:30 -08:00
|
|
|
import React from 'react';
|
2023-03-08 10:22:10 -08:00
|
|
|
import { defineMessages, useIntl } from 'react-intl';
|
2022-12-15 14:51:30 -08:00
|
|
|
|
2023-03-08 10:22:10 -08:00
|
|
|
import GroupMemberCount from 'soapbox/features/group/components/group-member-count';
|
|
|
|
import GroupPrivacy from 'soapbox/features/group/components/group-privacy';
|
|
|
|
import GroupRelationship from 'soapbox/features/group/components/group-relationship';
|
|
|
|
|
2023-03-14 11:44:48 -07:00
|
|
|
import GroupAvatar from './groups/group-avatar';
|
|
|
|
import { HStack, Stack, Text } from './ui';
|
2022-12-15 14:51:30 -08:00
|
|
|
|
|
|
|
import type { Group as GroupEntity } from 'soapbox/types/entities';
|
|
|
|
|
|
|
|
const messages = defineMessages({
|
|
|
|
groupHeader: { id: 'group.header.alt', defaultMessage: 'Group header' },
|
|
|
|
});
|
|
|
|
|
|
|
|
interface IGroupCard {
|
|
|
|
group: GroupEntity
|
|
|
|
}
|
|
|
|
|
|
|
|
const GroupCard: React.FC<IGroupCard> = ({ group }) => {
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
|
|
return (
|
2023-03-08 10:22:10 -08:00
|
|
|
<Stack
|
|
|
|
className='relative h-[240px] rounded-lg border border-solid border-gray-300 bg-white dark:border-primary-800 dark:bg-primary-900'
|
|
|
|
data-testid='group-card'
|
|
|
|
>
|
2023-02-27 05:25:59 -08:00
|
|
|
{/* Group Cover Image */}
|
|
|
|
<Stack grow className='relative basis-1/2 rounded-t-lg bg-primary-100 dark:bg-gray-800'>
|
|
|
|
{group.header && (
|
|
|
|
<img
|
|
|
|
className='absolute inset-0 h-full w-full rounded-t-lg object-cover'
|
|
|
|
src={group.header} alt={intl.formatMessage(messages.groupHeader)}
|
|
|
|
/>
|
|
|
|
)}
|
2022-12-15 14:51:30 -08:00
|
|
|
</Stack>
|
2023-02-27 05:25:59 -08:00
|
|
|
|
|
|
|
{/* Group Avatar */}
|
2023-04-01 11:37:34 -07:00
|
|
|
<div className='absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2'>
|
2023-03-14 11:44:48 -07:00
|
|
|
<GroupAvatar group={group} size={64} withRing />
|
2023-02-27 05:25:59 -08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
{/* Group Info */}
|
|
|
|
<Stack alignItems='center' justifyContent='end' grow className='basis-1/2 py-4' space={0.5}>
|
2023-03-29 10:21:43 -07:00
|
|
|
<HStack alignItems='center' space={1.5}>
|
|
|
|
<Text size='lg' weight='bold' dangerouslySetInnerHTML={{ __html: group.display_name_html }} />
|
|
|
|
|
|
|
|
{group.relationship?.pending_requests && (
|
|
|
|
<div className='h-2 w-2 rounded-full bg-secondary-500' />
|
|
|
|
)}
|
|
|
|
</HStack>
|
2023-02-27 05:25:59 -08:00
|
|
|
|
2023-03-08 10:22:10 -08:00
|
|
|
<HStack className='text-gray-700 dark:text-gray-600' space={2} wrap>
|
|
|
|
<GroupRelationship group={group} />
|
|
|
|
<GroupPrivacy group={group} />
|
|
|
|
<GroupMemberCount group={group} />
|
2023-02-27 05:25:59 -08:00
|
|
|
</HStack>
|
|
|
|
</Stack>
|
|
|
|
</Stack>
|
2022-12-15 14:51:30 -08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default GroupCard;
|