Add GroupAvatar component
This commit is contained in:
parent
7070630eaf
commit
c8a4d63fc8
|
@ -5,7 +5,8 @@ import GroupMemberCount from 'soapbox/features/group/components/group-member-cou
|
||||||
import GroupPrivacy from 'soapbox/features/group/components/group-privacy';
|
import GroupPrivacy from 'soapbox/features/group/components/group-privacy';
|
||||||
import GroupRelationship from 'soapbox/features/group/components/group-relationship';
|
import GroupRelationship from 'soapbox/features/group/components/group-relationship';
|
||||||
|
|
||||||
import { Avatar, HStack, Stack, Text } from './ui';
|
import GroupAvatar from './groups/group-avatar';
|
||||||
|
import { HStack, Stack, Text } from './ui';
|
||||||
|
|
||||||
import type { Group as GroupEntity } from 'soapbox/types/entities';
|
import type { Group as GroupEntity } from 'soapbox/types/entities';
|
||||||
|
|
||||||
|
@ -37,7 +38,7 @@ const GroupCard: React.FC<IGroupCard> = ({ group }) => {
|
||||||
|
|
||||||
{/* Group Avatar */}
|
{/* Group Avatar */}
|
||||||
<div className='absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2'>
|
<div className='absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2'>
|
||||||
<Avatar className='ring-2 ring-white dark:ring-primary-900' src={group.avatar} size={64} />
|
<GroupAvatar group={group} size={64} withRing />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Group Info */}
|
{/* Group Info */}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
import { useGroupRoles } from 'soapbox/hooks/useGroupRoles';
|
||||||
|
|
||||||
|
import { Avatar } from '../ui';
|
||||||
|
|
||||||
|
import type { Group } from 'soapbox/schemas';
|
||||||
|
|
||||||
|
interface IGroupAvatar {
|
||||||
|
group: Group
|
||||||
|
size: number
|
||||||
|
withRing?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
const GroupAvatar = (props: IGroupAvatar) => {
|
||||||
|
const { group, size, withRing = false } = props;
|
||||||
|
|
||||||
|
const { normalizeRole } = useGroupRoles();
|
||||||
|
|
||||||
|
const isAdmin = normalizeRole(group.relationship?.role as any) === 'admin';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Avatar
|
||||||
|
className={
|
||||||
|
clsx('relative rounded-full', {
|
||||||
|
'shadow-[0_0_0_2px_theme(colors.primary.600),0_0_0_4px_theme(colors.white)]': isAdmin && withRing,
|
||||||
|
'shadow-[0_0_0_2px_theme(colors.primary.600)]': isAdmin && !withRing,
|
||||||
|
'shadow-[0_0_0_2px_theme(colors.white)]': !isAdmin && withRing,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
src={group.avatar}
|
||||||
|
size={size}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default GroupAvatar;
|
|
@ -3,8 +3,9 @@ import React from 'react';
|
||||||
import { defineMessages, useIntl } from 'react-intl';
|
import { defineMessages, useIntl } from 'react-intl';
|
||||||
|
|
||||||
import { openModal } from 'soapbox/actions/modals';
|
import { openModal } from 'soapbox/actions/modals';
|
||||||
|
import GroupAvatar from 'soapbox/components/groups/group-avatar';
|
||||||
import StillImage from 'soapbox/components/still-image';
|
import StillImage from 'soapbox/components/still-image';
|
||||||
import { Avatar, HStack, Stack, Text } from 'soapbox/components/ui';
|
import { HStack, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useAppDispatch } from 'soapbox/hooks';
|
import { useAppDispatch } from 'soapbox/hooks';
|
||||||
import { normalizeAttachment } from 'soapbox/normalizers';
|
import { normalizeAttachment } from 'soapbox/normalizers';
|
||||||
import { isDefaultHeader } from 'soapbox/utils/accounts';
|
import { isDefaultHeader } from 'soapbox/utils/accounts';
|
||||||
|
@ -109,10 +110,10 @@ const GroupHeader: React.FC<IGroupHeader> = ({ group }) => {
|
||||||
|
|
||||||
<div className='absolute left-1/2 bottom-0 -translate-x-1/2 translate-y-1/2'>
|
<div className='absolute left-1/2 bottom-0 -translate-x-1/2 translate-y-1/2'>
|
||||||
<a href={group.avatar} onClick={handleAvatarClick} target='_blank'>
|
<a href={group.avatar} onClick={handleAvatarClick} target='_blank'>
|
||||||
<Avatar
|
<GroupAvatar
|
||||||
className='ring-[3px] ring-white dark:ring-primary-900'
|
group={group}
|
||||||
src={group.avatar}
|
|
||||||
size={80}
|
size={80}
|
||||||
|
withRing
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,7 +2,8 @@ import React, { forwardRef } from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { Avatar, Button, HStack, Stack, Text } from 'soapbox/components/ui';
|
import GroupAvatar from 'soapbox/components/groups/group-avatar';
|
||||||
|
import { Button, HStack, Stack, Text } from 'soapbox/components/ui';
|
||||||
import GroupMemberCount from 'soapbox/features/group/components/group-member-count';
|
import GroupMemberCount from 'soapbox/features/group/components/group-member-count';
|
||||||
import GroupPrivacy from 'soapbox/features/group/components/group-privacy';
|
import GroupPrivacy from 'soapbox/features/group/components/group-privacy';
|
||||||
import { useJoinGroup } from 'soapbox/queries/groups';
|
import { useJoinGroup } from 'soapbox/queries/groups';
|
||||||
|
@ -43,9 +44,8 @@ const GroupGridItem = forwardRef((props: IGroup, ref: React.ForwardedRef<HTMLDiv
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Stack justifyContent='end' className='z-10 p-4 text-white' space={3}>
|
<Stack justifyContent='end' className='z-10 p-4 text-white' space={3}>
|
||||||
<Avatar
|
<GroupAvatar
|
||||||
className='ring-2 ring-white'
|
group={group}
|
||||||
src={group.avatar}
|
|
||||||
size={44}
|
size={44}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ import React from 'react';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
|
||||||
import { Avatar, Button, HStack, Icon, Stack, Text } from 'soapbox/components/ui';
|
import GroupAvatar from 'soapbox/components/groups/group-avatar';
|
||||||
|
import { Button, HStack, Icon, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useJoinGroup } from 'soapbox/queries/groups';
|
import { useJoinGroup } from 'soapbox/queries/groups';
|
||||||
import { Group as GroupEntity } from 'soapbox/types/entities';
|
import { Group as GroupEntity } from 'soapbox/types/entities';
|
||||||
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
import { shortNumberFormat } from 'soapbox/utils/numbers';
|
||||||
|
@ -26,9 +27,8 @@ const GroupListItem = (props: IGroup) => {
|
||||||
>
|
>
|
||||||
<Link key={group.id} to={`/groups/${group.id}`}>
|
<Link key={group.id} to={`/groups/${group.id}`}>
|
||||||
<HStack alignItems='center' space={2}>
|
<HStack alignItems='center' space={2}>
|
||||||
<Avatar
|
<GroupAvatar
|
||||||
className='ring-2 ring-white dark:ring-primary-900'
|
group={group}
|
||||||
src={group.avatar}
|
|
||||||
size={44}
|
size={44}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
|
/**
|
||||||
|
* Schemas
|
||||||
|
*/
|
||||||
export { customEmojiSchema } from './custom-emoji';
|
export { customEmojiSchema } from './custom-emoji';
|
||||||
export type { CustomEmoji } from './custom-emoji';
|
|
||||||
export { groupSchema } from './group';
|
export { groupSchema } from './group';
|
||||||
export type { Group } from './group';
|
|
||||||
export { groupMemberSchema } from './group-member';
|
export { groupMemberSchema } from './group-member';
|
||||||
export type { GroupMember } from './group-member';
|
|
||||||
export { groupRelationshipSchema } from './group-relationship';
|
export { groupRelationshipSchema } from './group-relationship';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Entity Types
|
||||||
|
*/
|
||||||
|
export type { CustomEmoji } from './custom-emoji';
|
||||||
|
export type { Group } from './group';
|
||||||
|
export type { GroupMember } from './group-member';
|
||||||
export type { GroupRelationship } from './group-relationship';
|
export type { GroupRelationship } from './group-relationship';
|
||||||
|
|
Loading…
Reference in New Issue