Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement - Relationship Icon #160

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/api/room/widgets/AvatarInfoName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export class AvatarInfoName
public readonly id: number,
public readonly name: string,
public readonly userType: number,
public readonly isFriend: boolean = false)
public readonly isFriend: boolean = false,
public readonly relationshipStatus: number = 0)
{}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { FC, useMemo } from 'react';
import { AvatarInfoName, GetSessionDataManager } from '../../../../../api';
import { AvatarInfoName, GetSessionDataManager, MessengerFriend } from '../../../../../api';
import { ContextMenuView } from '../../context-menu/ContextMenuView';

interface AvatarInfoWidgetNameViewProps
Expand All @@ -17,12 +17,25 @@ export const AvatarInfoWidgetNameView: FC<AvatarInfoWidgetNameViewProps> = props
const newClassNames: string[] = [ 'name-only' ];

if(nameInfo.isFriend) newClassNames.push('is-friend');
switch(nameInfo.relationshipStatus)
{
case MessengerFriend.RELATIONSHIP_HEART:
newClassNames.push('is-heart');
break;
case MessengerFriend.RELATIONSHIP_SMILE:
newClassNames.push('is-smile');
break;
case MessengerFriend.RELATIONSHIP_BOBBA:
newClassNames.push('is-bobba');
break;
}

return newClassNames;
}, [ nameInfo ]);

return (
<ContextMenuView objectId={ nameInfo.roomIndex } category={ nameInfo.category } userType={ nameInfo.userType } fades={ (nameInfo.id !== GetSessionDataManager().userId) } classNames={ getClassNames } onClose={ onClose }>
<div className="relation-icon"></div>
<div className="text-shadow">
{ nameInfo.name }
</div>
Expand Down
30 changes: 30 additions & 0 deletions src/components/room/widgets/context-menu/ContextMenu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,33 @@
width: unset;
text-align: center;
font-size: 18px;
display: flex;
align-items: center;

&.is-friend {
background-color: rgba($green, 0.5);
}

&.is-heart {
.relation-icon {
display: block;
background-position: -5px -67px;
}
}

&.is-smile {
.relation-icon {
display: block;
background-position: -57px -67px;
}
}

&.is-bobba {
.relation-icon {
display: block;
background-position: -96px -5px;
}
}
}

&:not(.name-only):not(.menu-hidden) {
Expand Down Expand Up @@ -126,4 +149,11 @@
}
}
}

.relation-icon {
display: none;
background: url('@/assets/images/friends/friends-spritesheet.png') transparent no-repeat;
width: 16px; height: 14px;
margin-right: 3px;
}
}
5 changes: 3 additions & 2 deletions src/hooks/rooms/widgets/useAvatarInfoWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ const useAvatarInfoWidgetState = () =>
{
if(user.webID === GetSessionDataManager().userId) return;

if(friends.find(friend => (friend.id === user.webID)))
const addedNameBubblesUserFriend = friends.find(friend => (friend.id === user.webID));
if (addedNameBubblesUserFriend)
{
addedNameBubbles.push(new AvatarInfoName(user.roomIndex, RoomObjectCategory.UNIT, user.webID, user.name, user.type, true));
addedNameBubbles.push(new AvatarInfoName(user.roomIndex, RoomObjectCategory.UNIT, user.webID, user.name, user.type, true, addedNameBubblesUserFriend.relationshipStatus));
}
});

Expand Down