Skip to content

Commit b94ced5

Browse files
committed
Merge branch 'users-tag'
2 parents 29a86ee + 30ffe3c commit b94ced5

File tree

12 files changed

+435
-236
lines changed

12 files changed

+435
-236
lines changed

README.md

Lines changed: 41 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -327,129 +327,23 @@ multiline code
327327

328328
Example: set `"accepted-files="image/png, image/jpeg, application/pdf"` to allow `JPG` `PNG` and `PDF` files
329329

330-
(18) `styles` can be used to customize your own theme. Ex:
330+
(18) `styles` can be used to customize your own theme. You can find the full list [here](src/themes/index.js)
331331

332332
```javascript
333333
styles="{
334334
general: {
335335
color: '#0a0a0a',
336-
backgroundInput: '#fff',
337-
colorPlaceholder: '#9ca6af',
338-
colorCaret: '#1976d2',
339336
colorSpinner: '#333',
340-
borderStyle: '1px solid #e1e4e8',
341-
backgroundScrollIcon: '#fff'
342-
},
343-
344-
container: {
345-
border: 'none',
346-
borderRadius: '4px',
347-
boxShadow: '0px 3px 1px 1px #000'
348-
},
349-
350-
header: {
351-
background: '#fff',
352-
colorRoomName: '#0a0a0a',
353-
colorRoomInfo: '#9ca6af'
337+
borderStyle: '1px solid #e1e4e8'
354338
},
355339
356340
footer: {
357341
background: '#f8f9fa',
358-
borderStyleInput: '1px solid #e1e4e8',
359-
borderInputSelected: '#1976d2',
360342
backgroundReply: 'rgba(0, 0, 0, 0.08)'
361343
},
362344
363-
content: {
364-
background: '#f8f9fa'
365-
},
366-
367-
sidemenu: {
368-
background: '#fff',
369-
backgroundHover: '#f6f6f6',
370-
backgroundActive: '#e5effa',
371-
colorActive: '#1976d2',
372-
borderColorSearch: '#e1e5e8'
373-
},
374-
375-
dropdown: {
376-
background: '#fff',
377-
backgroundHover: '#f6f6f6'
378-
},
379-
380-
message: {
381-
background: '#fff',
382-
backgroundMe: '#ccf2cf',
383-
color: '#0a0a0a',
384-
colorStarted: '#9ca6af',
385-
backgroundDeleted: '#dadfe2',
386-
colorDeleted: '#757e85',
387-
colorUsername: '#9ca6af',
388-
colorTimestamp: '#828c94',
389-
backgroundDate: '#e5effa',
390-
colorDate: '#505a62',
391-
backgroundSystem: '#e5effa',
392-
colorSystem: '#505a62',
393-
backgroundReply: 'rgba(0, 0, 0, 0.08)',
394-
colorReplyUsername: '#0a0a0a',
395-
colorReply: '#6e6e6e',
396-
backgroundImage: '#ddd',
397-
colorNewMessages: '#1976d2',
398-
backgroundReaction: '#eee',
399-
borderStyleReaction: '1px solid #eee',
400-
backgroundReactionHover: '#fff',
401-
borderStyleReactionHover: '1px solid #ddd',
402-
colorReactionCounter: '#0a0a0a',
403-
backgroundReactionMe: '#cfecf5',
404-
borderStyleReactionMe: '1px solid #3b98b8',
405-
backgroundReactionHoverMe: '#cfecf5',
406-
borderStyleReactionHoverMe: '1px solid #3b98b8',
407-
colorReactionCounterMe: '#0b59b3'
408-
},
409-
410-
markdown: {
411-
background: 'rgba(239, 239, 239, 0.7)',
412-
border: 'rgba(212, 212, 212, 0.9)',
413-
color: '#e01e5a',
414-
colorMulti: '#0a0a0a'
415-
},
416-
417-
room: {
418-
colorUsername: '#0a0a0a',
419-
colorMessage: '#67717a',
420-
colorTimestamp: '#a2aeb8',
421-
colorStateOnline: '#4caf50',
422-
colorStateOffline: '#ccc',
423-
backgroundCounterBadge: '#0696c7',
424-
colorCounterBadge: '#fff'
425-
},
426-
427-
emoji: {
428-
background: '#fff'
429-
},
430-
431345
icons: {
432-
search: '#9ca6af',
433-
add: '#1976d2',
434-
toggle: '#0a0a0a',
435-
menu: '#0a0a0a',
436-
close: '#9ca6af',
437-
closeImage: '#fff',
438-
file: '#1976d2',
439-
paperclip: '#1976d2',
440-
closeOutline: '#000',
441-
send: '#1976d2',
442-
sendDisabled: '#9ca6af',
443-
emoji: '#1976d2',
444-
emojiReaction: '#828c94',
445-
document: '#1976d2',
446-
pencil: '#9e9e9e',
447-
checkmark: '#9e9e9e',
448-
checkmarkSeen: '#0696c7',
449-
eye: '#fff',
450-
dropdownMessage: '#fff',
451-
dropdownMessageBackground: 'rgba(0, 0, 0, 0.25)',
452-
dropdownScroll: '#0a0a0a'
346+
search: '#9ca6af'
453347
}
454348
}"
455349
```
@@ -467,12 +361,12 @@ rooms="[
467361
roomName: 'Room 1',
468362
avatar: 'assets/imgs/people.png',
469363
unreadCount: 4,
364+
index: 3,
470365
lastMessage: {
471366
content: 'Last message received',
472367
sender_id: 1234,
473368
username: 'John Doe',
474369
timestamp: '10:20',
475-
date: 123242424,
476370
saved: true,
477371
distributed: false,
478372
seen: false,
@@ -503,8 +397,8 @@ rooms="[
503397
]"
504398
```
505399

506-
- If you set a `date` to `lastMessage` property, your rooms will be ordered using this date value.
507-
`date` can be any sortable value, like a `string`, `datetime`, `timestamp`, etc.
400+
- If you add the `index` property, your rooms will be ordered using this value.
401+
`index` can be any sortable value, like a `string`, `datetime`, `timestamp`, etc.
508402

509403
- For each room user, you can add the `status` property, which can hold the `state` and `last_changed` properties:
510404

@@ -566,28 +460,40 @@ messages="[
566460

567461
## Events API
568462

569-
| Event | Params | Fires when |
570-
| --------------------------- | --------------------------------------------------------------- | ----------------------------------------------------- |
571-
| fetch-messages (1) | `{ room, options }` | A user has scrolled on top to load more messages |
572-
| fetch-more-rooms (2) | - | A user has scrolled to load more rooms |
573-
| send-message | `{ roomId, content, file (6), replyMessage (7) }` | A user has sent a message |
574-
| edit-message | `{ roomId, messageId, newContent, file (6), replyMessage (7) }` | A user has edited a message |
575-
| delete-message | `{ roomId, messageId }` | A user has deleted a message |
576-
| open-file | `{ message, action }` | A user has clicked to view or download a file |
577-
| add-room | - | A user clicks on the plus icon next to searchbar |
578-
| menu-action-handler (3) | `{ roomId, action }` | A user clicks on the vertical dots icon inside a room |
579-
| message-action-handler (4) | `{ roomId, action, message }` | A user clicks on the dropdown icon inside a message |
580-
| send-message-reaction | `{ roomId, messageId, reaction, remove }` | A user clicks on the emoji icon inside a message |
581-
| room-info | `room` | A user clicks the room header bar |
582-
| toggle-rooms-list | `{ opened }` | A user clicks on the toggle icon inside a room header |
583-
| textarea-action-handler (5) | `{ roomId, message }` | A user clicks on custom icon inside the footer |
584-
| typing-message | `{ message, roomId }` | A user is typing a message |
463+
| Event | Params | Fires when |
464+
| --------------------------- | ------------------------------------------------------------------------ | ----------------------------------------------------- |
465+
| fetch-messages (1) | `{ room, options }` | A user has scrolled on top to load more messages |
466+
| fetch-more-rooms (2) | - | A user has scrolled to load more rooms |
467+
| send-message | `{ roomId, content, file (7), replyMessage (8), usersTag }` | A user has sent a message |
468+
| edit-message | `{ roomId, messageId, newContent, file (6), replyMessage (8),usersTag }` | A user has edited a message |
469+
| delete-message | `{ roomId, messageId }` | A user has deleted a message |
470+
| open-file | `{ message, action }` | A user has clicked to view or download a file |
471+
| open-user-tag (3) | `{ user }` | A user has clicked on a user tag inside a message |
472+
| add-room | - | A user clicks on the plus icon next to searchbar |
473+
| menu-action-handler (4) | `{ roomId, action }` | A user clicks on the vertical dots icon inside a room |
474+
| message-action-handler (5) | `{ roomId, action, message }` | A user clicks on the dropdown icon inside a message |
475+
| send-message-reaction | `{ roomId, messageId, reaction, remove }` | A user clicks on the emoji icon inside a message |
476+
| room-info | `room` | A user clicks the room header bar |
477+
| toggle-rooms-list | `{ opened }` | A user clicks on the toggle icon inside a room header |
478+
| textarea-action-handler (6) | `{ roomId, message }` | A user clicks on custom icon inside the footer |
479+
| typing-message | `{ message, roomId }` | A user is typing a message |
585480

586481
(1) `fetch-messages` is triggered every time a room is opened. If the room is opened for the first time, the `options` param will hold `reset: true`.<br>
587482
(1) `fetch-messages` should be a method implementing a pagination system. Its purpose is to load older messages of a conversation when the user scroll on top.
588483

589-
(3) `menu-action-handler` is the result of the `menuActions` prop.<br>
590-
When clicking a button from your `menuActions` array, `menuActionHandler` will give you the name of the button that was click.
484+
(2) `fetch-more-rooms` is triggered when scrolling down the rooms list, and should be a method implementing a pagination system.
485+
486+
(3) `open-user-tag` is triggered when clicking a user tag inside a message. When creating a user tag by typing `@` in the footer textarea and sending the message, the tag will be identified with the below pattern:
487+
488+
```javascript
489+
<usertag>TAGGED_USER_ID</usertag>
490+
```
491+
492+
This will make the tag clickable inside a message. Ex: [message tag content](#messages-collection-inside-a-room-document)<br>
493+
`send-message` and `edit-message` events will handle that pattern for you and pass it in the `content` param.
494+
495+
(4) `menu-action-handler` is the result of the [`menu-actions`](#props-api) prop.<br>
496+
When clicking a button from your `menu-actions` array, `menu-action-handler` will give you the name of the button that was click.
591497
Then you can do whatever you want with it. Ex:
592498

593499
```javascript
@@ -603,7 +509,7 @@ menuActionHandler({ roomId, action }) {
603509
}
604510
```
605511

606-
(4) `message-action-handler` is the result of the `message-actions` prop.<br>
512+
(5) `message-action-handler` is the result of the `message-actions` prop.<br>
607513
When clicking a message menu button from your `message-actions` array, `message-action-handler` will give you the name of the button that was click and the corresponding message data.
608514
Then you can do whatever you want with it. Ex:
609515

@@ -618,11 +524,11 @@ messageActionHandler({ roomId, action, message }) {
618524
}
619525
```
620526

621-
(5) `textarea-action-handler` can be used to add an extra icon on the right of the textarea, and recieve an event when clicking it.
527+
(6) `textarea-action-handler` can be used to add an extra icon on the right of the textarea, and recieve an event when clicking it.
622528

623-
(6) All file params contain: `{ blob, localURL, name, size, type, extension }`
529+
(7) All file params contain: `{ blob, localURL, name, size, type, extension }`
624530

625-
(7) `replyMessage` object is available when the user replied to another message by clicking the corresponding icon, and contains the message information that was clicked.
531+
(8) `replyMessage` object is available when the user replied to another message by clicking the corresponding icon, and contains the message information that was clicked.
626532

627533
## Named Slots
628534

@@ -724,7 +630,7 @@ chatRooms: {
724630
```javascript
725631
messages: {
726632
MESSAGE_ID_1: {
727-
content: 'My first message',
633+
content: 'My first message to <usertag>John</usertag>',
728634
sender_id: 2,
729635
timestamp: 'December 11, 2019 at 4:00:00 PM',
730636
seen: true

0 commit comments

Comments
 (0)