Skip to content

Commit cb83b1d

Browse files
authored
Merge branch 'master' into icon-library-change
2 parents 3ac4b02 + 11c7c62 commit cb83b1d

9 files changed

Lines changed: 69 additions & 67 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Reactjs chat elements
66

7-
## NOTE: this package not support react-native anymore.
7+
## NOTE: this package does not support react-native anymore.
88

99
## **[Full Documentation](https://detaysoft.github.io/docs-react-chat-elements/)**, **[Changelog](https://github.com/Detaysoft/react-chat-elements/blob/master/CHANGELOG.md)**
1010

example/App.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,13 @@ button {
114114
.rce-mlist {
115115
padding: 1rem 0;
116116
}
117+
118+
.chat-item-sub-text {
119+
display: flex;
120+
align-items: center;
121+
font-size: 12px;
122+
column-gap: 3px;
123+
margin-top: 3px;
124+
opacity: 0.7;
125+
color: teal;
126+
}

example/components/ChatListExample.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { useEffect, useState } from 'react'
44
import ChatList from '../../src/ChatList/ChatList'
55
import SideBar from '../../src/SideBar/SideBar'
66
import { IChatItemProps } from '../../src/type'
7+
import { FaUsers } from 'react-icons/fa'
78

89
import { HugeiconsIcon } from '@hugeicons/react';
910
// @ts-ignore
@@ -84,21 +85,18 @@ function ChatListExample() {
8485
showMute: Math.floor((Math.random() * 10) % 2) === 1,
8586
showVideoCall: Math.floor((Math.random() * 10) % 2) === 1,
8687
customStatusComponents: [Test],
87-
subList: nested && [getRandomLiteChat(), getRandomLiteChat()]
88+
subTextElement: Math.floor((Math.random() * 100) % 2) === 1 ? getSubTextElement() : <></>,
8889
};
8990
}
9091

91-
const getRandomLiteChat: any = () => {
92-
return {
93-
id: String(Math.random()),
94-
avatar: `data:image/png;base64,${photo(20)}`,
95-
avatarFlexible: true,
96-
title: loremIpsum({ count: 2, units: 'words' }),
97-
subtitle: loremIpsum({ count: 1, units: 'sentences' }),
98-
date: new Date(),
99-
unread: Math.floor((Math.random() * 10) % 3),
100-
};
101-
};
92+
const getSubTextElement = () => {
93+
return (
94+
<div className='chat-item-sub-text'>
95+
<FaUsers />
96+
<span>{loremIpsum({ count: 2, units: 'words' })}</span>
97+
</div>
98+
)
99+
}
102100

103101
return (
104102
<div className='chat-list'>

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.18",
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.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@
186186
height: 18px;
187187
}
188188

189+
.rce-citem-body--subinfo {
190+
display: flex;
191+
}
192+
189193
.rce-container-citem.subitem .rce-citem {
190194
height: 40px;
191195
padding-left: 30px;

src/ChatList/ChatList.tsx

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ const ChatList: React.FC<IChatListProps> = props => {
3030
props.onDragLeave?.(e, id)
3131
}
3232

33-
const onExpand: ChatListEvent = (item, index, event) => {
34-
if (props.onExpand instanceof Function) props.onExpand(item, index, event)
35-
}
36-
3733
return (
3834
<div className={classNames('rce-container-clist', props.className)}>
3935
{props.dataSource.map((x, i: number) => (
@@ -53,33 +49,7 @@ const ChatList: React.FC<IChatListProps> = props => {
5349
onDragLeave={onDragLeaveMW}
5450
onDragComponent={props.onDragComponent}
5551
setDragStates={setDragStates}
56-
onExpandItem={(e: React.MouseEvent<HTMLElement>) => onExpand(x, i, e)}
57-
expanded={x.expanded}
5852
/>
59-
{x.subList && x.subList.length > 0 && (
60-
<>
61-
{x.expanded && x.subList.map((sub, j) => (
62-
<ChatItem
63-
{...sub}
64-
className='subitem'
65-
avatarSize='xsmall'
66-
key={`${i}-${j}`}
67-
lazyLoadingImage={props.lazyLoadingImage}
68-
onAvatarError={(e: React.MouseEvent<HTMLElement>) => onAvatarError(sub, j, e)}
69-
onContextMenu={(e: React.MouseEvent<HTMLElement>) => onContextMenu(sub, j, e)}
70-
onClick={(e: React.MouseEvent<HTMLElement>) => onClick(sub, j, e)}
71-
onClickMute={(e: React.MouseEvent<HTMLElement>) => props.onClickMute?.(sub, j, e)}
72-
onClickVideoCall={(e: React.MouseEvent<HTMLElement>) => props.onClickVideoCall?.(sub, j, e)}
73-
onDragOver={props?.onDragOver}
74-
onDragEnter={props?.onDragEnter}
75-
onDrop={props.onDrop}
76-
onDragLeave={onDragLeaveMW}
77-
onDragComponent={props.onDragComponent}
78-
setDragStates={setDragStates}
79-
/>
80-
))}
81-
</>
82-
)}
8353
</>
8454
))}
8555
</div>

src/type.d.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +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 subList The Chat Item's sub chat items and optional.
33-
* @prop onExpandItem The Chat Item's expand function onExpandItem(id: string) and optional.
34-
* @prop expanded The Chat Item's expanded 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.
3534
*/
3635
export interface IChatItemProps {
3736
id: string | number
@@ -65,9 +64,8 @@ export interface IChatItemProps {
6564
onDragComponent?: any
6665
letterItem?: ILetterItem
6766
customStatusComponents?: React.ElementType<any>[]
68-
subList?: IChatItemProps[]
69-
onExpandItem?: Function
70-
expanded?: boolean;
67+
subTextElement?: JSX.Element
68+
miniAvatar?: string
7169
}
7270

7371
/**
@@ -97,7 +95,6 @@ export interface ILetterItem {
9795
* @prop onDrop The Chat Item's drop function and optional.
9896
* @prop onDragLeave The Chat Item's drop leave function and optional.
9997
* @prop onDragComponent The Chat Item's drag component and optional.
100-
* @prop onExpand The Chat Item's expand function and optional.
10198
*/
10299
export interface IChatListProps {
103100
id: string | number
@@ -115,7 +112,6 @@ export interface IChatListProps {
115112
onDrop?: Function
116113
onDragLeave?: Function
117114
onDragComponent?: Function
118-
onExpand?: Function
119115
}
120116

121117
/**
@@ -1036,6 +1032,7 @@ export interface IPopupProps {
10361032
* @prop statusColorType The Avatar's status color type and optional.
10371033
* @prop statusColor The Avatar's status color and optional.
10381034
* @prop statusText The Avatar's status text and optional.
1035+
* @prop miniImage The Avatar's mini image and optional.
10391036
*/
10401037
export interface IAvatarProps {
10411038
src: string
@@ -1051,6 +1048,7 @@ export interface IAvatarProps {
10511048
statusColorType?: string
10521049
statusColor?: string
10531050
statusText?: string
1051+
miniImage?: string
10541052
}
10551053

10561054
/**

0 commit comments

Comments
 (0)