Skip to content

Commit 04ea3e7

Browse files
author
einan
committed
Mini avatar added.
1 parent 57fd0bc commit 04ea3e7

5 files changed

Lines changed: 44 additions & 17 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-chat-elements",
3-
"version": "12.0.16",
3+
"version": "12.0.17",
44
"description": "Reactjs chat components",
55
"author": "Avare Kodcu <abdurrahmaneker58@gmail.com>",
66
"main": "dist/main.js",

src/Avatar/Avatar.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,15 @@
9090
width: 35px;
9191
border-radius: 20px;
9292
}
93+
94+
.rce-mini-avatar-container {
95+
position: absolute;
96+
right: 5px;
97+
bottom: 2.5px;
98+
}
99+
100+
.rce-citem-avatar .rce-mini-avatar-container img {
101+
width: 35px !important;
102+
height: 35px !important;
103+
border: 2px solid #FFF !important;
104+
}

src/Avatar/Avatar.tsx

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,22 +58,32 @@ const Avatar: React.FC<IAvatarProps> = ({ type = 'default', size = 'default', la
5858
}
5959

6060
return (
61-
// @ts-ignore
62-
<div className={classNames('rce-avatar-container', type, size, props.className)}>
63-
{props.letterItem ? (
64-
<div className='rce-avatar-letter-background' style={{ backgroundColor: stringToColour(props.letterItem.id) }}>
65-
<span className='rce-avatar-letter'>{props.letterItem.letter}</span>
61+
<>
62+
{/* @ts-ignore */}
63+
<div className={classNames('rce-avatar-container', type, size, props.className)}>
64+
{props.letterItem ? (
65+
<div className='rce-avatar-letter-background' style={{ backgroundColor: stringToColour(props.letterItem.id) }}>
66+
<span className='rce-avatar-letter'>{props.letterItem.letter}</span>
67+
</div>
68+
) : (
69+
<img
70+
alt={props.alt}
71+
src={src}
72+
onError={props.onError}
73+
className={classNames('rce-avatar', { 'rce-avatar-lazy': isLazyImage })}
74+
/>
75+
)}
76+
{props.sideElement}
6677
</div>
67-
) : (
68-
<img
69-
alt={props.alt}
70-
src={src}
71-
onError={props.onError}
72-
className={classNames('rce-avatar', { 'rce-avatar-lazy': isLazyImage })}
73-
/>
74-
)}
75-
{props.sideElement}
76-
</div>
78+
79+
{props.miniImage && (
80+
<div className='rce-mini-avatar-container'>
81+
<img
82+
src={props.miniImage}
83+
/>
84+
</div>
85+
)}
86+
</>
7787
)
7888
}
7989
export default Avatar

src/ChatItem/ChatItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ const ChatItem: React.FC<IChatItemProps> = ({
109109
onError={onAvatarError}
110110
lazyLoadingImage={lazyLoadingImage}
111111
type={classNames('circle', { 'flexible': avatarFlexible })}
112+
miniImage={props.miniAvatar}
112113
/>
113114
</div>,
114115
<div key={'rce-citem-body'} className='rce-citem-body'>

src/type.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ import React from 'react'
2929
* @prop onDragLeave The Chat Item's drop leave function and optional.
3030
* @prop onDragComponent The Chat Item's drag component and optional.
3131
* @prop letterItem The Chat Item's avatar letterItem and optional.
32-
* @prop subTextElement The Chat Item's sub text element and optional
32+
* @prop subTextElement The Chat Item's sub text element and optional.
33+
* @prop miniAvatar The Chat Item's mini avatar and optional.
3334
*/
3435
export interface IChatItemProps {
3536
id: string | number
@@ -64,6 +65,7 @@ export interface IChatItemProps {
6465
letterItem?: ILetterItem
6566
customStatusComponents?: React.ElementType<any>[]
6667
subTextElement?: JSX.Element
68+
miniAvatar?: string
6769
}
6870

6971
/**
@@ -1030,6 +1032,7 @@ export interface IPopupProps {
10301032
* @prop statusColorType The Avatar's status color type and optional.
10311033
* @prop statusColor The Avatar's status color and optional.
10321034
* @prop statusText The Avatar's status text and optional.
1035+
* @prop miniImage The Avatar's mini image and optional.
10331036
*/
10341037
export interface IAvatarProps {
10351038
src: string
@@ -1045,6 +1048,7 @@ export interface IAvatarProps {
10451048
statusColorType?: string
10461049
statusColor?: string
10471050
statusText?: string
1051+
miniImage?: string
10481052
}
10491053

10501054
/**

0 commit comments

Comments
 (0)